Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Web语音API:同时发出两个语音_Javascript_Html_Webspeech Api - Fatal编程技术网

Javascript Web语音API:同时发出两个语音

Javascript Web语音API:同时发出两个语音,javascript,html,webspeech-api,Javascript,Html,Webspeech Api,我正在使用Web Speech API,想知道是否有可能同时运行SpeechSynthesistTerrance()的两个实例,从而使语音彼此重叠 简化我当前的代码,我基本上有两个函数,每个函数定义一个SpeechSynthesisUtterance()的新实例,然后调用它们。然而,由此产生的听写在两个实例之间交替进行,因此,如果语音1说的是“boom,chicka”,而语音2说的是“bow,wow”,那么我听到的是“boom,bow,chicka,wow”,而不是“boom+bow,chick

我正在使用Web Speech API,想知道是否有可能同时运行SpeechSynthesistTerrance()的两个实例,从而使语音彼此重叠

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

窗口的speechSynthesis.speak()上显示

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

所以我想这是一个否定的答案。
(如果你真的想进入这个领域,这里有一条——但它说的是一样的)

同时,我正在使用基于音频文件的外部TTS服务。这些在并行性方面较少受到限制

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);