【问题标题】:Speech Synthesis API offline languages语音合成 API 离线语言
【发布时间】:2017-05-30 13:10:08
【问题描述】:

可以离线使用语音合成API吗?如果是这样,我可以使用多种语言还是只使用默认语言? 我试过这段代码,它可以在线工作,但不能离线工作。我怎样才能使它在线工作?

  <html>
    <head>
      <title>Index</title>
    </head>

<p id = "1"></p>


 <script src="../js/jquery-3.2.1.js"></script>         


<script type="text/javascript">

     $(document).ready(function() {
        document.addEventListener("keydown", function (e) {
          var audio = document.getElementById("myAudio");
            if (e.keyCode ===49 || e.keyCode ===97) {  //1 is pressed                
            mySpeech();
          }              
        });
      })
     function mySpeech(){
      var msg = new SpeechSynthesisUtterance();
      var voices = window.speechSynthesis.getVoices();
      msg.voiceURI = 'native';
      msg.lang = 'it-IT'
      //msg.voice = voices[$('#voices').val()];
      msg.rate = 1; // 0 to 1 
      msg.pitch = 1; // 0 to 2
      msg.text = "hello world";    
      speechSynthesis.speak(msg);
    }   

    </script>

 </body>

【问题讨论】:

    标签: text-to-speech offline speech-synthesis


    【解决方案1】:

    唯一可以离线使用的语言是浏览器的本地语音。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      相关资源
      最近更新 更多