My shell scripts #3 - Google Text-to-Speech API

This simple script outputs an mp3 audio of a given text string ready to be played by some commandline app (sox, madplay, ...). The only thing I can't figure out is how to get it to accept some national characters (right now it just says some gibberish). If you manage to figure out this one problem, I'd be more than happy to hear from you in the comments ;).

Usage:
$ say en lol #says "lol" in english
$ somecommand | say fr - #read text to say from a pipe
And here goes the script:
#!/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

My shell scripts #2 - WHOIS search

This time, we're going to get some informations about domains through WHOIS servers. All this via CLI interface and without the ubiquitous "whois" command (which is not available for my CPU architecture in OpenWrt package repository and I'm too lazy to cross-compile it myself). Used programs: "netcat", "sed", "grep".

The whois-servers.net server automatically redirects you to the WHOIS server responsible for the supplied TLD, so you don't have to remember them (and it also simplifies this script).
#!/bin/ash
if [ ! -n "$1" ]
then
  echo "Usage:"
  echo "  $0 domain.tld"
  exit 1
fi
tld=`echo $1 | sed 's/\/.*//' | grep -o '[[:alpha:]]*$'`
echo "$1" | netcat -T $tld.whois-servers.net 43
echo
exit 0

My shell scripts #1 - Wikipedia search

I will publish my creations here, just in case someone finds them useful. My scripts are made for the ash shell, so they should work in most of the other shells. I run them on my OpenWrt router with 400MHz CPU and 32MB RAM with no problems :).

The first one I'm going to publish is a Wikipedia search script, requiring only "dig" and "sed" programs. Usage is fairly simple, just type:

$ ./wiki.sh hello world


The script automatically replaces all spaces with underscores. And now the actual code:

#!/bin/ash
if [ ! -n "$1" ]
then
  echo "What are you searching for?"
  echo "Usage:"
  echo "  $0 keyword"
  exit 1
fi
q=`echo $* | sed 's/\ /\_/g'`
dig +short txt $q.wp.dg.cx | sed 's/\"\ \"//'
exit 0