fix: selected local tts voice not shown in settings

This commit is contained in:
Jun Siang Cheah 2024-06-03 19:11:37 +01:00
parent de03bf834e
commit 8f03daeaf6

View File

@ -14,6 +14,7 @@
let OpenAIUrl = ''; let OpenAIUrl = '';
let OpenAIKey = ''; let OpenAIKey = '';
let OpenAISpeaker = '';
let STTEngines = ['', 'openai']; let STTEngines = ['', 'openai'];
let STTEngine = ''; let STTEngine = '';
@ -88,14 +89,14 @@
url: OpenAIUrl, url: OpenAIUrl,
key: OpenAIKey, key: OpenAIKey,
model: model, model: model,
speaker: speaker speaker: OpenAISpeaker
}); });
if (res) { if (res) {
OpenAIUrl = res.OPENAI_API_BASE_URL; OpenAIUrl = res.OPENAI_API_BASE_URL;
OpenAIKey = res.OPENAI_API_KEY; OpenAIKey = res.OPENAI_API_KEY;
model = res.OPENAI_API_MODEL; 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; OpenAIUrl = res.OPENAI_API_BASE_URL;
OpenAIKey = res.OPENAI_API_KEY; OpenAIKey = res.OPENAI_API_KEY;
model = res.OPENAI_API_MODEL; 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: { audio: {
STTEngine: STTEngine !== '' ? STTEngine : undefined, STTEngine: STTEngine !== '' ? STTEngine : undefined,
TTSEngine: TTSEngine !== '' ? TTSEngine : undefined, TTSEngine: TTSEngine !== '' ? TTSEngine : undefined,
speaker: speaker !== '' ? speaker : undefined, speaker:
(TTSEngine === 'openai' ? OpenAISpeaker : speaker) !== ''
? TTSEngine === 'openai'
? OpenAISpeaker
: speaker
: undefined,
model: model !== '' ? model : undefined, model: model !== '' ? model : undefined,
nonLocalVoices: nonLocalVoices nonLocalVoices: nonLocalVoices
} }
@ -231,7 +240,7 @@
on:change={(e) => { on:change={(e) => {
if (e.target.value === 'openai') { if (e.target.value === 'openai') {
getOpenAIVoices(); getOpenAIVoices();
speaker = 'alloy'; OpenAISpeaker = 'alloy';
model = 'tts-1'; model = 'tts-1';
} else { } else {
getWebAPIVoices(); getWebAPIVoices();
@ -324,7 +333,7 @@
<input <input
list="voice-list" list="voice-list"
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none" class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
bind:value={speaker} bind:value={OpenAISpeaker}
placeholder="Select a voice" placeholder="Select a voice"
/> />