Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a working tts library for Chrome OS #2999

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

TipsyTheCat
Copy link

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.

Added tts
Added tts block xml
@jmoenig
Copy link
Owner

jmoenig commented Mar 7, 2022

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

@TipsyTheCat
Copy link
Author

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

@jmoenig
Copy link
Owner

jmoenig commented Mar 7, 2022

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

@TipsyTheCat
Copy link
Author

TipsyTheCat commented Mar 7, 2022 via email

@jmoenig
Copy link
Owner

jmoenig commented Mar 7, 2022

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

@TipsyTheCat TipsyTheCat changed the title Add a working tts library (on chrome browsers) Add a working tts library for Chrome OS Mar 10, 2022
@TipsyTheCat
Copy link
Author

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
Copy link
Author

Also, pardon my unclearness...

Gee, I make lots of typos -w-
In an attempt to fix my typo, a made ANOTHER typo: fixed (i think)
@TipsyTheCat
Copy link
Author

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 TipsyTheCat marked this pull request as draft April 26, 2022 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants