Add a working tts library for Chrome OS
Simple JS tts api implementation that actually works on chrome browsers.
Done by using the built-in tts api and adding window.speechSynthesis.cancel() before speaking the message, which fixes tts not working.
Umm, can you tell us what this is about, in particular how it's different from the existing "text to speech" library?
Ever since this, most (if not all) chrome users have been unable to invoke JavaScripts tts api using
var msg = new SpeechSynthesisUtterance();
msg.text = "Hello world";
window.speechSynthesis.speak(msg);
But, by canceling using window.speechSynthesis.cancel() allows speech to properly start.
example:
var msg = new SpeechSynthesisUtterance();
msg.text = "Hello world";
window.speechSynthesis.cancel()
window.speechSynthesis.speak(msg);
Hmm... I've just tried the existing library in Chrome 99 and it works just fine...
On chrome os?
On Mon, Mar 7, 2022, 09:20 Jens Mönig @.***> wrote:
Hmm... I've just tried the existing library in Chrome 99 and it works just fine...
— Reply to this email directly, view it on GitHub https://github.com/jmoenig/Snap/pull/2999#issuecomment-1060737978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXLNCV6OKUG5VI5PY4LFXB3U6YGEJANCNFSM5QDL4TKQ . You are receiving this because you authored the thread.Message ID: @.***>
no, in Chrome on a Mac and also in Windows.
Okay, I've read up on what you pointed out, and it seems that some user interaction with a page is required before tts will work. But that's literally the case when you click the green flag button to start a project, isn't it? I don't see how calling cancel() would circumvent the autoplay deprecation. Can you tell me more about this? How did you get the idea to call cancel()?
Personally, I have not idea why it doesn't work or why doing this does work... This is a screen recording of using tts with and without cancel()
Also, pardon my unclearness...
Ok, so I noticed that on first run of the block it doesn't speak. I'm going to convert this PR into a draft to figure out how to fix this...