![]() |
|
ADSP 21xx
Have you found this site useful? Did we save you time? Did we cure your head-ache? Is your hair growing back now? Please make a donation to help with maintenance. |
Text to Speech HowtoMandrake Linux 10.x Herman Oosthuysen Copyright 2005, Aerospace Software Ltd, GPL. ScopeThis guide explains how to get your computer to read a text file, using the Festival text to speech program. I wanted the computer to read my email and it turned into a whole weekend of fun. The default voice used by Festival will drive any sane human being to tears and reminds me of Mervin The Paranoid Android, from Douglas Adams' Hitchhiker's Guide to the Galaxy series. Another way to describe the voice, is that of an enebriated Irishman. A good party tool for St. Paddy's Day. InstallInstallation is the easy part, since most of it comes with Mandrake in rpm format. Run rpmdrake (or urpmi) and install the Festival package. The Festival home page is here: http://www.cstr.ed.ac.uk/ I selected the American English voice - and am now too scared to try the British voice... Sox is the swiss army knife of audio. It can do pretty much anything pretty well. Get sox here: http://sox.sourceforge.net/
Look at the end of the make output and confirm that everything is OK. Play the System LogRun the audio mixer Kmix and turn all the volume sliders waaaaay up. By default, Festival speaks very softly. On my VIA MiniITX system, the VIA DXS and Main Volume sliders control this service. Well, let's dive right in and make the machine read the system log file. I left the machine doing this when I went out and when I came back a couple hours later, the cat was relaxing under the table, with the voice of god talking to her every so often... # tail -f /var/log/messages |festival --tts | sox -t wav - -t ossdsp /dev/audio echo 1 2 150 1 If that works, then you'll soon need a box of tissues. This must be what Mervin did when he caused a bunch of attack robots to commit suicide, by telling them the story of his life... TestIf that didn't work, which is very likely, then you need a more structured test method. First create a text file to read: $ echo "hello world" > hello.txt $ festival --tts hello.txt Play with the above and the Kmix sliders, till you can hear it talk to you. The --tts switch means Text To Speech. Tie echo and festival together: $ echo "hello world" | festival --tts Read the system log file: $ su - password # tail -f /var/log/messages|festival --tts You can add some effects to the voice, by feeding the result through sox and then the fun can really start. The Sox program usually works by feeding it the names of an input and output file. In that case, it can automatically detect the file type and using it is really easy. However, we want to use it as a filter. To do that, replace the input filename with a dash. The dash will cause Sox to read from STDIN instead. When used as a filter, Sox cannot automatically detect the file type, so we have to define the type with the -t wav parameter. Immediately after that you will see a lonely dash, which tells Sox to use STDIN for input, which allows us to Pipe "|" data to it from the Festival program. To feed the output to the DSP Audio device, we have to identify the file type as -t ossdsp /dev/audio. Effects are added at the end of the line as echo 1 1 0.5 0.5, or whatever tickles your fancy. See the Sox manual page for details. # tail -f /var/log/messages |festival --tts | sox -t wav - -t ossdsp /dev/audio echo 1 2 100 0.6 It took me a few hours to figure that line out, which prompted me to write this guide! Whenever a new line is added to the system log, the computer will talk. Put this on a firewall and you'll know when the system is under attack. Festival ServerFestival has a server called festival_server and its corollary festival_client. It works, but it doesn't seem to be able to handle a stream. It only starts speaking once it reaches the end of a file, which made it unusable for me. Steven HawkingIf you need a text to speech system to allow a disabled person to communicate, then you can set up a simple text editor and use tail to output the last line that was written to the file, BUT I wasn't able to get that to work. If anyone figures out a simple method to hook a text editor to Festival, please let me know. The not so simple method, is to install KDE version 3.4, which has all this built in, but it is still under heavy development, or you can install the Emacspeak desktop, available from emacspeak.sourceforge.net. This is a complete desktop system for the blind and apparently, it works very well. Just reading a text file is easy though. You can get plain text books from Project Gutenberg and feed them to Festival: $ festival --tts filename If it is a HTML file, then you need to strip the HTML tags and the Lynx text browser can be put to good use, to do that on the fly: $ lynx -dump filename | festival --tts For larfs, you can do this: $ lynx -dump http://slashdot.org|festival --tts It is difficult to remove the annoying brackets from a web page, since grep uses a bracket as a reserved character. An inverse literal match works. It breaks the bracketed tags and then Festival ignores what is left. The following example removes brackets and vertical bars from a web page. The result sounds quite acceptable: $ lynx -dump http://slashdot.org | grep -v -F "[" | grep -v -F "|" | festival --tts To read PDF files, pipe together pdf2ps and ps2ascii like this: $ pdf2ps filename | ps2ascii | festival --tts Read EmailThe trick with email, is to use formail to filter out the subject and body parts of the incoming messages, so that Festival doesn't have to slog through all the boring headers. First, you have to find your mail Inbox. On this machine, my inbox is in ~/.thunderbird/default.hhj/Mail/mail.aeronetworks.ca. So, change directory and try the following formail command: # cd ~/.thunderbird/default.hhj/Mail/mail.aeronetworks.ca # tail -f Inbox | formail -s formail -k -X From: -X Subject: | festival --tts The tail utility reads any new additions to the Inbox and pipes it to formail. Formail splits the mailbox up into separate mail messages and feeds each message to another copy of formail, which extracts the From: and Subject: headers. The k parameter tells it to keep the body as well. The result is piped into Festival. Whenever a new mail message lands in my Inbox, Festival now reads it for me - small things, yeah, I know... ;-) Have fun! Herman |
|
Copyright © 2005-2008, Aerospace Software Ltd., GPL. |