Raspberry Pi and the "Say" Command from OSX: How-to Make Your Pi Speak-at-will
This Trick No Longer Works
Google has added a captcha to this service so it will no longer work.

OS X has the say
command, which allows it to speak many different voices. Linux users can also have this ability–although it is not as in-depth.
Installing Pre-requisite Software
The Raspberry Pi does not have mplayer installed by default. Fortunately, it can be installed via aptitude.
sudo apt-get update sudo apt-get install mplayer
Add Code to the .bashrc File
Add the following line to the bottom of the ~/.bashrc
file
function say { mplayer "http://translate.google.com/translate_tts?tl=en&q=$1"; }
Test the New Command
Save the file, exit, and log back in for the command to take effect. Now, just type
say “whatever you want to say in quotes” and the Pi will speak for you.
Depending what speaker setup you have, you may need to adjust some settings. In particular, you can try telling the Pi what audio interface to use with the command
amixer cset numid=3 n
where n is:
0=auto 1=analog 2=HDMI
Make the Say Command Scriptable By Adding it to /usr/bin
Create a new file: /usr/bin/say
. The file should read like this (slightly different that if it is in .bashrc
)
#!/bin/bash mplayer "http://translate.google.com/translate_tts?tl=en&q=$1";
The file needs to be executable; there are two ways to do this:
chmod 755 /usr/bin/say
or
chmod +x /usr/bin/say