【问题标题】:SpeechSynthesis stops working after first utterance in FireFox, but works in ChromeSpeechSynthesis 在 FireFox 中第一次发声后停止工作,但在 Chrome 中工作
【发布时间】:2017-11-13 22:35:35
【问题描述】:

问题很简单,见JSfiddle

SpeechSynthesis 在 Chrome 中运行良好,但在 FireFox 中第一次发声后神秘地停止了。 (在 Safari 中也适用于我。)欢迎提出任何想法,因为我没有太多可参考的内容。

代码:

var u = new SpeechSynthesisUtterance();
var synth = window.speechSynthesis;
u.text = "hello";
synth.speak(u);
synth.speak(u);
synth.speak(u);

【问题讨论】:

    标签: javascript google-chrome firefox text-to-speech speech-synthesis


    【解决方案1】:

    这实际上是一个known bug in Firefox

    The specs drafts 仍然不太清楚话语的可重用性,但你可以在 w3c 的 github 上看到 this issue,他们同意它应该是这样的事实。

    目前,一种解决方法是每次都创建一个新的话语...

    var synth = window.speechSynthesis;
    
    synth.speak(new SpeechSynthesisUtterance('hello'));
    synth.speak(new SpeechSynthesisUtterance('hello'));
    synth.speak(new SpeechSynthesisUtterance('hello'));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-18
      • 2017-05-10
      • 2021-08-12
      • 2016-07-19
      • 2017-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多