Fix speechSynthesis cancel before speak to unblock audio
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
6dd7e03d21
commit
8fa906b559
1 file changed
+7
-1
+7
-1
@@ -133,7 +133,13 @@ async function ttsDrain() {
|
|||||||
} else {
|
} else {
|
||||||
const u = new SpeechSynthesisUtterance(text);
|
const u = new SpeechSynthesisUtterance(text);
|
||||||
u.rate = 0.85; u.lang = 'en-US';
|
u.rate = 0.85; u.lang = 'en-US';
|
||||||
await new Promise((resolve) => { u.onend = resolve; u.onerror = resolve; speechSynthesis.speak(u); });
|
speechSynthesis.cancel();
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
u.onend = resolve;
|
||||||
|
u.onerror = resolve;
|
||||||
|
// some browsers need a short delay after cancel() before speak() works
|
||||||
|
setTimeout(() => speechSynthesis.speak(u), 50);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
ttsDrain();
|
ttsDrain();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user