语音合成 API 支持的语言
Speech Synthesis API Supported Languages
有人有语音合成 API 支持的语言列表吗?或者我可以 运行 找到不同语言的代码片段?谢谢!
每个 browser/OS 组合的支持语音列表不同。
我写了一个 jsbin 显示 browser/OS 的声音 运行:
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;
}
}
有人有语音合成 API 支持的语言列表吗?或者我可以 运行 找到不同语言的代码片段?谢谢!
每个 browser/OS 组合的支持语音列表不同。
我写了一个 jsbin 显示 browser/OS 的声音 运行:
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;
}
}