From 8f03daeaf690b3b8cb13ca0e69fcedf47994b84c Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Mon, 3 Jun 2024 19:11:37 +0100 Subject: [PATCH] fix: selected local tts voice not shown in settings --- src/lib/components/chat/Settings/Audio.svelte | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lib/components/chat/Settings/Audio.svelte b/src/lib/components/chat/Settings/Audio.svelte index b0a320d2c..86df4e949 100644 --- a/src/lib/components/chat/Settings/Audio.svelte +++ b/src/lib/components/chat/Settings/Audio.svelte @@ -14,6 +14,7 @@ let OpenAIUrl = ''; let OpenAIKey = ''; + let OpenAISpeaker = ''; let STTEngines = ['', 'openai']; let STTEngine = ''; @@ -88,14 +89,14 @@ url: OpenAIUrl, key: OpenAIKey, model: model, - speaker: speaker + speaker: OpenAISpeaker }); if (res) { OpenAIUrl = res.OPENAI_API_BASE_URL; OpenAIKey = res.OPENAI_API_KEY; model = res.OPENAI_API_MODEL; - speaker = res.OPENAI_API_VOICE; + OpenAISpeaker = res.OPENAI_API_VOICE; } } }; @@ -125,7 +126,10 @@ OpenAIUrl = res.OPENAI_API_BASE_URL; OpenAIKey = res.OPENAI_API_KEY; model = res.OPENAI_API_MODEL; - speaker = res.OPENAI_API_VOICE; + OpenAISpeaker = res.OPENAI_API_VOICE; + if (TTSEngine === 'openai') { + speaker = OpenAISpeaker; + } } } }); @@ -141,7 +145,12 @@ audio: { STTEngine: STTEngine !== '' ? STTEngine : undefined, TTSEngine: TTSEngine !== '' ? TTSEngine : undefined, - speaker: speaker !== '' ? speaker : undefined, + speaker: + (TTSEngine === 'openai' ? OpenAISpeaker : speaker) !== '' + ? TTSEngine === 'openai' + ? OpenAISpeaker + : speaker + : undefined, model: model !== '' ? model : undefined, nonLocalVoices: nonLocalVoices } @@ -231,7 +240,7 @@ on:change={(e) => { if (e.target.value === 'openai') { getOpenAIVoices(); - speaker = 'alloy'; + OpenAISpeaker = 'alloy'; model = 'tts-1'; } else { getWebAPIVoices(); @@ -324,7 +333,7 @@