From 58df5e537604c131a1545ef2c6e3a3af0b060473 Mon Sep 17 00:00:00 2001 From: takatost Date: Fri, 16 Feb 2024 00:05:29 +0800 Subject: [PATCH] fix: tts voice language to zh-Hans instead of zh-CN (#2450) --- api/controllers/console/app/audio.py | 10 ---- .../model_providers/openai/tts/tts-1-hd.yaml | 14 ++--- .../model_providers/openai/tts/tts-1.yaml | 12 ++-- .../model_providers/tongyi/tts/tts-1.yaml | 58 +++++++++---------- .../config-voice/param-config-content.tsx | 18 +++--- 5 files changed, 51 insertions(+), 61 deletions(-) diff --git a/api/controllers/console/app/audio.py b/api/controllers/console/app/audio.py index a401763776..ac90dfcc8d 100644 --- a/api/controllers/console/app/audio.py +++ b/api/controllers/console/app/audio.py @@ -23,7 +23,6 @@ from controllers.console.wraps import account_initialization_required from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError from core.model_runtime.errors.invoke import InvokeError from libs.login import login_required -from models.model import AppModelConfig from services.audio_service import AudioService from services.errors.audio import ( AudioTooLargeServiceError, @@ -86,11 +85,6 @@ class ChatMessageTextApi(Resource): app_id = str(app_id) app_model = _get_app(app_id, None) - app_model_config: AppModelConfig = app_model.app_model_config - - if not app_model_config.text_to_speech_dict['enabled']: - raise AppUnavailableError() - try: response = AudioService.transcript_tts( tenant_id=app_model.tenant_id, @@ -129,10 +123,6 @@ class ChatMessageTextApi(Resource): class TextModesApi(Resource): def get(self, app_id: str): app_model = _get_app(str(app_id)) - app_model_config: AppModelConfig = app_model.app_model_config - - if not app_model_config.text_to_speech_dict['enabled']: - raise AppUnavailableError() try: parser = reqparse.RequestParser() diff --git a/api/core/model_runtime/model_providers/openai/tts/tts-1-hd.yaml b/api/core/model_runtime/model_providers/openai/tts/tts-1-hd.yaml index bc3c44beb7..94473edf9a 100644 --- a/api/core/model_runtime/model_providers/openai/tts/tts-1-hd.yaml +++ b/api/core/model_runtime/model_providers/openai/tts/tts-1-hd.yaml @@ -1,26 +1,26 @@ -model: tts-1 +model: tts-1-hd model_type: tts model_properties: default_voice: 'alloy' voices: - mode: 'alloy' name: 'Alloy' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'echo' name: 'Echo' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'fable' name: 'Fable' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'onyx' name: 'Onyx' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'nova' name: 'Nova' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'shimmer' name: 'Shimmer' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] word_limit: 120 audio_type: 'mp3' max_workers: 5 diff --git a/api/core/model_runtime/model_providers/openai/tts/tts-1.yaml b/api/core/model_runtime/model_providers/openai/tts/tts-1.yaml index e52602d1a1..ca8cbfac73 100644 --- a/api/core/model_runtime/model_providers/openai/tts/tts-1.yaml +++ b/api/core/model_runtime/model_providers/openai/tts/tts-1.yaml @@ -5,22 +5,22 @@ model_properties: voices: - mode: 'alloy' name: 'Alloy' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'echo' name: 'Echo' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'fable' name: 'Fable' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'onyx' name: 'Onyx' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'nova' name: 'Nova' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] - mode: 'shimmer' name: 'Shimmer' - language: ['zh-CN', 'en-US'] + language: ['zh-Hans', 'en-US'] word_limit: 120 audio_type: 'mp3' max_workers: 5 diff --git a/api/core/model_runtime/model_providers/tongyi/tts/tts-1.yaml b/api/core/model_runtime/model_providers/tongyi/tts/tts-1.yaml index 7627dfd0be..e533d5812d 100644 --- a/api/core/model_runtime/model_providers/tongyi/tts/tts-1.yaml +++ b/api/core/model_runtime/model_providers/tongyi/tts/tts-1.yaml @@ -5,91 +5,91 @@ model_properties: voices: - mode: "sambert-zhinan-v1" name: "知楠(广告男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiqi-v1" name: "知琪(温柔女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhichu-v1" name: "知厨(新闻播报)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhide-v1" name: "知德(新闻男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhijia-v1" name: "知佳(标准女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiru-v1" name: "知茹(新闻女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiqian-v1" name: "知倩(配音解说、新闻播报)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhixiang-v1" name: "知祥(配音解说)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiwei-v1" name: "知薇(萝莉女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhihao-v1" name: "知浩(咨询男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhijing-v1" name: "知婧(严厉女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiming-v1" name: "知茗(诙谐男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhimo-v1" name: "知墨(情感男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhina-v1" name: "知娜(浙普女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhishu-v1" name: "知树(资讯男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhistella-v1" name: "知莎(知性女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiting-v1" name: "知婷(电台女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhixiao-v1" name: "知笑(资讯女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiya-v1" name: "知雅(严厉女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiye-v1" name: "知晔(青年男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiying-v1" name: "知颖(软萌童声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhiyuan-v1" name: "知媛(知心姐姐)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhigui-v1" name: "知柜(直播女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhishuo-v1" name: "知硕(自然男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhimiao-emo-v1" name: "知妙(多种情感女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhimao-v1" name: "知猫(直播女声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhilun-v1" name: "知伦(悬疑解说)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhifei-v1" name: "知飞(激昂解说)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-zhida-v1" name: "知达(标准男声)" - language: [ "zh-CN", "en-US" ] + language: [ "zh-Hans", "en-US" ] - mode: "sambert-camila-v1" name: "Camila(西班牙语女声)" language: [ "es-ES" ] diff --git a/web/app/components/app/configuration/config-voice/param-config-content.tsx b/web/app/components/app/configuration/config-voice/param-config-content.tsx index bf6459df41..d055808692 100644 --- a/web/app/components/app/configuration/config-voice/param-config-content.tsx +++ b/web/app/components/app/configuration/config-voice/param-config-content.tsx @@ -21,14 +21,14 @@ const VoiceParamConfig: FC = () => { const appId = (matched?.length && matched[1]) ? matched[1] : '' const LanguageItems = [ - { value: 'zh-CN', name: '中文' }, - { value: 'en-US', name: '英语' }, - { value: 'de-DE', name: '德语' }, - { value: 'fr-FR', name: '法语' }, - { value: 'es-ES', name: '西班牙语' }, - { value: 'it-IT', name: '意大利语' }, - { value: 'th-TH', name: '泰语' }, - { value: 'id-ID', name: '印尼语' }, + { value: 'zh-Hans', name: 'Chinese' }, + { value: 'en-US', name: 'English' }, + { value: 'de-DE', name: 'German' }, + { value: 'fr-FR', name: 'French' }, + { value: 'es-ES', name: 'Spanish' }, + { value: 'it-IT', name: 'Italian' }, + { value: 'th-TH', name: 'Thai' }, + { value: 'id-ID', name: 'Indonesian' }, ] const { textToSpeechConfig, @@ -38,7 +38,7 @@ const VoiceParamConfig: FC = () => { const languageItem = LanguageItems.find(item => item.value === textToSpeechConfig.language) const localLanguagePlaceholder = languageItem?.name || t('common.placeholder.select') - const voiceItems = useSWR({ url: `/apps/${appId}/text-to-audio/voices?language=${languageItem ? languageItem.value : 'zh-CN'}` }, fetchAppVoices).data + const voiceItems = useSWR({ url: `/apps/${appId}/text-to-audio/voices?language=${languageItem ? languageItem.value : 'en-US'}` }, fetchAppVoices).data const voiceItem = voiceItems?.find(item => item.value === textToSpeechConfig.voice) const localVoicePlaceholder = voiceItem?.name || t('common.placeholder.select')