想编写带语音的网页吗?
快去看一下WebSpeech

WebSpeech

简体中文版

(updated on Jun 23, 2014)

WebSpeech is a Javascript library for developers who want to write pages with voice. WebSpeech supports Android and iOS 4 or newer. It can be downloaded from SourceForge. And there is a WebSpeech module for Drupal 7

Here is a demo:


Language: Variant:
Speed Delta(-50..100): Pitch Delta(-100..100): Volume Delta(-100..100):

Here is a simple code example:

<html>
  <head>
    <script type='text/javascript'
      src='/WebSpeech/WebSpeech.js'></script>
  </head>
  <body>
    Have you heard the voice?
    If not, please make sure Flash plug-in has been installed.
    And this example should be put on web server
    (not open it as a local file)!!
    <script type='text/javascript'>
      WebSpeech.ready(function() {
        WebSpeech.setVoice('en');
        WebSpeech.speak('hello world');
      }
    </script>
  </body>
</html>

And here are some more examples written with WebSpeech:

Why can we make web page speakable with WebSpeech? That's because there is a Web TTS server behind it. The server provides free service for the public for limited usage. You can also setup your own Web TTS server with instruction of How to setup eSpeak TTS server for WebSpeech. If you think this service is useful, I really appreciate your donation, which is significant to the persistence of WebSpeech and eGuideDog project.

We provide unlimited usage of voice service for commercial websites (and government websites). The fee is $100 USD or ¥500 RMB each year for one website.

We also provide TTS server setup and maintenance service. The fee is $200 USD or ¥1000 RMB for one server setup and one month maintenance with all source code and documents. A special processed Ekho voice data that has better quality with bigger size than that offered in standard version are included. You need to prepare a Linux server which can be access from internet.

Please contact Cameron Wong (hgneng at gmail.com) for the services.

Here is the API of WebSpeech:

// default is 'http://wa.eguidedog.net/cgi-bin/ekho.pl'
WebSpeech.server = 'your new TTS server';

WebSpeech.speak('text to speak');
WebSpeech.pause();
WebSpeech.resume();
WebSpeech.stop();

// read current HTML page
WebSpeech.speakHtml();
WebSpeech.pauseHtml();
WebSpeech.stopHtml();

// execute function when Webspeech initialized
WebSpeech.ready(function () { ... });

// set callback function, which will be called when speeches finish
WebSpeech.onfinish = function () { ... };

// voiceName can be EkhoMandarin (default), EkhoCantonese
// or any voice name in eSpeak
WebSpeech.setVoice('voiceName');

WebSpeech.getSpeedDelta(); // return speed delta
WebSpeech.setSpeedDelta(value); // -50 <= value <= 100
WebSpeech.getPitchDelta();
WebSpeech.setPitchDelta(value); // -100 <= value <= 100
WebSpeech.getVolumeDelta();
WebSpeech.setVolumeDelta(value); // -100 <= value <= 100

// like SaveAs action in the browser
WebSpeech.saveMp3('text to save to MP3 format file');
WebSpeech.saveOgg('text to save to OGG format file');

// when data available, callback function will be called and
// the result will pass as the arguments.
WebSpeech.getPhonSymbols('text', function (success, symbols) { ... });

License: GPLv2+