Speech Synthesis API Supported Languages

后端 未结 1 1871
余生分开走
余生分开走 2021-01-22 15:52

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条回答
  •  广开言路
    2021-01-22 16:15

    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 = '';
        // Get voices; add to table markup
        function loadVoices() {
            var voices = speechSynthesis.getVoices();
            voices.forEach(function(voice, i) {
              // Add all details to table
              text += '
    DefaultLanguageLocalNameURI
    ' + voice.default + '' + voice.lang + '' + voice.localService + '' + voice.name + '' + voice.voiceURI; }); } loadVoices(); langList.innerHTML = text; // Chrome loads voices asynchronously. window.speechSynthesis.onvoiceschanged = function(e) { loadVoices(); langList.innerHTML = text; } }

    0 讨论(0)
    提交回复
    热议问题