语音合成API支持的语言

时间:2017-01-09 14:15:47

标签: speech-synthesis

有人有一个关于Speech Synthesis API支持的语言的列表吗?或者我可以运行一段代码来查找不同的语言?谢谢!

1 个答案:

答案 0 :(得分:0)

每个浏览器/操作系统组合支持的语音列表不同。 我写了一个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;
    }
}