Make text-to-speech reliable on Android

Do not treat a not-yet-loaded voice list as missing German voice, poll for voices, wait after cancel before speaking, keep utterances referenced, retry stalled speech, detect missing end events, unlock speech on first tap, and stop the microphone before the examiner speaks.
This commit is contained in:
X4Lo committed 2026-11-06 22:17:32 +00:00
1 parent c754477f07
commit 5d760c0bf6
5 files changed
+193 -47

No files matched your search

+2 -2
View File
@@ -10,7 +10,7 @@ import type { Question } from "@/data/types";
import Quiz from "@/components/Quiz";
import Ar from "@/components/Ar";
import { recordResult } from "@/lib/progress";
import { hasGermanVoice, speakSequence, stopSpeaking, TTS_MISSING_EVENT } from "@/lib/speech";
import { germanVoiceMissing, speakSequence, stopSpeaking, TTS_MISSING_EVENT } from "@/lib/speech";
import { fireConfetti } from "@/components/AppShell";
import { sfx } from "@/lib/sfx";
@@ -266,7 +266,7 @@ function ExamAudio({ item }: { item: HoerItem }) {
className="btn blue"
disabled={playing || plays >= max}
onClick={() => {
if (!hasGermanVoice()) {
if (germanVoiceMissing()) {
window.dispatchEvent(new Event(TTS_MISSING_EVENT));
window.scrollTo({ top: 0, behavior: "smooth" });
return;