0
有沒有人有語音合成API支持的語言列表?或者我可以運行一段代碼來查找不同的語言?謝謝!語音合成API支持的語言
有沒有人有語音合成API支持的語言列表?或者我可以運行一段代碼來查找不同的語言?謝謝!語音合成API支持的語言
支持的語音列表對於每個瀏覽器/操作系統組合都不相同。 我寫的顯示瀏覽器/ OS的聲音一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;
}
}