我正在使用 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);