Text-to-speech is really convenient, especially when you are lazy like me. Festival enables us to achieve a TTS system with limitless possibilities thanks to our Linux bash shell. I will show you some ways that we can use Festival as an enabler to our laziness and also produce some really cool and useful effects when coupling this technology with common things like PHP, cron, dnotify, or login scripts.
Remember the movie 2001: A Space Odyssey? I’d like to think that I am Dave, I just hope that my PC doesn’t turn on me (Although, I think it has in the past).
image via link
You need to install Festival. su root if need be.
festvox-kallpc16k is the male american voice. Ubuntu doesn’t install a voice unless you specify which will cause the program to crash. Look in synaptic for other voices and language support.
Fedora - CentOS - Redhat:
Now that we have Festival installed, lets start with the basics.
Make Festival say something:
Make Festival read a text file:
Make Festival say the time:
Festival and PHP Programming
Combining the Power of PHP and Festival we can do some cool things. You need to have a PHP CLI installed.
Make Festival say a random quote:
Contents of rquote.php (minus the PHP tags):
$quotes = 'Nothing is faster than the speed of light...To prove this to yourself, try opening the refrigerator door before the light comes on.';
$quotes = 'The FBI is watching YOU.';
$quotes = 'Vote anarchist.';
srand ((double) microtime() * 1000000);
$random_number = rand(0,count($quotes)-1);
- $quotes = ‘Nothing is faster than the speed of light…To prove this to yourself, try opening the refrigerator door before the light comes on.’;
- $quotes = ‘The FBI is watching YOU.’;
- $quotes = ‘Vote anarchist.’;
- echo ($quotes[$random_number]);
php rquote.php | festival --tts
Back to the Real World
You might be thinking,”Well that is great and dandy, I can make my PC talk. Woopty friggin doo.”.
Create a desktop shortcut. You can then drag files on top of it to have Festival read the file (Yah! No more command line):
Create a file with the following contents named readit.desktop:
Remind yourself of the time on the hour with cron:
Enter the following into the file:
0 * * * * username ~/time.sh
Contents of time.sh:
date '+%I, %M %p' | festival --tts
Make it executable chmod u+x ~/time.sh.
Make Festival talk when a file has been accessed or changed using dnotify (HINT: You might have to install dnotify):
dnotify -CD /home/shane/Desktop -e echo "A file has changed on the desktop" | festival --tts
Make Festival read man pages to you:
Lets face it, no one likes to read man pages:
man lsof | festival --tts
The possibilities are endless
I hope you see all the possible things that you can have your computer talking to you about. I am acually going to have Festival (It would have been cool if they would have named it HAL 9000) read this article to me to check for grammar and spelling. The voice isn’t the greatest, it just takes a little getting used to. Check your repos for more voices. Let me know if you come up with something interesting in the comments and I will add it to the list. Now you should feel a little bit more like Dave Bowman!