Talking Clock in Ubuntu
I got envious of Fefi’s Macbook which hourly reads the time out loud. “It’s eleven o’clock”, his laptop calls out during meetings. I wanted to be periodically reminded of the time as well, so I searched for a suitable software for Ubuntu.
I didn’t find a talking clock package, sadly. But I found several alternative alarm clocks (Alarm Clock, saytime, Amarok/Rhythmbox plugin, etc.) which can play out a custom sound. Some people in ubuntuforums.org recommended using espeak (voice sounded too mechanical) or festival (large install) to read out the time, but there were always some problems. I was too lazy to program myself, so I was looking for a quick install, but searching for one is eating up my time more than if I just did the scripting myself. So I decided to make use of cron instead, and some bash scripting to get the job done. Now, I have a “lady” reminding me of the time every hour!
So, here’s what you need to do:
Disclaimer: Scripts done for my personal use. Use at your own risk. :P
- Download the voice files. I found mine (I used AT&T Audrey) from Steve’s Talking Clock.
- Concatenate the files to form your alarms. I used sox to concatenate its.wav {time}.wav and {am/pm}.wav. So mine says “It’s 9PM.” You can use and modify the generate_voice.sh if you want a different alarm format. The files will be stored in .clockvoices by default, if not specified during the call.
#!/bin/bashvoicepath=${HOME}/.clockvoice
command="sox its.wav"if [ $# -ne 0 ]; then
if [ $1="--help" ]; then
echo "Usage: generate_voice.sh "
echo "Make sure to run this while in the directory of voice files."
exit
else
voicepath=$1
fi
fiecho Saving in ${voicepath}...
for j in 0 1; do
for i in `seq 1 12`; do
period="am"
if [ $j -eq 1 ]; then
period="pm"
fifname=$((i%12+j*12))
if [ $fname -lt 10 ]; then
fname=0$fname
fi
`$command $i.wav $period.wav ${voicepath}/${fname}00.wav`
done
done - Write the bash script to play out the proper file according to the time. See readtime.sh. This will be the script that cron will execute hourly.
#!/bin/bash
# readtime.shvoicepath=${HOME}/.clockvoice
hour=`date +%H`if [ $# -ne 0 ]; then
voicepath=$1
fiplay ${voicepath}/${hour}00.wav
- Set your cron’s schedule by typing
crontab -eAdd an entry like so:0 * * * * {absolute_location_of_readtime.sh}
That’s about it! Enjoy! :D
Filed under: Open Source, Software | Leave a Comment
No Responses Yet to “Talking Clock in Ubuntu”