Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Fix voice selection (#2664)
Charlie.Wei6a6133c102ad
diff --git a/api/controllers/console/app/audio.py b/api/controllers/console/app/audio.pyindex d2c1891b657..77eaf136fc6 100644--- a/api/controllers/console/app/audio.py+++ b/api/controllers/console/app/audio.py@@ -88,7 +88,7 @@ class ChatMessageTextApi(Resource):response = AudioService.transcript_tts(tenant_id=app_model.tenant_id,text=request.form['text'],- voice=app_model.app_model_config.text_to_speech_dict.get('voice'),+ voice=request.form['voice'] if request.form['voice'] else app_model.app_model_config.text_to_speech_dict.get('voice'),streaming=False)diff --git a/api/controllers/console/explore/audio.py b/api/controllers/console/explore/audio.pyindex f957d381740..dc546ce0dd2 100644--- a/api/controllers/console/explore/audio.py+++ b/api/controllers/console/explore/audio.py@@ -85,7 +85,7 @@ class ChatTextApi(InstalledAppResource):response = AudioService.transcript_tts(tenant_id=app_model.tenant_id,text=request.form['text'],- voice=app_model.app_model_config.text_to_speech_dict.get('voice'),+ voice=request.form['voice'] if request.form['voice'] else app_model.app_model_config.text_to_speech_dict.get('voice'),streaming=False)return {'data': response.data.decode('latin1')}diff --git a/api/controllers/service_api/app/audio.py b/api/controllers/service_api/app/audio.pyindex 58ab56a292f..60ca2171d52 100644--- a/api/controllers/service_api/app/audio.py+++ b/api/controllers/service_api/app/audio.py@@ -87,7 +87,7 @@ class TextApi(Resource):tenant_id=app_model.tenant_id,text=args['text'],end_user=end_user,- voice=app_model.app_model_config.text_to_speech_dict.get('voice'),+ voice=args['voice'] if args['voice'] else app_model.app_model_config.text_to_speech_dict.get('voice'),streaming=args['streaming'])diff --git a/api/controllers/web/audio.py b/api/controllers/web/audio.pyindex c628c166067..4e677ae288d 100644--- a/api/controllers/web/audio.py+++ b/api/controllers/web/audio.py@@ -84,7 +84,7 @@ class TextApi(WebApiResource):tenant_id=app_model.tenant_id,text=request.form['text'],end_user=end_user.external_user_id,- voice=app_model.app_model_config.text_to_speech_dict.get('voice'),+ voice=request.form['voice'] if request.form['voice'] else app_model.app_model_config.text_to_speech_dict.get('voice'),streaming=False)diff --git a/api/core/model_runtime/model_providers/openai/tts/tts.py b/api/core/model_runtime/model_providers/openai/tts/tts.pyindex b1718c063c7..f5e2ec4b7c5 100644--- a/api/core/model_runtime/model_providers/openai/tts/tts.py+++ b/api/core/model_runtime/model_providers/openai/tts/tts.py@@ -34,7 +34,7 @@ class OpenAIText2SpeechModel(_CommonOpenAI, TTSModel)::return: text translated to audio file"""audio_type = self._get_model_audio_type(model, credentials)- if not voice:+ if not voice or voice not in [d['value'] for d in self.get_tts_model_voices(model=model, credentials=credentials)]:voice = self._get_model_default_voice(model, credentials)if streaming:return Response(stream_with_context(self._tts_invoke_streaming(model=model,diff --git a/api/core/model_runtime/model_providers/tongyi/tts/tts.py b/api/core/model_runtime/model_providers/tongyi/tts/tts.pyindex 6bd17684fe2..937f469bdfa 100644--- a/api/core/model_runtime/model_providers/tongyi/tts/tts.py+++ b/api/core/model_runtime/model_providers/tongyi/tts/tts.py@@ -34,7 +34,7 @@ class TongyiText2SpeechModel(_CommonTongyi, TTSModel)::return: text translated to audio file"""audio_type = self._get_model_audio_type(model, credentials)- if not voice or voice not in self.get_tts_model_voices(model=model, credentials=credentials):+ if not voice or voice not in [d['value'] for d in self.get_tts_model_voices(model=model, credentials=credentials)]:voice = self._get_model_default_voice(model, credentials)if streaming:return Response(stream_with_context(self._tts_invoke_streaming(model=model,diff --git a/web/app/components/app/configuration/features/chat-group/text-to-speech/index.tsx b/web/app/components/app/configuration/features/chat-group/text-to-speech/index.tsxindex 6bd40547ca4..02cac061b44 100644--- a/web/app/components/app/configuration/features/chat-group/text-to-speech/index.tsx+++ b/web/app/components/app/configuration/features/chat-group/text-to-speech/index.tsx@@ -40,6 +40,7 @@ const TextToSpeech: FC = () => {{ languageInfo?.example && (<AudioBtnvalue={languageInfo?.example}+ voice={voiceItem?.value}isAudition={true}/>)}diff --git a/web/app/components/base/audio-btn/index.tsx b/web/app/components/base/audio-btn/index.tsxindex c10755d3a14..6c9f3e253be 100644--- a/web/app/components/base/audio-btn/index.tsx+++ b/web/app/components/base/audio-btn/index.tsx@@ -9,12 +9,14 @@ import { textToAudio } from '@/service/share'type AudioBtnProps = {value: string+ voice?: stringclassName?: stringisAudition?: boolean}const AudioBtn = ({value,+ voice,className,isAudition,}: AudioBtnProps) => {@@ -27,13 +29,16 @@ const AudioBtn = ({const pathname = usePathname()const removeCodeBlocks = (inputText: any) => {const codeBlockRegex = /```[\s\S]*?```/g- return inputText.replace(codeBlockRegex, '')+ if (inputText)+ return inputText.replace(codeBlockRegex, '')+ return ''}const playAudio = async () => {const formData = new FormData()if (value !== '') {formData.append('text', removeCodeBlocks(value))+ formData.append('voice', removeCodeBlocks(voice))let url = ''let isPublic = falsediff --git a/web/app/components/base/chat/chat/answer/operation.tsx b/web/app/components/base/chat/chat/answer/operation.tsxindex eb5dead6578..8a791d82dae 100644--- a/web/app/components/base/chat/chat/answer/operation.tsx+++ b/web/app/components/base/chat/chat/answer/operation.tsx@@ -77,6 +77,7 @@ const Operation: FC<OperationProps> = ({{(!isOpeningStatement && config?.text_to_speech?.enabled) && (<AudioBtnvalue={content}+ voice={config?.text_to_speech?.voice}className='hidden group-hover:block'/>)}