Emulate say() in Ubuntu

February 1st, 2009 Chris
Tags: , , | Comments Off

Macs come standard with the “say” command, which translates text into speech. It’s pretty easy to do the same thing on linux, using a package called ‘festival’.

Install the app:

sudo apt-get install festival

Then try it out:

echo “Hello World!” | festival -tts

If you get an error message that says “can’t open /dev/dsp”, do the following:

sudo apt-get install esound-clients
sudo gedit /etc/festival.scm

and paste in the following lines:

(Parameter.set ‘Audio_Command “esdplay $FILE”)
(Parameter.set ‘Audio_Method ‘Audio_Command)
(Parameter.set ‘Audio_Required_Format ‘snd)

Now, save the file, and try it again.

I added a little alias, as well. Open up your ~/.bashrc and add these lines:

function say {
    echo $1 | festival --tts
}

Now the command requires much less typing:

say “Hello world!”

Have fun!

Comments are closed.