A good Text-to-Speech JavaScript library

Ajax3.14 picture Ajax3.14 · Jul 1, 2012 · Viewed 30.2k times · Source

I am looking for a good text to speech javascript library for my application. I looked around and saw Jtalk and speak.js. But I'm not sure which one to go forth with. I'm curious to know from people about the pros and cons of them and I'm interested to know if there's any other Javascript plugin you guys came across.

I am basically visualizing a animation and I wanted to add some audio for sight-impaired people to tell them what is happening.

Answer

Trinh Hoang Nhu picture Trinh Hoang Nhu · Jul 1, 2012

UPDATE 2018

Modern browser has built in TTS

if ('speechSynthesis' in window) {
    var msg = new SpeechSynthesisUtterance('Hello World');
    window.speechSynthesis.speak(msg);
}

speechSynthesis

Deprecated

If you don't want to write a lot of code (or import some library that you don't understand), I suggest you use Google TTS services. It's quite simple. For example you have a text like: welcome to Stack overflow you can call like this:

http://translate.google.com/translate_tts?ie=UTF-8&q=Welcome%20to%20stack%20overflow&tl=en&total=1&idx=0&textlen=23&prev=input

This will return an audio file reading that text. Then your job is to use browser audio to play it. Nice and easy.

PS: Google TTS has really true voice.

Example: http://jsfiddle.net/qspcL/

Reference from: http://jnjnjn.com/187/playing-audio-on-the-ipad-with-html5-and-javascript/