From 822f03f3cdf78e043308b147a00ef46fd99cb73f Mon Sep 17 00:00:00 2001 From: JzoNg Date: Mon, 26 Aug 2024 16:22:11 +0800 Subject: [PATCH] text to speech card --- .../base/features/new-feature-panel/index.tsx | 56 ++++++++++++++++++- web/i18n/en-US/app-debug.ts | 10 ++-- web/i18n/zh-Hans/app-debug.ts | 6 +- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/web/app/components/base/features/new-feature-panel/index.tsx b/web/app/components/base/features/new-feature-panel/index.tsx index 430b1ee748..7323cc25e2 100644 --- a/web/app/components/base/features/new-feature-panel/index.tsx +++ b/web/app/components/base/features/new-feature-panel/index.tsx @@ -3,20 +3,27 @@ import { useTranslation } from 'react-i18next' import produce from 'immer' import { RiCloseLine, + RiEqualizer2Line, RiQuestionLine, RiSparklingFill, } from '@remixicon/react' import { Citations, Microphone01, + TextToAudio, VirtualAssistant, } from '@/app/components/base/icons/src/vender/features' import DialogWrapper from '@/app/components/base/features/new-feature-panel/dialog-wrapper' import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks' +import { useDefaultModel } from '@/app/components/header/account-setting/model-provider-page/hooks' +import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import type { OnFeaturesChange } from '@/app/components/base/features/types' import { FeatureEnum } from '@/app/components/base/features/types' +import { TtsAutoPlay } from '@/types/app' +import { languages } from '@/i18n/language' import Switch from '@/app/components/base/switch' import Tooltip from '@/app/components/base/tooltip' +import Button from '@/app/components/base/button' type Props = { show: boolean @@ -28,6 +35,10 @@ type Props = { const NewFeaturePanel = ({ show, isChatMode, onChange, onClose }: Props) => { const { t } = useTranslation() + const { data: speech2textDefaultModel } = useDefaultModel(ModelTypeEnum.speech2text) + const { data: text2speechDefaultModel } = useDefaultModel(ModelTypeEnum.tts) + const textToSpeech = useFeatures(s => s.features.text2speech) // .language .voice .autoPlay + const languageInfo = languages.find(i => i.value === textToSpeech?.language) const features = useFeatures(s => s.features) const featuresStore = useFeaturesStore() @@ -90,7 +101,7 @@ const NewFeaturePanel = ({ show, isChatMode, onChange, onClose }: Props) => { )} {/* speech to text */} - {isChatMode && ( + {isChatMode && speech2textDefaultModel && (
@@ -104,6 +115,49 @@ const NewFeaturePanel = ({ show, isChatMode, onChange, onClose }: Props) => {
{t('appDebug.feature.speechToText.description')}
)} + {/* text to speech */} + {text2speechDefaultModel && ( +
+
+
+ +
+
+ {t('appDebug.feature.textToSpeech.title')} +
+ handleChange(FeatureEnum.text2speech, value)} defaultValue={!!features.text2speech?.enabled} /> +
+ {!features.text2speech?.enabled && ( +
{t('appDebug.feature.textToSpeech.description')}
+ )} + {!!features.text2speech?.enabled && ( + <> +
+
+
{t('appDebug.voice.voiceSettings.language')}
+
{languageInfo?.name || '-'}
+
+
+
+
{t('appDebug.voice.voiceSettings.voice')}
+
{features.text2speech?.voice || t('appDebug.voice.defaultDisplay')}
+
+
+
+
{t('appDebug.voice.voiceSettings.autoPlay')}
+
{features.text2speech?.autoPlay === TtsAutoPlay.enabled ? t('appDebug.voice.voiceSettings.autoPlayEnabled') : t('appDebug.voice.voiceSettings.autoPlayDisabled')}
+
+
+
+ +
+ + )} +
+ )} {/* follow up */} {isChatMode && (
diff --git a/web/i18n/en-US/app-debug.ts b/web/i18n/en-US/app-debug.ts index 06e800c4ca..612d3fe5f7 100644 --- a/web/i18n/en-US/app-debug.ts +++ b/web/i18n/en-US/app-debug.ts @@ -68,17 +68,17 @@ const translation = { }, speechToText: { title: 'Speech to Text', - description: 'Once enabled, you can use voice input.', + description: 'Voice input can be used in chat.', resDes: 'Voice input is enabled', }, textToSpeech: { title: 'Text to Speech', - description: 'Once enabled, text can be converted to speech.', + description: 'Conversation messages can be converted to speech.', resDes: 'Text to Audio is enabled', }, citation: { title: 'Citations and Attributions', - description: 'Once enabled, show source document and attributed section of the generated content.', + description: 'Show source document and attributed section of the generated content.', resDes: 'Citations and Attributions is enabled', }, annotation: { @@ -384,8 +384,8 @@ const translation = { resolutionTooltip: 'Text-to-speech voice support language。', voice: 'Voice', autoPlay: 'Auto Play', - autoPlayEnabled: 'Turn On', - autoPlayDisabled: 'Turn Off', + autoPlayEnabled: 'On', + autoPlayDisabled: 'Off', }, }, openingStatement: { diff --git a/web/i18n/zh-Hans/app-debug.ts b/web/i18n/zh-Hans/app-debug.ts index 87486b6082..288958b63a 100644 --- a/web/i18n/zh-Hans/app-debug.ts +++ b/web/i18n/zh-Hans/app-debug.ts @@ -68,17 +68,17 @@ const translation = { }, speechToText: { title: '语音转文字', - description: '启用后,您可以使用语音输入。', + description: '您可以使用语音输入。', resDes: '语音输入已启用', }, textToSpeech: { title: '文字转语音', - description: '启用后,文本可以转换成语音。', + description: '文本可以转换成语音。', resDes: '文本转音频已启用', }, citation: { title: '引用和归属', - description: '启用后,显示源文档和生成内容的归属部分。', + description: '显示源文档和生成内容的归属部分。', resDes: '引用和归属已启用', }, annotation: {