using text to speech in firefox

There are so many nice articles written in web everyday. And after delicious, digg, reddit etc are there, these articles are becoming reachable also. But i dont have time to read all of them. How nice it would be if someone will read them for me while in am working on something else. Here is a simple solution.

Software Requirements -
* festival (text to speech software)
* mbrola (speech synthesizers)

Steps -

1) Install festival
- festival comes by default with my distribution fc4.

2) Test festival
- echo “hello world” | festival –tts
or festival –tts filename.txt

this is a basic setup with which will work. You can save the webpage and then run festival on it.

3) Improve voice quality with mbrola ( follow the instructions at this link )
- Get the binary of your architecture from mbroal download page. i386 people get move the binary of your architecture available in to any $PATH directory and rename it to just mbrola. ex : mv mbrola-linux-i386 /usr/local/bin/mbrola
- Get the festival voice wrapper from here and extract it to festival voices directory (aka $FVD) (/usr/share/festival/voices for me)
– move us1_mbrola available in the tar to $FVD/english
– get us1 voice from mbrola voices page. extract the mbrola voice (eg us1) to $FVD/english/us1_mbrola/
— to add more voices just copy festvox to another directory (say us2_mbrola), and do the necessary changes to file names and data. replace every us1 with us2 (for us2 voice). and then copy the new voice like before(us1 case).

run festival as in step 2 and you will be able to listen to any text in a real like voice.

But its not very convenient to everytime save text and then run festival. so a firefox extension will do this job for us. coz i am not a firefox extension hacker i have worked around the problem to solve it for me.. if anyone knows how to save the selected test into a file and then run a system program using a firefox extension then please let me know. or those who are looking around to develop something cool, can write such an extension for firefox.

4) my hack to this problem - i mapped a mouse gesture to a javascript (provided by Optimoz Mouse Gesture extension) that posts the selected test to a cgi file sitting on localhost. this cgi file run festival tts on the text and i am able to listen to selected text with a simple mouse gesture. the javascript follows -

}else if(y.getSelection){
var r = new XMLHttpRequest();”GET”, “http://localhost/~user/cgi-bin/tts.cgi?data=”+escape(Q) );
r.send( null );

write a simple cgi files which just does `echo $_GET[’data’] | festival –tts`

5) festival also provides text2wave which allows you to convert text to wave file and you can enqueue the audio file into your playlist.

* window managers like KDE/Gnome etc provides this facility. so if you use a complex window manager, try to explore this facility in it before going through the above procedure.

long time no links -
* The C++ Source. As Simple As Possible?
* How to Interview a Programmer
* You have the right to blog silent!
* 2006 Will Be Delayed By A Second
* Switched On: The Year of the Switch
* Three Reasons Why You Should be an Entrepreneur
* timbl’s blog
* Software Predicts Movie Success
* Agatra / Forget your passwords

4 Responses to “using text to speech in firefox”

  1. vardhman Says:

    I did it earlier :)
    Hey, I posted about newsreading in Linux/KDE. Which is kinds of better than ur 4th point. Check it out.

  2. smr Says:

    yeah right..
    but there are people who hates to use any k* command. so they have to work around for it.

  3. vardhman Says:

    Will try mbrola
    Probably on ur pc itself, Festival TTS work good in some pages and bad in some, a more humanly voice would be awesome.

  4. Pam Says:

    Festival installation
    I am facing problems in installing festival.. could you please give me the exact procedure to install it?

Leave a Reply