2014-02-09 49 views
9

我正在创建HTML5 Speech Synthesis应用程序,如下面的链接。Firefox和语音合成API

http://updates.html5rocks.com/2014/01/Web-apps-that-talk---Introduction-to-the-Speech-Synthesis-API

的Windows7和Android Chrome33beta或Mac的Safari浏览器工作正常。

但Windows7-Firefox 27似乎支持Speech-Synthesis-API,但不工作,因为返回空语音列表。

有没有解决方法?

+0

有一个名为'media.webspeech.synth.enabled'的'about:config'标志,可以在Firefox中启用'speechSynthesis'。问题依然存在,'speechSynthesis.getVoices()。length === 0'。 – dakab

回答

1

不幸的是,它看起来像只有Firefox操作系统(也可能是Android的Firefox,我没有检查过)捆绑并支持语音合成库。

有关桌面支持的开放bug

1

从版本44开始,在Firefox桌面上可以使用语音合成的一半api。

但奇怪的是仍然要求设置标志。在"Browser Compatibility"

可以通过在有关media.webspeech.synth.enabled和media.webspeech.recognition.enable标志启用:配置。请注意,目前Firefox桌面中只有语音合成部分可用 - 语音识别部分即将发布,一旦所需的内部权限被整理出来。

我想知道为什么。 MDN甚至去鞭打some nice working examples的麻烦,为什么不启用功能默认?

0

如果你只是想将一个按钮添加到您的网页大声朗读网页时,该代码添加到您的网站:

<script src='https://code.responsivevoice.org/responsivevoice.js'></script> 
<script type="text/javascript"> 
    <!-- // 
    var speechpause=0; 
    function toggleSpeech(){ 
     if(speechpause!=1){ 
     responsiveVoice.pause(); 
     speechpause=1; 
     }else{ 
     responsiveVoice.resume(); 
     speechpause=0; 
     } 
    } 
    //--> 
</script> 
<div style="float:right"> 
     <input onclick="responsiveVoice.speak($('#some_div_with_content').text(), 'Deutsch Female', {pitch: .7});" type="button" value=" Play" /> 
     <input onclick="toggleSpeech()" type="button" value="||" /> 
</div> 

这使用jQuery来获取内容的文本,但可能很容易改变。