TimeToSpeech
From Hak5
Ever have a need to be able to hear what time it is on your Linux computer with a couple keystrokes? Well with things like the analog clock in Enlightenment 17, lack of a clock in MythTV, small fonts, and other annoyances, who wouldn't? Thanks to a little tiny bash coding, you can hear the time too.
First, you must install Festival and a speaker. This should be fairly straight-forward, depending on your distribution. For Archlinux, simply run
# pacman -Sy festival festival-don
Once Festival is installed, create a file, ~/time.sh. This could be called anything you want.
SPEECH="";
case "$1" in
time)
SPEECH=$( date "+ %l %M %p" | sed -e "s/00//g" | sed -e 's/ 0/ oh /g' | sed -e 's/AM/a-m/g' )
;;
date)
SPEECH=$( date "+ %A, %B %dth" | sed "s/1th/1st/g" | sed "s/2th/2nd/g" | sed "s/3th/3rd/g" )
;;
*)
SPEECH=$( date "+ %A, %B %dth" | sed "s/1th/1st/g" | sed "s/2th/2nd/g" | sed "s/3th/3rd/g" )
SPEECH=$(echo $SPEECH $(date "+ %l %M %p" | sed -e 's/ 0/ oh /g' | sed -e 's/AM/a-m/g') )
;;
esac
echo $SPEECH
echo "(SayText \"$SPEECH\")" | festival --pipe
Now that you have created the file, test it out by running $ sh time.sh
If you hear a British accent saying the date and time, well done! Last thing to do is make your Window Manager make it say the time when you strike a couple keystrokes. In all examples, we'll be saying the time with Alt + T, and the date with Alt + D
Fluxbox: run:
$ echo "Mod1 t :ExecCommand sh ~/time.sh time" >> .fluxbox/keys $ echo "Mod1 d :ExecCommand sh ~/time.sh date" >> .fluxbox/keys
If your Window Manager isn't listed above, just google "howto <window manager name> custom key bindings" and add your findings to this article.


