160617、使用espeak將文字轉語音(TTS)


http://www.eguidedog.net/cn/WebSpeech_cn.php

簡單使用例子:

<html>
  <head>
    <meta http-equiv="Content-Type"
      content="text/html; charset=utf-8" /> 
    <script type='text/javascript'
      src='/WebSpeech/WebSpeech.js'></script>
  </head>
  <body>
    聽到聲音了嗎?
    <script type='text/javascript'>      WebSpeech.server = 'http://120.24.87.124/cgi-bin/ekho2.pl';
      WebSpeech.speak('聽到聲音了嗎?');
    </script>
  </body>
</html>

API

// 默認語音服務器是 'http://wa.eguidedog.net/cgi-bin/ekho.pl'
// 請修改為 http://120.24.87.124/cgi-bin/ekho2.pl
WebSpeech.server = '您的語音服務器';
WebSpeech.speak('text to speak');
WebSpeech.pause();
WebSpeech.resume();
WebSpeech.stop();
// 朗讀當前網頁
WebSpeech.speakHtml();
WebSpeech.pauseHtml();
WebSpeech.stopHtml();
// 當WebSpeech初始化完成后運行
WebSpeech.ready(function () { ... });
// 當speak的文本完成后運行
WebSpeech.onfinish = function () { ... };
// 目前支持的聲音有 EkhoMandarin(即普通話,缺省),EkhoCantonese(粵語)
// 以及eSpeak中支持的聲音
WebSpeech.setVoice('voiceName'); 
WebSpeech.getSpeedDelta();
WebSpeech.setSpeedDelta(value); // -50 <= value <= 100
WebSpeech.getPitchDelta();
WebSpeech.setPitchDelta(value); // -100 <= value <= 100
WebSpeech.getVolumeDelta();
WebSpeech.setVolumeDelta(value); // -100 <= value <= 100
// 會激活瀏覽器“另存為”的功能
WebSpeech.saveMp3('text to save to MP3 format file');
WebSpeech.saveOgg('text to save to OGG format file');
// 獲取漢字的音標,當數據到達時會調用參數中傳入的函數,
// symbols就是我們需要的數據,是以空格為分隔符的字符串
WebSpeech.getPhonSymbols('text', function (success, symbols) { ... }); 

補充:可以去下載jtts.jar(java中將文字轉語音)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM