SpeechSynthesis.speak (in Web Speech API) always stops after a few seconds in Google Chrome
Asked Answered
A

1

30

When using the speak function in the Web Speech API, in Chrome the speaking stops abruptly after a few seconds, in the middle of the text given to it, in a seemingly random place (without reaching the end). This only happens in Chrome (works well on Firefox), tested on two different computers/systems.

Have a look at this jsfiddle to see/listen: https://jsfiddle.net/fv9ochpq/

You can see that the SpeechSynthesis object .speaking flag stays on(true) after it stops speaking.

I haven't seen any documented limit to the text passed to the utterance. Is this a Google Chrome bug? BTW, I've known about this since 2014 - when I was trying to add a speech feature to a browser extension I made (back then it was the TTS API available to chrome extensions - same thing happened there as well), but eventually didn't do it because of this apparent bug. Now I want to overcome this - if this is a bug, I will appreciate anyone directing me to the best place to report it.

EDIT: It seem to stop after about 15 seconds. Adding an interval every 14 seconds running .resume() seem to "fix" this. See: https://jsfiddle.net/fv9ochpq/1/
But this is a hack.

AUGUST 2019 UPDATE Since December 2018 - Chrome does not allow triggering speech without user interaction, this is an updated jsfiddle, with an added button, and the actual speak call moved to its onclick: https://jsfiddle.net/vcmxkwd3/

THE BUG IS STILL HAPPENING! :

Anisaanise answered 18/3, 2017 at 14:40 Comment(5)
Hi, here I found a workaround, and works for me. #57667857Legra
@Márcio - you mean the workaround specified in my EDIT part in the question? :) I can't believe it's been more than 3 years and they still haven't fixed this?Anisaanise
I have the most current version of Chrome (jun 2020), and it still remains with only 15 seconds. Sorry, I not see the link EDIT,Legra
Seems to still break after 15 seconds, also tested this in my own project and getting the same result.Buttaro
Still happening in Chrome in 2024...Mireyamiriam
K
3

You asked where to report this problem. For programmers, I think this forum is the best place. In fact considerable discussion has occurred at Chrome Speech Synthesis with longer texts. But I believe much of it mistakenly focuses on the number of words allowed by SpeechSynthesis rather than on duration has you do here. In fact, your solution seems to me the most practical of all.

Google has a bug reporting facility, and the issue has been reported as speechSynthesis fails for long text without warning and blocks the API. It currently has a total of 3 reports, which give it 3 "stars." We may be able to bring attention to the issue by adding reports to this Chromium Bug (I have added one).

Current status of this Bug is "Untriaged;" also of interest are several other reported issues related to Chrome SpeechSynthesis.

Kitts answered 18/1, 2018 at 14:13 Comment(3)
I just went to my first link, with Chrome 63.0.3239.132, and surprisingly it read it all loud to the end. So they might of actually fixed this! on latest Chrome versions.Anisaanise
@YuvalA, your first fiddle is in English. Is that language installed locally on your computer? If so, please test the fiddle with a language that isn't installed (under Windows, I think that means any language other than the one you use Windows with). You will need to add code to the fiddle to select the foreign language, e.g., synth.cancel(); u.lang = 'fr'; synth.speak(u);. I find the speech still cuts out under the release of Chrome you're using, with the above code mods.Kitts
you're right. Just tested it with French and french text - it stops in the middle after a few seconds :( .Anisaanise

© 2022 - 2024 — McMap. All rights reserved.