From 761c66a8d85b7224b50f374b8ce35b205f5ce3f6 Mon Sep 17 00:00:00 2001 From: Yanyutin753 <132346501+Yanyutin753@users.noreply.github.com> Date: Mon, 6 May 2024 15:23:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A4=A9=20Added=20custom=20openai=20tt?= =?UTF-8?q?s=20models=20and=20role=20variables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apps/audio/main.py | 12 ++++++ backend/config.py | 2 + src/lib/apis/audio/index.ts | 7 +++- src/lib/apis/openai/index.ts | 5 ++- .../chat/Messages/ResponseMessage.svelte | 3 +- src/lib/components/chat/Settings/Audio.svelte | 39 ++++++++++++++++++- src/lib/i18n/locales/ar-BH/translation.json | 1 + src/lib/i18n/locales/bg-BG/translation.json | 1 + src/lib/i18n/locales/bn-BD/translation.json | 1 + src/lib/i18n/locales/ca-ES/translation.json | 1 + src/lib/i18n/locales/de-DE/translation.json | 1 + src/lib/i18n/locales/dg-DG/translation.json | 1 + src/lib/i18n/locales/en-GB/translation.json | 1 + src/lib/i18n/locales/en-US/translation.json | 1 + src/lib/i18n/locales/es-ES/translation.json | 1 + src/lib/i18n/locales/fa-IR/translation.json | 1 + src/lib/i18n/locales/fr-CA/translation.json | 1 + src/lib/i18n/locales/fr-FR/translation.json | 1 + src/lib/i18n/locales/it-IT/translation.json | 1 + src/lib/i18n/locales/ja-JP/translation.json | 1 + src/lib/i18n/locales/ka-GE/translation.json | 1 + src/lib/i18n/locales/ko-KR/translation.json | 1 + src/lib/i18n/locales/nl-NL/translation.json | 1 + src/lib/i18n/locales/pl-PL/translation.json | 1 + src/lib/i18n/locales/pt-BR/translation.json | 1 + src/lib/i18n/locales/pt-PT/translation.json | 1 + src/lib/i18n/locales/ru-RU/translation.json | 1 + src/lib/i18n/locales/sv-SE/translation.json | 1 + src/lib/i18n/locales/tr-TR/translation.json | 1 + src/lib/i18n/locales/uk-UA/translation.json | 1 + src/lib/i18n/locales/vi-VN/translation.json | 1 + src/lib/i18n/locales/zh-CN/translation.json | 1 + src/lib/i18n/locales/zh-TW/translation.json | 1 + src/lib/stores/index.ts | 1 + 34 files changed, 89 insertions(+), 7 deletions(-) diff --git a/backend/apps/audio/main.py b/backend/apps/audio/main.py index addaf4b76..46ba788a8 100644 --- a/backend/apps/audio/main.py +++ b/backend/apps/audio/main.py @@ -43,6 +43,8 @@ from config import ( DEVICE_TYPE, AUDIO_OPENAI_API_BASE_URL, AUDIO_OPENAI_API_KEY, + AUDIO_OPENAI_API_MODEL, + AUDIO_OPENAI_API_SPEAKER ) log = logging.getLogger(__name__) @@ -60,6 +62,8 @@ app.add_middleware( app.state.OPENAI_API_BASE_URL = AUDIO_OPENAI_API_BASE_URL app.state.OPENAI_API_KEY = AUDIO_OPENAI_API_KEY +app.state.OPENAI_API_MODEL = AUDIO_OPENAI_API_MODEL +app.state.OPENAI_API_SPEAKER = AUDIO_OPENAI_API_SPEAKER # setting device type for whisper model whisper_device_type = DEVICE_TYPE if DEVICE_TYPE and DEVICE_TYPE == "cuda" else "cpu" @@ -72,6 +76,8 @@ SPEECH_CACHE_DIR.mkdir(parents=True, exist_ok=True) class OpenAIConfigUpdateForm(BaseModel): url: str key: str + model: str + speaker: str @app.get("/config") @@ -79,6 +85,8 @@ async def get_openai_config(user=Depends(get_admin_user)): return { "OPENAI_API_BASE_URL": app.state.OPENAI_API_BASE_URL, "OPENAI_API_KEY": app.state.OPENAI_API_KEY, + "OPENAI_API_MODEL": app.state.OPENAI_API_MODEL, + "OPENAI_API_SPEAKER": app.state.OPENAI_API_SPEAKER } @@ -91,11 +99,15 @@ async def update_openai_config( app.state.OPENAI_API_BASE_URL = form_data.url app.state.OPENAI_API_KEY = form_data.key + app.state.OPENAI_API_MODEL = form_data.model + app.state.OPENAI_API_SPEAKER = form_data.speaker return { "status": True, "OPENAI_API_BASE_URL": app.state.OPENAI_API_BASE_URL, "OPENAI_API_KEY": app.state.OPENAI_API_KEY, + "OPENAI_API_MODEL": app.state.OPENAI_API_MODEL, + "OPENAI_API_SPEAKER": app.state.OPENAI_API_SPEAKER, } diff --git a/backend/config.py b/backend/config.py index 9208a845c..02352a092 100644 --- a/backend/config.py +++ b/backend/config.py @@ -574,6 +574,8 @@ IMAGE_GENERATION_MODEL = os.getenv("IMAGE_GENERATION_MODEL", "") AUDIO_OPENAI_API_BASE_URL = os.getenv("AUDIO_OPENAI_API_BASE_URL", OPENAI_API_BASE_URL) AUDIO_OPENAI_API_KEY = os.getenv("AUDIO_OPENAI_API_KEY", OPENAI_API_KEY) +AUDIO_OPENAI_API_MODEL = os.getenv("AUDIO_OPENAI_API_MODEL", "tts-1") +AUDIO_OPENAI_API_SPEAKER = os.getenv("AUDIO_OPENAI_API_SPEAKER", "alloy") #################################### # LiteLLM diff --git a/src/lib/apis/audio/index.ts b/src/lib/apis/audio/index.ts index 6679420d9..3b716d58e 100644 --- a/src/lib/apis/audio/index.ts +++ b/src/lib/apis/audio/index.ts @@ -30,6 +30,8 @@ export const getAudioConfig = async (token: string) => { type OpenAIConfigForm = { url: string; key: string; + model: string; + speaker: string; }; export const updateAudioConfig = async (token: string, payload: OpenAIConfigForm) => { @@ -95,7 +97,8 @@ export const transcribeAudio = async (token: string, file: File) => { export const synthesizeOpenAISpeech = async ( token: string = '', speaker: string = 'alloy', - text: string = '' + text: string = '', + OpenAIModel: string = 'tts-1' ) => { let error = null; @@ -106,7 +109,7 @@ export const synthesizeOpenAISpeech = async ( 'Content-Type': 'application/json' }, body: JSON.stringify({ - model: 'tts-1', + model: OpenAIModel, input: text, voice: speaker }) diff --git a/src/lib/apis/openai/index.ts b/src/lib/apis/openai/index.ts index ac770e5b7..d8bdac4f5 100644 --- a/src/lib/apis/openai/index.ts +++ b/src/lib/apis/openai/index.ts @@ -239,7 +239,8 @@ export const generateOpenAIChatCompletion = async ( export const synthesizeOpenAISpeech = async ( token: string = '', speaker: string = 'alloy', - text: string = '' + text: string = '', + model: string = 'tts-1' ) => { let error = null; @@ -250,7 +251,7 @@ export const synthesizeOpenAISpeech = async ( 'Content-Type': 'application/json' }, body: JSON.stringify({ - model: 'tts-1', + model: model, input: text, voice: speaker }) diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 4d87f929f..73c56d31a 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -223,7 +223,8 @@ const res = await synthesizeOpenAISpeech( localStorage.token, $settings?.audio?.speaker, - sentence + sentence, + $settings?.audio?.OpenAIModel ).catch((error) => { toast.error(error); diff --git a/src/lib/components/chat/Settings/Audio.svelte b/src/lib/components/chat/Settings/Audio.svelte index 71fb7957e..a3c453a17 100644 --- a/src/lib/components/chat/Settings/Audio.svelte +++ b/src/lib/components/chat/Settings/Audio.svelte @@ -26,6 +26,8 @@ let voices = []; let speaker = ''; + let models = []; + let OpenAIModel = ''; const getOpenAIVoices = () => { voices = [ @@ -38,6 +40,10 @@ ]; }; + const getOpenAIVoicesModel = () => { + models = [{ name: 'tts-1' }, { name: 'tts-1-hd' }]; + }; + const getWebAPIVoices = () => { const getVoicesLoop = setInterval(async () => { voices = await speechSynthesis.getVoices(); @@ -78,12 +84,16 @@ if (TTSEngine === 'openai') { const res = await updateAudioConfig(localStorage.token, { url: OpenAIUrl, - key: OpenAIKey + key: OpenAIKey, + model: OpenAIModel, + speaker: speaker, }); if (res) { OpenAIUrl = res.OPENAI_API_BASE_URL; OpenAIKey = res.OPENAI_API_KEY; + OpenAIModel = res.OPENAI_API_MODEL; + speaker = res.OPENAI_API_SPEAKER; } } }; @@ -98,9 +108,11 @@ STTEngine = settings?.audio?.STTEngine ?? ''; TTSEngine = settings?.audio?.TTSEngine ?? ''; speaker = settings?.audio?.speaker ?? ''; + OpenAIModel = settings?.audio?.OpenAIModel ?? ''; if (TTSEngine === 'openai') { getOpenAIVoices(); + getOpenAIVoicesModel(); } else { getWebAPIVoices(); } @@ -111,6 +123,8 @@ if (res) { OpenAIUrl = res.OPENAI_API_BASE_URL; OpenAIKey = res.OPENAI_API_KEY; + OpenAIModel = res.OPENAI_API_MODEL; + speaker = res.OPENAI_API_SPEAKER; } } }); @@ -126,7 +140,8 @@ audio: { STTEngine: STTEngine !== '' ? STTEngine : undefined, TTSEngine: TTSEngine !== '' ? TTSEngine : undefined, - speaker: speaker !== '' ? speaker : undefined + speaker: speaker !== '' ? speaker : undefined, + OpenAIModel: OpenAIModel !== '' ? OpenAIModel : undefined } }); dispatch('save'); @@ -215,6 +230,7 @@ if (e.target.value === 'openai') { getOpenAIVoices(); speaker = 'alloy'; + OpenAIModel = 'tts-1'; } else { getWebAPIVoices(); speaker = ''; @@ -307,6 +323,25 @@ +
+
{$i18n.t('Set Model')}
+
+
+ + + + {#each models as OpenAIMode} + +
+
+
{/if} diff --git a/src/lib/i18n/locales/ar-BH/translation.json b/src/lib/i18n/locales/ar-BH/translation.json index f259eb426..6583e82a7 100644 --- a/src/lib/i18n/locales/ar-BH/translation.json +++ b/src/lib/i18n/locales/ar-BH/translation.json @@ -350,6 +350,7 @@ "Set Steps": "ضبط الخطوات", "Set Title Auto-Generation Model": "قم بتعيين نموذج إنشاء العنوان تلقائيًا", "Set Voice": "ضبط الصوت", + "Set Model": "ضبط النموذج", "Settings": "الاعدادات", "Settings saved successfully!": "تم حفظ الاعدادات بنجاح", "Share": "كشاركة", diff --git a/src/lib/i18n/locales/bg-BG/translation.json b/src/lib/i18n/locales/bg-BG/translation.json index 8a1d23874..5fda2e8f4 100644 --- a/src/lib/i18n/locales/bg-BG/translation.json +++ b/src/lib/i18n/locales/bg-BG/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Задай Стъпки", "Set Title Auto-Generation Model": "Задай Модел за Автоматично Генериране на Заглавие", "Set Voice": "Задай Глас", + "Set Model": "Задай Модел", "Settings": "Настройки", "Settings saved successfully!": "Настройките са запазени успешно!", "Share": "", diff --git a/src/lib/i18n/locales/bn-BD/translation.json b/src/lib/i18n/locales/bn-BD/translation.json index d101cbfde..059ad4c8c 100644 --- a/src/lib/i18n/locales/bn-BD/translation.json +++ b/src/lib/i18n/locales/bn-BD/translation.json @@ -350,6 +350,7 @@ "Set Steps": "পরবর্তী ধাপসমূহ", "Set Title Auto-Generation Model": "শিরোনাম অটোজেনারেশন মডেন নির্ধারণ করুন", "Set Voice": "কন্ঠস্বর নির্ধারণ করুন", + "Set Model": "মডেল নির্ধারণ করুন", "Settings": "সেটিংসমূহ", "Settings saved successfully!": "সেটিংগুলো সফলভাবে সংরক্ষিত হয়েছে", "Share": "", diff --git a/src/lib/i18n/locales/ca-ES/translation.json b/src/lib/i18n/locales/ca-ES/translation.json index 614e466a7..4f0835476 100644 --- a/src/lib/i18n/locales/ca-ES/translation.json +++ b/src/lib/i18n/locales/ca-ES/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Estableix Passos", "Set Title Auto-Generation Model": "Estableix Model d'Auto-Generació de Títol", "Set Voice": "Estableix Veu", + "Set Model": "Estableix Model", "Settings": "Configuracions", "Settings saved successfully!": "Configuracions guardades amb èxit!", "Share": "", diff --git a/src/lib/i18n/locales/de-DE/translation.json b/src/lib/i18n/locales/de-DE/translation.json index c2afbde64..7c252bf6b 100644 --- a/src/lib/i18n/locales/de-DE/translation.json +++ b/src/lib/i18n/locales/de-DE/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Schritte festlegen", "Set Title Auto-Generation Model": "Modell für automatische Titelgenerierung festlegen", "Set Voice": "Stimme festlegen", + "Set Model": "Modell festlegen", "Settings": "Einstellungen", "Settings saved successfully!": "Einstellungen erfolgreich gespeichert!", "Share": "Teilen", diff --git a/src/lib/i18n/locales/dg-DG/translation.json b/src/lib/i18n/locales/dg-DG/translation.json index 1737ff6bd..d8e3c6ce8 100644 --- a/src/lib/i18n/locales/dg-DG/translation.json +++ b/src/lib/i18n/locales/dg-DG/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Set Steps so many steps", "Set Title Auto-Generation Model": "Set Title Auto-Generation Model very auto-generate", "Set Voice": "Set Voice so speak", + "Set Model": "Set Model so speak", "Settings": "Settings much settings", "Settings saved successfully!": "Settings saved successfully! Very success!", "Share": "", diff --git a/src/lib/i18n/locales/en-GB/translation.json b/src/lib/i18n/locales/en-GB/translation.json index a753636de..a4d12d9d8 100644 --- a/src/lib/i18n/locales/en-GB/translation.json +++ b/src/lib/i18n/locales/en-GB/translation.json @@ -350,6 +350,7 @@ "Set Steps": "", "Set Title Auto-Generation Model": "", "Set Voice": "", + "Set Model": "", "Settings": "", "Settings saved successfully!": "", "Share": "", diff --git a/src/lib/i18n/locales/en-US/translation.json b/src/lib/i18n/locales/en-US/translation.json index a753636de..a4d12d9d8 100644 --- a/src/lib/i18n/locales/en-US/translation.json +++ b/src/lib/i18n/locales/en-US/translation.json @@ -350,6 +350,7 @@ "Set Steps": "", "Set Title Auto-Generation Model": "", "Set Voice": "", + "Set Model": "", "Settings": "", "Settings saved successfully!": "", "Share": "", diff --git a/src/lib/i18n/locales/es-ES/translation.json b/src/lib/i18n/locales/es-ES/translation.json index 1c517cf16..ad6fb5948 100644 --- a/src/lib/i18n/locales/es-ES/translation.json +++ b/src/lib/i18n/locales/es-ES/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Establecer Pasos", "Set Title Auto-Generation Model": "Establecer modelo de generación automática de títulos", "Set Voice": "Establecer la voz", + "Set Model": "Establecer el modelo", "Settings": "Configuración", "Settings saved successfully!": "¡Configuración guardada exitosamente!", "Share": "", diff --git a/src/lib/i18n/locales/fa-IR/translation.json b/src/lib/i18n/locales/fa-IR/translation.json index 7986eb3ec..9df98fb37 100644 --- a/src/lib/i18n/locales/fa-IR/translation.json +++ b/src/lib/i18n/locales/fa-IR/translation.json @@ -350,6 +350,7 @@ "Set Steps": "تنظیم گام\u200cها", "Set Title Auto-Generation Model": "تنظیم مدل تولید خودکار عنوان", "Set Voice": "تنظیم صدا", + "Set Model": "تنظیم مدل", "Settings": "تنظیمات", "Settings saved successfully!": "تنظیمات با موفقیت ذخیره شد!", "Share": "", diff --git a/src/lib/i18n/locales/fr-CA/translation.json b/src/lib/i18n/locales/fr-CA/translation.json index fb9a7b2c5..88f0f01b1 100644 --- a/src/lib/i18n/locales/fr-CA/translation.json +++ b/src/lib/i18n/locales/fr-CA/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Définir les étapes", "Set Title Auto-Generation Model": "Définir le modèle de génération automatique de titre", "Set Voice": "Définir la voix", + "Set Model": "Configurer le modèle", "Settings": "Paramètres", "Settings saved successfully!": "Paramètres enregistrés avec succès !", "Share": "", diff --git a/src/lib/i18n/locales/fr-FR/translation.json b/src/lib/i18n/locales/fr-FR/translation.json index 3161136b8..6965cc76d 100644 --- a/src/lib/i18n/locales/fr-FR/translation.json +++ b/src/lib/i18n/locales/fr-FR/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Définir les étapes", "Set Title Auto-Generation Model": "Définir le modèle de génération automatique de titre", "Set Voice": "Définir la voix", + "Set Model": "Définir le modèle", "Settings": "Paramètres", "Settings saved successfully!": "Paramètres enregistrés avec succès !", "Share": "", diff --git a/src/lib/i18n/locales/it-IT/translation.json b/src/lib/i18n/locales/it-IT/translation.json index 524bef3df..ed21ea72a 100644 --- a/src/lib/i18n/locales/it-IT/translation.json +++ b/src/lib/i18n/locales/it-IT/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Imposta passaggi", "Set Title Auto-Generation Model": "Imposta modello di generazione automatica del titolo", "Set Voice": "Imposta voce", + "Set Model": "Imposta modello", "Settings": "Impostazioni", "Settings saved successfully!": "Impostazioni salvate con successo!", "Share": "", diff --git a/src/lib/i18n/locales/ja-JP/translation.json b/src/lib/i18n/locales/ja-JP/translation.json index eee01ac3c..4006dd11c 100644 --- a/src/lib/i18n/locales/ja-JP/translation.json +++ b/src/lib/i18n/locales/ja-JP/translation.json @@ -350,6 +350,7 @@ "Set Steps": "ステップを設定", "Set Title Auto-Generation Model": "タイトル自動生成モデルを設定", "Set Voice": "音声を設定", + "Set Model": "モデルを設定", "Settings": "設定", "Settings saved successfully!": "設定が正常に保存されました!", "Share": "", diff --git a/src/lib/i18n/locales/ka-GE/translation.json b/src/lib/i18n/locales/ka-GE/translation.json index e76c31120..99ed2110d 100644 --- a/src/lib/i18n/locales/ka-GE/translation.json +++ b/src/lib/i18n/locales/ka-GE/translation.json @@ -350,6 +350,7 @@ "Set Steps": "ნაბიჯების დაყენება", "Set Title Auto-Generation Model": "სათაურის ავტომატური გენერაციის მოდელის დაყენება", "Set Voice": "ხმის დაყენება", + "Set Model": "მოდელის დაყენება", "Settings": "ხელსაწყოები", "Settings saved successfully!": "პარამეტრები წარმატებით განახლდა!", "Share": "", diff --git a/src/lib/i18n/locales/ko-KR/translation.json b/src/lib/i18n/locales/ko-KR/translation.json index 7ad3d6d1d..941e80d0b 100644 --- a/src/lib/i18n/locales/ko-KR/translation.json +++ b/src/lib/i18n/locales/ko-KR/translation.json @@ -350,6 +350,7 @@ "Set Steps": "단계 설정", "Set Title Auto-Generation Model": "제목 자동 생성 모델 설정", "Set Voice": "음성 설정", + "Set Model": "모델 설정", "Settings": "설정", "Settings saved successfully!": "설정이 성공적으로 저장되었습니다!", "Share": "", diff --git a/src/lib/i18n/locales/nl-NL/translation.json b/src/lib/i18n/locales/nl-NL/translation.json index 5a0236453..689b9154e 100644 --- a/src/lib/i18n/locales/nl-NL/translation.json +++ b/src/lib/i18n/locales/nl-NL/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Stel Stappen in", "Set Title Auto-Generation Model": "Stel Titel Auto-Generatie Model in", "Set Voice": "Stel Stem in", + "Set Model": "Stel die model op", "Settings": "Instellingen", "Settings saved successfully!": "Instellingen succesvol opgeslagen!", "Share": "", diff --git a/src/lib/i18n/locales/pl-PL/translation.json b/src/lib/i18n/locales/pl-PL/translation.json index c212b1520..9f306f8de 100644 --- a/src/lib/i18n/locales/pl-PL/translation.json +++ b/src/lib/i18n/locales/pl-PL/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Ustaw kroki", "Set Title Auto-Generation Model": "Ustaw model automatycznego generowania tytułów", "Set Voice": "Ustaw głos", + "Set Model": "Ustaw model", "Settings": "Ustawienia", "Settings saved successfully!": "Ustawienia zapisane pomyślnie!", "Share": "", diff --git a/src/lib/i18n/locales/pt-BR/translation.json b/src/lib/i18n/locales/pt-BR/translation.json index c1c5cce65..77e4dd393 100644 --- a/src/lib/i18n/locales/pt-BR/translation.json +++ b/src/lib/i18n/locales/pt-BR/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Definir Etapas", "Set Title Auto-Generation Model": "Definir Modelo de Geração Automática de Título", "Set Voice": "Definir Voz", + "Set Model": "Definir Modelo", "Settings": "Configurações", "Settings saved successfully!": "Configurações salvas com sucesso!", "Share": "", diff --git a/src/lib/i18n/locales/pt-PT/translation.json b/src/lib/i18n/locales/pt-PT/translation.json index 7a18ebd27..834d27e47 100644 --- a/src/lib/i18n/locales/pt-PT/translation.json +++ b/src/lib/i18n/locales/pt-PT/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Definir Etapas", "Set Title Auto-Generation Model": "Definir Modelo de Geração Automática de Título", "Set Voice": "Definir Voz", + "Set Model": "Definir Modelo", "Settings": "Configurações", "Settings saved successfully!": "Configurações salvas com sucesso!", "Share": "", diff --git a/src/lib/i18n/locales/ru-RU/translation.json b/src/lib/i18n/locales/ru-RU/translation.json index 724fc2d1e..98705a695 100644 --- a/src/lib/i18n/locales/ru-RU/translation.json +++ b/src/lib/i18n/locales/ru-RU/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Установить шаги", "Set Title Auto-Generation Model": "Установить модель автогенерации заголовков", "Set Voice": "Установить голос", + "Set Model": "Установить модель", "Settings": "Настройки", "Settings saved successfully!": "Настройки успешно сохранены!", "Share": "", diff --git a/src/lib/i18n/locales/sv-SE/translation.json b/src/lib/i18n/locales/sv-SE/translation.json index c302b9068..17dd0a030 100644 --- a/src/lib/i18n/locales/sv-SE/translation.json +++ b/src/lib/i18n/locales/sv-SE/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Ange steg", "Set Title Auto-Generation Model": "Ange modell för automatisk generering av titel", "Set Voice": "Ange röst", + "Set Model": "Ställ in modell", "Settings": "Inställningar", "Settings saved successfully!": "Inställningar sparades framgångsrikt!", "Share": "", diff --git a/src/lib/i18n/locales/tr-TR/translation.json b/src/lib/i18n/locales/tr-TR/translation.json index 04fed4072..9de595f17 100644 --- a/src/lib/i18n/locales/tr-TR/translation.json +++ b/src/lib/i18n/locales/tr-TR/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Adımları Ayarla", "Set Title Auto-Generation Model": "Otomatik Başlık Oluşturma Modelini Ayarla", "Set Voice": "Ses Ayarla", + "Set Model": "Model Ayarla", "Settings": "Ayarlar", "Settings saved successfully!": "Ayarlar başarıyla kaydedildi!", "Share": "Paylaş", diff --git a/src/lib/i18n/locales/uk-UA/translation.json b/src/lib/i18n/locales/uk-UA/translation.json index 1dde07072..637614d8c 100644 --- a/src/lib/i18n/locales/uk-UA/translation.json +++ b/src/lib/i18n/locales/uk-UA/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Встановити кроки", "Set Title Auto-Generation Model": "Встановити модель автогенерації заголовків", "Set Voice": "Встановити голос", + "Set Model": "Встановити модель", "Settings": "Налаштування", "Settings saved successfully!": "Налаштування успішно збережено!", "Share": "", diff --git a/src/lib/i18n/locales/vi-VN/translation.json b/src/lib/i18n/locales/vi-VN/translation.json index d8a7ccf96..7096f65c9 100644 --- a/src/lib/i18n/locales/vi-VN/translation.json +++ b/src/lib/i18n/locales/vi-VN/translation.json @@ -350,6 +350,7 @@ "Set Steps": "Đặt Số Bước", "Set Title Auto-Generation Model": "Đặt tiêu đề tự động", "Set Voice": "Đặt Giọng nói", + "Set Model": "Thiết lập mô hình", "Settings": "Cài đặt", "Settings saved successfully!": "Cài đặt đã được lưu thành công!", "Share": "", diff --git a/src/lib/i18n/locales/zh-CN/translation.json b/src/lib/i18n/locales/zh-CN/translation.json index fe7ec77ff..6c9492ee4 100644 --- a/src/lib/i18n/locales/zh-CN/translation.json +++ b/src/lib/i18n/locales/zh-CN/translation.json @@ -350,6 +350,7 @@ "Set Steps": "设置步骤", "Set Title Auto-Generation Model": "设置标题自动生成模型", "Set Voice": "设置声音", + "Set Model": "设置模型", "Settings": "设置", "Settings saved successfully!": "设置已保存", "Share": "", diff --git a/src/lib/i18n/locales/zh-TW/translation.json b/src/lib/i18n/locales/zh-TW/translation.json index 3edde3b95..d71ddd8c0 100644 --- a/src/lib/i18n/locales/zh-TW/translation.json +++ b/src/lib/i18n/locales/zh-TW/translation.json @@ -350,6 +350,7 @@ "Set Steps": "設定步數", "Set Title Auto-Generation Model": "設定自動生成標題用模型", "Set Voice": "設定語音", + "Set Model": "設定模型", "Settings": "設定", "Settings saved successfully!": "成功儲存設定", "Share": "", diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 967cfdad5..32c738ae3 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -102,6 +102,7 @@ type AudioSettings = { STTEngine?: string; TTSEngine?: string; speaker?: string; + OpenAIModel?: string; }; type TitleSettings = { From 5f7188b4804d713161cf772a20ecfb459040392e Mon Sep 17 00:00:00 2001 From: Yanyutin753 <132346501+Yanyutin753@users.noreply.github.com> Date: Mon, 6 May 2024 15:33:29 +0800 Subject: [PATCH 2/3] fix python test --- backend/apps/audio/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/apps/audio/main.py b/backend/apps/audio/main.py index 46ba788a8..be605388c 100644 --- a/backend/apps/audio/main.py +++ b/backend/apps/audio/main.py @@ -44,7 +44,7 @@ from config import ( AUDIO_OPENAI_API_BASE_URL, AUDIO_OPENAI_API_KEY, AUDIO_OPENAI_API_MODEL, - AUDIO_OPENAI_API_SPEAKER + AUDIO_OPENAI_API_SPEAKER, ) log = logging.getLogger(__name__) @@ -86,7 +86,7 @@ async def get_openai_config(user=Depends(get_admin_user)): "OPENAI_API_BASE_URL": app.state.OPENAI_API_BASE_URL, "OPENAI_API_KEY": app.state.OPENAI_API_KEY, "OPENAI_API_MODEL": app.state.OPENAI_API_MODEL, - "OPENAI_API_SPEAKER": app.state.OPENAI_API_SPEAKER + "OPENAI_API_SPEAKER": app.state.OPENAI_API_SPEAKER, } From 5d6517c537338723d360461768c61010c836de72 Mon Sep 17 00:00:00 2001 From: Yanyutin753 <132346501+Yanyutin753@users.noreply.github.com> Date: Tue, 7 May 2024 08:28:34 +0800 Subject: [PATCH 3/3] update the name --- backend/apps/audio/main.py | 10 +++---- backend/config.py | 2 +- src/lib/apis/audio/index.ts | 4 +-- .../chat/Messages/ResponseMessage.svelte | 2 +- src/lib/components/chat/Settings/Audio.svelte | 26 +++++++++---------- src/lib/stores/index.ts | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/backend/apps/audio/main.py b/backend/apps/audio/main.py index be605388c..87732d7bc 100644 --- a/backend/apps/audio/main.py +++ b/backend/apps/audio/main.py @@ -44,7 +44,7 @@ from config import ( AUDIO_OPENAI_API_BASE_URL, AUDIO_OPENAI_API_KEY, AUDIO_OPENAI_API_MODEL, - AUDIO_OPENAI_API_SPEAKER, + AUDIO_OPENAI_API_VOICE, ) log = logging.getLogger(__name__) @@ -63,7 +63,7 @@ app.add_middleware( app.state.OPENAI_API_BASE_URL = AUDIO_OPENAI_API_BASE_URL app.state.OPENAI_API_KEY = AUDIO_OPENAI_API_KEY app.state.OPENAI_API_MODEL = AUDIO_OPENAI_API_MODEL -app.state.OPENAI_API_SPEAKER = AUDIO_OPENAI_API_SPEAKER +app.state.OPENAI_API_VOICE = AUDIO_OPENAI_API_VOICE # setting device type for whisper model whisper_device_type = DEVICE_TYPE if DEVICE_TYPE and DEVICE_TYPE == "cuda" else "cpu" @@ -86,7 +86,7 @@ async def get_openai_config(user=Depends(get_admin_user)): "OPENAI_API_BASE_URL": app.state.OPENAI_API_BASE_URL, "OPENAI_API_KEY": app.state.OPENAI_API_KEY, "OPENAI_API_MODEL": app.state.OPENAI_API_MODEL, - "OPENAI_API_SPEAKER": app.state.OPENAI_API_SPEAKER, + "OPENAI_API_VOICE": app.state.OPENAI_API_VOICE, } @@ -100,14 +100,14 @@ async def update_openai_config( app.state.OPENAI_API_BASE_URL = form_data.url app.state.OPENAI_API_KEY = form_data.key app.state.OPENAI_API_MODEL = form_data.model - app.state.OPENAI_API_SPEAKER = form_data.speaker + app.state.OPENAI_API_VOICE = form_data.speaker return { "status": True, "OPENAI_API_BASE_URL": app.state.OPENAI_API_BASE_URL, "OPENAI_API_KEY": app.state.OPENAI_API_KEY, "OPENAI_API_MODEL": app.state.OPENAI_API_MODEL, - "OPENAI_API_SPEAKER": app.state.OPENAI_API_SPEAKER, + "OPENAI_API_VOICE": app.state.OPENAI_API_VOICE, } diff --git a/backend/config.py b/backend/config.py index 02352a092..a6dc83ffa 100644 --- a/backend/config.py +++ b/backend/config.py @@ -575,7 +575,7 @@ IMAGE_GENERATION_MODEL = os.getenv("IMAGE_GENERATION_MODEL", "") AUDIO_OPENAI_API_BASE_URL = os.getenv("AUDIO_OPENAI_API_BASE_URL", OPENAI_API_BASE_URL) AUDIO_OPENAI_API_KEY = os.getenv("AUDIO_OPENAI_API_KEY", OPENAI_API_KEY) AUDIO_OPENAI_API_MODEL = os.getenv("AUDIO_OPENAI_API_MODEL", "tts-1") -AUDIO_OPENAI_API_SPEAKER = os.getenv("AUDIO_OPENAI_API_SPEAKER", "alloy") +AUDIO_OPENAI_API_VOICE = os.getenv("AUDIO_OPENAI_API_VOICE", "alloy") #################################### # LiteLLM diff --git a/src/lib/apis/audio/index.ts b/src/lib/apis/audio/index.ts index 3b716d58e..7bd8981fe 100644 --- a/src/lib/apis/audio/index.ts +++ b/src/lib/apis/audio/index.ts @@ -98,7 +98,7 @@ export const synthesizeOpenAISpeech = async ( token: string = '', speaker: string = 'alloy', text: string = '', - OpenAIModel: string = 'tts-1' + model: string = 'tts-1' ) => { let error = null; @@ -109,7 +109,7 @@ export const synthesizeOpenAISpeech = async ( 'Content-Type': 'application/json' }, body: JSON.stringify({ - model: OpenAIModel, + model: model, input: text, voice: speaker }) diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 73c56d31a..67b6e3a34 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -224,7 +224,7 @@ localStorage.token, $settings?.audio?.speaker, sentence, - $settings?.audio?.OpenAIModel + $settings?.audio?.model ).catch((error) => { toast.error(error); diff --git a/src/lib/components/chat/Settings/Audio.svelte b/src/lib/components/chat/Settings/Audio.svelte index a3c453a17..a7b8ec11a 100644 --- a/src/lib/components/chat/Settings/Audio.svelte +++ b/src/lib/components/chat/Settings/Audio.svelte @@ -27,7 +27,7 @@ let voices = []; let speaker = ''; let models = []; - let OpenAIModel = ''; + let model = ''; const getOpenAIVoices = () => { voices = [ @@ -85,15 +85,15 @@ const res = await updateAudioConfig(localStorage.token, { url: OpenAIUrl, key: OpenAIKey, - model: OpenAIModel, - speaker: speaker, + model: model, + speaker: speaker }); if (res) { OpenAIUrl = res.OPENAI_API_BASE_URL; OpenAIKey = res.OPENAI_API_KEY; - OpenAIModel = res.OPENAI_API_MODEL; - speaker = res.OPENAI_API_SPEAKER; + model = res.OPENAI_API_MODEL; + speaker = res.OPENAI_API_VOICE; } } }; @@ -108,7 +108,7 @@ STTEngine = settings?.audio?.STTEngine ?? ''; TTSEngine = settings?.audio?.TTSEngine ?? ''; speaker = settings?.audio?.speaker ?? ''; - OpenAIModel = settings?.audio?.OpenAIModel ?? ''; + model = settings?.audio?.model ?? ''; if (TTSEngine === 'openai') { getOpenAIVoices(); @@ -123,8 +123,8 @@ if (res) { OpenAIUrl = res.OPENAI_API_BASE_URL; OpenAIKey = res.OPENAI_API_KEY; - OpenAIModel = res.OPENAI_API_MODEL; - speaker = res.OPENAI_API_SPEAKER; + model = res.OPENAI_API_MODEL; + speaker = res.OPENAI_API_VOICE; } } }); @@ -141,7 +141,7 @@ STTEngine: STTEngine !== '' ? STTEngine : undefined, TTSEngine: TTSEngine !== '' ? TTSEngine : undefined, speaker: speaker !== '' ? speaker : undefined, - OpenAIModel: OpenAIModel !== '' ? OpenAIModel : undefined + model: model !== '' ? model : undefined } }); dispatch('save'); @@ -230,7 +230,7 @@ if (e.target.value === 'openai') { getOpenAIVoices(); speaker = 'alloy'; - OpenAIModel = 'tts-1'; + model = 'tts-1'; } else { getWebAPIVoices(); speaker = ''; @@ -330,13 +330,13 @@ - {#each models as OpenAIMode} - diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 32c738ae3..c4ccb5eec 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -102,7 +102,7 @@ type AudioSettings = { STTEngine?: string; TTSEngine?: string; speaker?: string; - OpenAIModel?: string; + model?: string; }; type TitleSettings = {