Setting up a talking clock easily in Linux
January 19, 2012 2 Comments
There are several ways to set up a talking clock in Linux. One simple way to do it if you’re a KDE user is to use the Analogue Clock widget. Once you have placed the Analogue Clock widget on your Desktop, click on the widget’s spanner icon, select the ‘General’ tab and it shows the title ‘Text to Speech’ and a ‘Speak time’ box where you can select the frequency at which you want the talking clock to speak the time. When you click ‘Apply’, an icon appears in the System Tray on the Panel: Jovie KDE Text-to-speech Manager. You can right-click on the Jovie icon then click on ‘Configure’ to change the language and voice etc.
Another alternative is to install the eSpeak text-to-speech synthesizer and use the GUI KAlarm utility to run the following command at any interval you like (every hour, every half hour, every 15 minutes or whatever you want):
date +%I:%M%p | espeak
When the command above is executed on the hour, the voice speaks the hour followed by “zero zero AM/PM”. For example it says “seven zero zero PM” rather than “seven o’clock PM”. If you prefer the latter, you can modify the one-line command:
if [ $(date +%M) != "00" ]; then date +%-H:%M%p%Z; else echo -n $(date +%-H); echo -n "oh clock "; date +%p; date +%Z; fi | espeak -ven+f6
Use the command
date --help to find out the different parameters available for the
date command. You can also play around with the last two characters in the above command to get different voices. For example “m1″, “f4″ etc.
Using KAlarm’s GUI is less daunting for many people than setting up a cronjob to run the command, which would be yet another way of doing it. Also, by using KAlarm it is quick and easy to enable and disable the talking clock.
An alternative to the above command would be to run one of the many Bash scripts found on the Web. One such is saytime. SayTime uses the festival text-to-speech engine, an alternative to espeak, which you would need to install. The guts of SayTime is simply the command:
echo "Today is `date +%d` `date +%B` `date +%Y` and now the time is `date +%k` and `date +%M` minutes" | festival --tts
so you could use that command with KAlarm or a cronjob if you wanted. You can play around with the commands to get the time spoken the way you want.
eSpeak is also configurable; check out the Web site eSpeak text to speech. For example, the following is the time spoken in Portuguese instead of English:
date +%I:%M%p | espeak -vpt
or in English with a Scottish accent:
date +%I:%M%p | espeak -ven-sc
or in English with a Brummie accent:
date +%I:%M%p | espeak -ven-wm
or in Latin with a female voice:
date +%I:%M%p | espeak -vla+f4
Three guesses what this one does:
date +%I:%M%p | espeak -ven+whisper
You can have some fun exploring the options.