【问题标题】:Web Speech API: two utterances at same timeWeb Speech API:同时两个话语
【发布时间】:2015-06-28 16:48:15
【问题描述】:

我正在使用 Web Speech API,想知道是否可以同时运行两个 SpeechSynthesisUtterance() 实例,从而使声音相互叠加。

缩写我当前的代码,我基本上有两个函数,每个函数定义一个 SpeechSynthesisUtterance() 的新实例,然后调用它们。然而,由此产生的听写在两个实例之间交替,如果声音 1 说“boom,chicka”,而声音 2 说“bow,wow”,我听到的是“boom,bow,chicka,wow”而不是“boom +鞠躬,小鸡 + 哇”。

function speak(text) {
// Create a new instance of SpeechSynthesisUtterance.
var msg = new SpeechSynthesisUtterance();
//some code here where I define parameters like volume, pitch which I left out

window.speechSynthesis.speak(msg);
}
function speak2(text2) {
// Create another new instance of SpeechSynthesisUtterance.
var msg2 = new SpeechSynthesisUtterance();
//some code here where I define parameters like volume, pitch which I left out

window.speechSynthesis.speak(msg2);
}

speak(text);
speak2(text2);

【问题讨论】:

    标签: javascript html webspeech-api


    【解决方案1】:

    window.speechSynthesis.speak() 上的 MDN documentation 表示

    SpeechSynthesis 接口的 speak() 方法将一个话语添加到话语队列中;当任何其他话语在它被说出之前排队时,它就会被说出。

    所以我想这是一个不。
    (如果你想真正了解它,这里是W3 spec - 但它说的是同样的事情)

    与此同时,我正在使用基于音频文件的外部 TTS 服务。这些在并行度上的限制较少。

    【讨论】:

      猜你喜欢
      • 2016-10-31
      • 2017-05-13
      • 2015-04-05
      • 2015-12-07
      • 2015-06-11
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 2014-02-26
      相关资源
      最近更新 更多