SpeechSynthesis API在 Firefox 上不会说普通话。不支持吗?我在文档中找不到列表。我尝试了几种不同的语言 tags .
Fiddle :
var msg = new SpeechSynthesisUtterance();
msg.text = '你好';
msg.lang = 'zh';
window.speechSynthesis.speak(msg);
(如果它有效,您应该听到“nihao”。在 Chrome 上听起来很好,在 Safari 上听起来OK。在 Ubuntu 上的 Firefox 53.0.2 上,我听到“letter字母”。)
最佳答案
在 Windows 上,Firefox 只有 3 种语音,都是英文。
我写了一个显示浏览器声音的jsbin:
https://jsbin.com/ginanegoqu/edit?js,output
if ('speechSynthesis' in window) {
// Start an html table for languages details
var text = '<table border=1><tr><th>Default<th>Language<th>Local<th>Name<th>URI</tr>';
// Get voices; add to table markup
function loadVoices() {
var voices = speechSynthesis.getVoices();
voices.forEach(function(voice, i) {
// Add all details to table
text += '<tr><td>' + voice.default + '<td>'
+ voice.lang + '<td>' + voice.localService
+ '<td>' + voice.name + '<td>' + voice.voiceURI;
});
}
loadVoices();
langList.innerHTML = text;
// Chrome loads voices asynchronously.
window.speechSynthesis.onvoiceschanged = function(e) {
loadVoices();
langList.innerHTML = text;
}
}
关于javascript - 中文 SpeechSynthesis API -- Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43983845/