add save sound

This commit is contained in:
larssand
2026-08-28 13:39:12 +02:00
parent 5f79228941
commit fa3e5ee379
6 changed files with 62 additions and 9 deletions

View File

@@ -340,7 +340,8 @@ export function speakTextHelper(text, { state, currentLanguage }, options = {})
utterance.volume = Math.max(0, Math.min(1, Number(options.volume ?? 1)));
if (typeof options.onEnd === "function") utterance.onend = options.onEnd;
if (typeof options.onError === "function") utterance.onerror = options.onError;
const voice = selectSpeechVoice(synth.getVoices(), String(state.settings.speechVoiceUri || ""), utterance.lang);
const configuredVoiceUri = options.voiceUri !== undefined ? options.voiceUri : state.settings.speechVoiceUri;
const voice = selectSpeechVoice(synth.getVoices(), String(configuredVoiceUri || ""), utterance.lang);
if (voice) utterance.voice = voice;
synth.speak(utterance);
return true;