简体   繁体   English

在Google Chrome中,SpeechSynthesis.speak(在Web Speech API中)会在几秒钟后停止

[英]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呼叫转移到它的onclickhttps ://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.

相关问题 几秒钟后谷歌语音识别 API 停止录音 - Google Speech recognition API stops recording after a few seconds speechSynthesis.speak()可在iPhone上使用,但不能在iPad上使用? - speechSynthesis.speak() works on iPhone but not iPad? 使用speechSynthesis.speak()在javascript中同步执行 - Synchronous execution in javascript with speechSynthesis.speak() speechSynthesis.speak() 没有任何声音 output - speechSynthesis.speak() doesn`t output any sound Web 语音 api 在几秒钟后关闭 - Web speech api closes after some seconds SpeechSynthesis,Web Speech API,去掉说话结束后的延迟和onend属性触发? - SpeechSynthesis, Web Speech API, remove the delay after speaking has finished and the onend property firing? Web Speech API-再说一次(重设句子) - Web Speech API - Speak again (reset sentence) 自 M71 起不再允许没有用户激活的 JavaScript SpeechSynthesis.speak() - JavaScript speechSynthesis.speak() without user activation is no longer allowed since M71 为什么在Firefox中不能多次调用SpeechSynthesis.speak()? - Why can't SpeechSynthesis.speak() be called more than once in Firefox? 在调用speak之前预加载Web Speech API - Preloading Web Speech API before calling speak
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM