2017-05-15 56 views
0

SpeechSynthesis API在Firefox上不会说普通话。它不支持?我无法在文档中找到列表。我尝试了几种不同的语言tags中文SpeechSynthesis API - Firefox

Fiddle:。

var msg = new SpeechSynthesisUtterance(); 
msg.text = '你好'; 
msg.lang = 'zh'; 
window.speechSynthesis.speak(msg); 

(应该听到 “你好”,如果它的工作原理听起来在Chrome 精细和Safari上OK在Ubuntu上的Firefox 53.0.2,我听到“信字母“)。

+0

我测试你的小提琴和它运作良好,在Firefox 53在Mac 10.12 – shaochuancs

回答

2

在Windows上,Firefox只有3种声音,全部是英文。

我写了显示浏览器的声音一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; 
    } 
}