• 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中将文字转语音)

  • 相关阅读:
    .Net转Java自学之路—SpringMVC框架篇九(拦截器)
    .Net转Java自学之路—SpringMVC框架篇八(RESTful支持)
    移动端高清适配、布局开发解决方案
    Webpack+Gulp+React+ES6开发
    gulp使用gulp-file-include将header/footer引入页面
    git在window与linux的换行符问题
    文件(图片)上传组件
    ie8、9跨域上传文件(图片)
    移动端rem布局背景图片使用以及sprite雪碧图
    iOS/Android 浏览器(h5)及微信中唤起本地APP
  • 原文地址:https://www.cnblogs.com/zrbfree/p/5626815.html
Copyright © 2020-2023  润新知