【问题标题】:SpeechSynthesisUtterance onboundary event not firing properlySpeechSynthesisUtterance onboundary 事件未正确触发
【发布时间】:2018-08-02 05:16:07
【问题描述】:

我正在使用 SpeechSynthesisUtterance onboundary 事件未正确触发。它有时会停在句子的中间。

有人遇到过这种情况吗?请帮忙。

var utterance = new SpeechSynthesisUtterance();
    	utterance.lang = 'en-UK';
    	utterance.rate = 1;
utterance.onboundary = function(event){
    		console.log(event);
  	};

【问题讨论】:

  • Its stoping middle of the sentence sometime”是什么意思?当你的句子中有 x 个单词时,它只会触发 x-n 次?
  • 如果我们有时在句子中有 x 个单词,它不会触发 x 次。我在 post 方法结果中使用它。
  • 你能找到所有这些有时的共同点吗?您是否有一个每次都会重现它的示例?
  • 我正在研究 angular1.6,在应用程序中我每次都能重现。但在应用程序之外,它每次都会触发。
  • 1.没有 en-UK,只有 en-GB,这会有所作为吗? 2. 也许在您的问题中添加 angularjs 标签以获得更多视图?

标签: javascript speech-synthesis


【解决方案1】:

似乎是垃圾收集的问题 (https://bugs.chromium.org/p/chromium/issues/detail?id=509488#c11) 如果您将话语存储在具有全局上下文的变量中,则它可以工作:

window.utterances = [];
var utterance = new SpeechSynthesisUtterance( 'hello' );
utterances.push( utterance );
speechSynthesis.speak( utterance );

【讨论】:

    【解决方案2】:

    这是一个专门针对以下问题的错误:

    • 使用额外的 Chrome 语音集(例如,如果您使用 Google UK Female,而不是臭名昭著的 Microsoft Dave)。

    来源:Bugs.Chromium.org - Issue 521666: speechutterance onboundary event doesn't fire

    正如其中一位开发人员所说...

    Mac OS X、Windows 和 Chrome OS 上的原生语音合成都支持单词级别的边界事件。

    也就是说,如果您使用的是 Chrome 语音合成(非本地),您将在这些替代语言上出现不规则行为。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多