[英]SpeechSynthesis.speak (in Web Speech API) always stops after a few seconds in Google Chrome
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). 当在Web Speech API中使用
speak
功能时,在Chrome中,语音会在几秒钟之后突然停止,在给定文本的中间,在一个看似随机的地方(没有到达终点)。 This only happens in Chrome (works well on Firefox), tested on two different computers/systems. 这只发生在Chrome(适用于Firefox),在两台不同的计算机/系统上进行测试。
Have a look at this jsfiddle to see/listen: https://jsfiddle.net/fv9ochpq/ 看看这个jsfiddle看/听: https ://jsfiddle.net/fv9ochpq/
You can see that the SpeechSynthesis
object .speaking
flag stays on(true) after it stops speaking. 您可以看到
SpeechSynthesis
对象.speaking
标志在停止说话后保持打开状态(true)。
I haven't seen any documented limit to the text passed to the utterance. 我没有看到传递给话语的文本有任何记录限制。 Is this a Google Chrome bug?
这是Google Chrome错误吗? 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.
顺便说一下,自2014年以来我就已经知道了这一点 - 当时我试图将语音功能添加到我制作的浏览器扩展中(那时它是可用于Chrome扩展的TTS API - 同样的事情也发生在那里),但最终还没有不要因为这个明显的错误而这样做。 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. 编辑 :它似乎在大约15秒后停止。 Adding an interval every 14 seconds running
.resume()
seem to "fix" this. 运行
.resume()
每14秒添加一个间隔似乎“修复”了这个。 See: https://jsfiddle.net/fv9ochpq/1/ 请参阅: 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/ 2019年8月更新自2018年12月以来 - Chrome不允许在没有用户交互的情况下触发语音,这是一个更新的jsfiddle,带有一个添加的按钮,实际的
speak
呼叫转移到它的onclick
: https ://jsfiddle.net/vcmxkwd3/
THE BUG IS STILL HAPPENING! 这个BUG仍在发生! :
:
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 .
实际上,在Chrome语音合成中发生了大量讨论,文本较长 。 But I believe much of it mistakenly focuses on the number of words allowed by SpeechSynthesis rather than on duration has you do here.
但是我相信它的大部分内容都错误地集中在SpeechSynthesis 允许的单词数上 ,而不是你在这里做的持续时间 。 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 . 谷歌有一个错误报告工具,并且已经报告了这个问题,因为在没有警告的情况下 , textSynthesis对于长文本失败并阻止了API 。 It currently has a total of 3 reports, which give it 3 "stars."
它目前总共有3个报告,它给它3个“星星”。 We may be able to bring attention to the issue by adding reports to this Chromium Bug (I have added one).
我们可以通过向此Chromium Bug添加报告来引起注意(我添加了一个)。
Current status of this Bug is "Untriaged;" 这个Bug的当前状态是“Untriaged;” also of interest are several other reported issues related to Chrome SpeechSynthesis .
还有一些与Chrome SpeechSynthesis相关的其他报道问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.