Snap icon indicating copy to clipboard operation
Snap copied to clipboard

Add a working tts library for Chrome OS

Open TipsyTheCat opened this issue 3 years ago • 8 comments

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.

TipsyTheCat avatar Mar 07 '22 13:03 TipsyTheCat

Umm, can you tell us what this is about, in particular how it's different from the existing "text to speech" library?

jmoenig avatar Mar 07 '22 14:03 jmoenig

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);

TipsyTheCat avatar Mar 07 '22 14:03 TipsyTheCat

Hmm... I've just tried the existing library in Chrome 99 and it works just fine...

jmoenig avatar Mar 07 '22 14:03 jmoenig

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: @.***>

TipsyTheCat avatar Mar 07 '22 15:03 TipsyTheCat

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()?

jmoenig avatar Mar 07 '22 15:03 jmoenig

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()

TipsyTheCat avatar Mar 10 '22 12:03 TipsyTheCat

Also, pardon my unclearness...

TipsyTheCat avatar Mar 10 '22 12:03 TipsyTheCat

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...

TipsyTheCat avatar Apr 26 '22 16:04 TipsyTheCat