Javascript 如何将默认的美国男配音更改为英国女配音或其他
Javascript 如何将默认的美国男配音更改为英国女配音或其他,javascript,html,voice-recognition,voice,Javascript,Html,Voice Recognition,Voice,const btn=document.querySelector('.talk'); const content=document.querySelector('.content'); 康斯特问候语=[ “如果你很好,我很乐意使用speechSynthesis 如果要对声音进行硬编码,有一个很好但本质上类似这样的方法: var synth = window.speechSynthesis; // get voices var voices = synth.getVoices(); // wh
const btn=document.querySelector('.talk');
const content=document.querySelector('.content');
康斯特问候语=[
“如果你很好,我很乐意使用speechSynthesis
如果要对声音进行硬编码,有一个很好但本质上类似这样的方法:
var synth = window.speechSynthesis;
// get voices
var voices = synth.getVoices();
// when voices have finished loading
synth.onvoiceschanged = function() {
var sayThis = new SpeechSynthesisUtterance('Hi how are you?');
sayThis.onend = function(event) {
console.log('SpeechSynthesisUtterance.onend');
}
sayThis.onerror = function(event) {
console.error('SpeechSynthesisUtterance.onerror');
}
var selectedVoice = 'Google UK English Female';
for (var i = 0; i < voices.length; i++) {
if (voices[i].name === selectedVoice) {
sayThis.voice = voices[i];
break;
}
}
sayThis.pitch = 1;
sayThis.rate = 1;
synth.speak(sayThis);
}
var synth=window.speechSynthesis;
//听到声音
var voices=synth.getVoices();
//声音加载完毕后
synth.onvoiceschanged=函数(){
var sayThis=新的演讲(你好吗?);
sayThis.onend=函数(事件){
log('SpeechSynthesisUtterance.onend');
}
sayThis.onerror=函数(事件){
console.error('speechsynthesisterance.onerror');
}
var selectedVoice='谷歌英国英语女性';
for(var i=0;i
您是否尝试过SpeechSynthesis语音文档?至于如何加载语音:在我的readOutLoud功能中,我使用了SpeechSynthesis,您能给我一个示例,说明如何将我选择的语音输入到我上面输入的JS中吗?谢谢!下面是另一个示例,