Usage:
$ say en lol #says "lol" in englishAnd here goes the script:
$ somecommand | say fr - #read text to say from a pipe
#!/bin/ash
lang=$1
shift
if [ "$1" = "-" ]
then
read text
echo $text
else
text=$*
fi
len=`expr length "$text"`
if [ -z "$text" ] ; then
echo "Please specify string to translate (up to 100 characters incl.)."
exit 4
elif [ "$len" -gt "100" ] ; then
echo "Can't translate more than 100 characters at once! (entered $len)"
exit 2
fi
wget -qU Mozilla -O - "http://translate.google.com/translate_tts?ie=UTF-8&tl=$lang&q=$text" | madplay -Q -o wave:- - | aplay -q -
exit 0