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