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:
1 parent
c754477f07
commit
5d760c0bf6
5 files changed
+193
-47
No files matched your search
+2
-2
@@ -6,7 +6,7 @@ import Quiz from "@/components/Quiz";
|
||||
import ResultCard from "@/components/ResultCard";
|
||||
import Ar from "@/components/Ar";
|
||||
import { recordResult, useProgress } from "@/lib/progress";
|
||||
import { hasGermanVoice, speakSequence, stopSpeaking, TTS_MISSING_EVENT, ttsSupported } from "@/lib/speech";
|
||||
import { germanVoiceMissing, speakSequence, stopSpeaking, TTS_MISSING_EVENT, ttsSupported } from "@/lib/speech";
|
||||
|
||||
export default function HoerenPage() {
|
||||
const [teil, setTeil] = useState<number>(1);
|
||||
@@ -92,7 +92,7 @@ function Player({ item, onBack }: { item: HoerItem; onBack: () => void }) {
|
||||
return;
|
||||
}
|
||||
if (exam && plays >= maxPlays) return;
|
||||
if (!hasGermanVoice()) {
|
||||
if (germanVoiceMissing()) {
|
||||
window.dispatchEvent(new Event(TTS_MISSING_EVENT));
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user