Honor the system default speech voice
Build and publish frontend / publish (push) Successful in 43s

This commit is contained in:
Ein Anderssono
2026-10-16 06:31:07 +02:00
parent db76289660
commit bf5ee88610
2 changed files with 12 additions and 5 deletions
+8 -3
View File
@@ -233,9 +233,14 @@
utterance.pitch = isNarrator ? 1 : Math.min(2, Math.max(0, Number(voiceOptions.pitch ?? profile.pitch ?? identityProfile.pitch) || 1));
const requestedName = voiceOptions.voiceName || profile.voiceName || settings.voiceName;
const voices = availableVoices();
utterance.voice = voices.find(voice => voice.name === requestedName)
|| voices.find(voice => /^sv(-|$)/i.test(voice.lang))
|| null;
// An empty selection means the operating system should choose its
// default voice for the requested language. Forcing the first voice
// returned by WebKit can select a voice that is listed but cannot speak.
utterance.voice = requestedName
? voices.find(voice => voice.name === requestedName)
|| voices.find(voice => /^sv(-|$)/i.test(voice.lang))
|| null
: null;
utterance.onstart = () => {
if (token !== generation) return;
if (speechStartTimer !== null) win.clearTimeout(speechStartTimer);