If this blog helped you in any way, please donate a dollar here

Sunday, July 11, 2010

Voice Notification System

Want to make the computer remind you the time every hour, so you don't lose track?

Here's a simple voice (I've chosen a female US speaker for this ;-) notification system that will remind every hour the time.

Pre-requisites:
festival

To install festival:
sudo apt-get install festival


Download:

And extract to:
/usr/share/festival/voices/english/cmu_us_clb_arctic_clunits

make sure the directory name ends with clunits.

Next, we must make the downloaded voice the default voice.
Edit, festival.scm which is located here:
/usr/share/festival/festival.scm


And append the line:
(set! voice_default 'voice_cmu_us_clb_arctic_clunits)

save the file and now...we are almost done.

Now to configure festival to speak:

Create a file (say, speak.sh) in your $HOME folder, with these contents:
---------------------
#!/bin/sh
festival --tts <<>
"$*"
EOF
---------------------

Next, create another file (say sayHourly.sh) in any folder (say at $HOME folder) with the following contents:
--------------BEGIN---------------
#!/bin/sh
if [ `w USERNAME -hos | wc -c` -eq 0 ]; then
exit;
fi;
tim=`date '+%l %p' | sed 's/AM/A.M/'`;
/home/USERNAME/speak.sh "It is $tim"
----------------END--------------
(replace USERNAME, with your username)

All set, now to create a cron job that runs your sayHourly.sh every hour. You can customize this to do anything else.

Run: (as yourself)
contab -e


Add this in one line of the file:
---------------------
0 * * * * /home/USERNAME/sayHourly.sh
---------------------
Don't forget to replace USERNAME, with your username.

Now we are all done, enjoy the American Girl telling you the time every hour!

No comments:

Post a Comment