中文 SpeechSynthesis API -- Firefox
SpeechSynthesis API for Chinese -- Firefox
SpeechSynthesis API does not speak Mandarin on Firefox. Is it not supported? I couldn't find a list in the docs. I tried several different language tags.
var msg = new SpeechSynthesisUtterance();
msg.text = '你好';
msg.lang = 'zh';
window.speechSynthesis.speak(msg);
(如果它有效,您应该听到 "nihao"。在 Chrome 上听起来 fine,在 OK 上Safari。在 Ubuntu 上的 Firefox 53.0.2 上,我听到 "letter 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;
}
}
SpeechSynthesis API does not speak Mandarin on Firefox. Is it not supported? I couldn't find a list in the docs. I tried several different language tags.
var msg = new SpeechSynthesisUtterance();
msg.text = '你好';
msg.lang = 'zh';
window.speechSynthesis.speak(msg);
(如果它有效,您应该听到 "nihao"。在 Chrome 上听起来 fine,在 OK 上Safari。在 Ubuntu 上的 Firefox 53.0.2 上,我听到 "letter 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;
}
}