15

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.

dda
  • 6,030
  • 2
  • 25
  • 34
Ajax3.14
  • 1,647
  • 5
  • 24
  • 42
  • 4
    "_for sight impaired people to tell them what is happening"_ really a good thinking. – Ram Jul 01 '12 at 03:26
  • An interactive demo of speak.js can be found here: http://jsfiddle.net/YgWdh/30/ – Anderson Green Feb 26 '13 at 06:09
  • 1
    @AndersonGreen, this demo does not work for me... on Chrome, Windows 8. Microphone works and speakers too, just checked. – Adam Mar 17 '14 at 21:12

2 Answers2

35

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/

James
  • 13,571
  • 6
  • 61
  • 83
  • The voice looks far better than js plugins. But how responsive would be using this service with my app. will it sync with the speed of my animation, basically I have ~.5 secs between every action. And moreover do you have a sample program for how to make the call to the google tts.Thanks – Ajax3.14 Jul 01 '12 at 03:40
  • 1
    thanks a lot!! it works in safari not chrome..Am I missing something – Ajax3.14 Jul 01 '12 at 04:12
  • May be Chrome is missing some audio plugins, I suggest u use SoundManager js library. It will handle alot of things – James Jul 01 '12 at 04:14
  • 6
    This was deprecated at the time and is shut down now. – John McLear Dec 09 '12 at 22:10
  • Is there any limit, that is maximum to pass within the querystring and receiving back the voice? – Rozkalns Jan 08 '13 at 02:52
  • @RobertR you can try to find its limit, I guess it's 256 chracter (could be more) but you should break into smaller sentences – James Jan 08 '13 at 14:31
  • @TrinhHoangNhu the page does not support cross origin. How would i use it with web audio api? – Achshar Jan 26 '13 at 19:27
  • also can you explain what all the parameters mean? is there any documentation? – Achshar Jan 26 '13 at 20:14
  • 1
    I worked for me for a few hours and now request to Google end up "pending" and "canceled". I've tried everything but the code worked and now stopped working, so I guess Google only allows few requests to its webservice... – Matthieu Napoli Feb 03 '13 at 10:17
  • click the link and enter the captcha to fix it, of course not an optimal solution – Mythli Aug 02 '15 at 09:18
2

Well I suggest you use JTtalk. It depends what your target crowd is, because legally blind and what you may think is blind can differ and not everyone knows Braille. The benefits I saw of Jtalk really relied on the examples it had, and how well they worked. To do our entire front-end part of the project with JTalk only took us 2 days, because we pretty much just edited the examples it had. Speak.js had a more difficult learning curve in my/my group's opinion. However, we found that the speech was a bit slurred and had comprehension issues, especially for documents where there were a lot of names (example stock articles mentioning companies). This is why we moved to Braille.

My senior design project was for the blind, however we realized that the text to speech wasn't where we wanted to go because we felt Braille was better. With Braille you can multitask better, easily go back and pause and most blind people can read Braille a lot faster then they can listen.

dda
  • 6,030
  • 2
  • 25
  • 34
Frank Visaggio
  • 3,642
  • 9
  • 34
  • 71