From 6dbd9c3ef4ee4925bd474c7caafaf8d8a856b0cb Mon Sep 17 00:00:00 2001 From: itsrubberduck Date: Sun, 19 Jul 2026 19:42:35 +0200 Subject: [PATCH] fix(classroom): force English (US) voice for browser TTS default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When no fixed instructor voice is chosen ("Standard · Ryan US"), the Web Speech path set no voice and fell back to the OS default (German on a German system). Now prefers an en-US (then en) voice, matching the online instructor default. Co-Authored-By: Claude Opus 4.8 --- app/pages/classroom.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/pages/classroom.vue b/app/pages/classroom.vue index 2193b41..b876067 100644 --- a/app/pages/classroom.vue +++ b/app/pages/classroom.vue @@ -5025,10 +5025,24 @@ async function say(text: string) { const synth = window.speechSynthesis const utterance = new SpeechSynthesisUtterance(speakText) utterance.rate = normalizedRate + const voices = synth.getVoices() if (cfg.value.voice) { const voiceName = cfg.value.voice.toLowerCase() - const voice = synth.getVoices().find(item => item.name.toLowerCase().includes(voiceName)) + const voice = voices.find(item => item.name.toLowerCase().includes(voiceName)) if (voice) utterance.voice = voice + } else { + // No fixed voice picked ("Standard · Ryan US"). The default OS voice is + // locale-dependent (German on a German machine), so force an English — + // ideally US — voice to match the online instructor default. + const enVoice = + voices.find(item => /^en[-_]us/i.test(item.lang)) || + voices.find(item => /^en/i.test(item.lang)) + if (enVoice) { + utterance.voice = enVoice + utterance.lang = enVoice.lang + } else { + utterance.lang = 'en-US' + } } utterance.onend = () => { isSpeaking.value = false