Speech Synthesis API Supported Languages

痞子三分冷 提交于 2019-12-04 06:43:45

问题


does anybody have a list on the languages which Speech Synthesis API supports? Or a snippet of code I could run to find the different languages? Thanks!


回答1:


The list of supported voices is different for each browser/OS combination. I wrote a jsbin showing the voices of the browser/OS on which it's run:
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;
    }
}


来源:https://stackoverflow.com/questions/41549950/speech-synthesis-api-supported-languages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!