Restore iOS speech after cancelling queued audio
Build and publish frontend / publish (push) Failing after 2s
Build and publish frontend / publish (push) Failing after 2s
This commit is contained in:
@@ -100,6 +100,9 @@
|
||||
// same turn as cancel(). Do not clear an already-empty native queue.
|
||||
if (wasQueued) {
|
||||
try { win.speechSynthesis?.cancel(); } catch (_) { /* Best effort. */ }
|
||||
// cancel() also removes the silent user-gesture primer from the native
|
||||
// queue. A later reply must prime again from the next player gesture.
|
||||
speechPrimed = false;
|
||||
}
|
||||
if (!recognition) setState('IDLE');
|
||||
}
|
||||
@@ -149,6 +152,10 @@
|
||||
return false;
|
||||
}
|
||||
cancelSpeech();
|
||||
// This runs synchronously from the microphone button gesture. If
|
||||
// cancelSpeech() removed the earlier primer, restore it before starting
|
||||
// recognition so a spoken reply can follow the transcript.
|
||||
activateFromUserGesture();
|
||||
const token = ++generation;
|
||||
let instance;
|
||||
try { instance = new Recognition(); }
|
||||
@@ -233,8 +240,10 @@
|
||||
if (token !== generation) return;
|
||||
if (speechStartTimer !== null) win.clearTimeout(speechStartTimer);
|
||||
speechStartTimer = null;
|
||||
setState('SPEAKING', 'Uppläsningen har startat. Om du inte hör ljud, kontrollera iPadens volym och ljudutgång.');
|
||||
if (typeof voiceOptions.onStart === 'function') voiceOptions.onStart();
|
||||
// onstart confirms the browser speech engine accepted the utterance;
|
||||
// it cannot confirm that sound reached the device's speakers.
|
||||
setState('SPEAKING', 'Webbläsaren har startat talsyntesen. Om du inte hör ljud, tryck på Läs senaste repliken.');
|
||||
};
|
||||
utterance.onend = () => {
|
||||
if (token !== generation) return;
|
||||
|
||||
Reference in New Issue
Block a user