zoukankan      html  css  js  c++  java
  • 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中将文字转语音)

  • 相关阅读:
    [转]群控电梯调度算法
    [转] 电梯调度算法总结
    [转]grub2.0和之前版本修复解决方案
    [转]Ubuntu 10.04 编译安装最新版本Linux2.6.34内核
    [转]PS2 键盘工作方式
    [转]个人管理 - 目标管理之前,你会时间管理吗
    [转]ubuntu 下编译内核简单步骤
    [转]关闭Google安全搜索,实现无限制搜索
    [转]Vim 复制粘贴探秘
    [转]Linux文件搜索
  • 原文地址:https://www.cnblogs.com/zrbfree/p/5626815.html
Copyright © 2011-2022 走看看