A good Text-to-Speech JavaScript library

31,456

Solution 1

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.

Solution 2

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/

Share:
31,456
Ajax3.14
Author by

Ajax3.14

Updated on March 31, 2020

Comments

  • Ajax3.14
    Ajax3.14 over 4 years

    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.

  • Ajax3.14
    Ajax3.14 about 12 years
    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
    Ajax3.14 about 12 years
    thanks a lot!! it works in safari not chrome..Am I missing something
  • James
    James about 12 years
    May be Chrome is missing some audio plugins, I suggest u use SoundManager js library. It will handle alot of things
  • John McLear
    John McLear over 11 years
    This was deprecated at the time and is shut down now.
  • Rozkalns
    Rozkalns over 11 years
    Is there any limit, that is maximum to pass within the querystring and receiving back the voice?
  • James
    James over 11 years
    @RobertR you can try to find its limit, I guess it's 256 chracter (could be more) but you should break into smaller sentences
  • Achshar
    Achshar over 11 years
    @TrinhHoangNhu the page does not support cross origin. How would i use it with web audio api?
  • Achshar
    Achshar over 11 years
    also can you explain what all the parameters mean? is there any documentation?
  • Matthieu Napoli
    Matthieu Napoli over 11 years
    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...
  • Mythli
    Mythli almost 9 years
    click the link and enter the captcha to fix it, of course not an optimal solution