- 24
- Nov
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).
Credit were credit is due – some ideas from xenocafe.com and linuxgazette.net.
image via link
Installation
You need to install Festival. su root if need be.
Ubuntu:
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:
openSUSE:
The Basics
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.’;
-
-
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.”.
We can do any number of other things that could be useful with desktop shortcuts, cron, dnotify, reading man pages, and more.
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:
[Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Terminal=false Name[en_US]=festival Exec=festival --tts Name=festival
Remind yourself of the time on the hour with cron:
crontab -e
Enter the following into the file:
0 * * * * username ~/time.sh
Contents of time.sh:
#!/bin/bash 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!
Related Posts
Tags: Cron, dnotify, Festival, Linux, Text-to-speech, TTS



November 25th, 2007 at 11:18 am
[...] Teach Linux to talk Filed under: Linux — 0ddn1x @ 2007-11-25 16:18:42 +0000 http://www.hackosis.com/index.php/2007/11/24/transform-linux-into-a-talking-companion/ [...]
November 26th, 2007 at 2:23 am
[...] Transform Linux into a Talking Companion (tags: linux free-software howto) [...]
November 26th, 2007 at 3:00 pm
and if you install http://cmusphinx.sourceforge.net/html/cmusphinx.php
it might understand you too :), have not tried it though.
November 26th, 2007 at 4:24 pm
Thanx for the heads up egron. I will definetely check it out. ;)
November 26th, 2007 at 5:12 pm
aaaaahhhhhhh, i took your advice and made myself a readit.desktop, but now how do i get it to shut the hell up!!! i closed festival using the system monitor but it just keeps talking!!
November 26th, 2007 at 7:40 pm
[...] Transform Linux into a Talking Companion | Hackosis (tags: linux interesting howto toread free-software text-to-speech) [...]
November 26th, 2007 at 7:53 pm
I get an error when executing this:
echo “My talking Linux PC efin rocks” | festival –tts
Linux: can’t open /dev/dsp
Any ideas?
November 26th, 2007 at 11:51 pm
Sorry, this is not a technical support blog. Please understand.
Look here for more tips:
http://ubuntuforums.org/showthread.php?t=171182
November 27th, 2007 at 10:53 am
I was trying to figure out how to disable reading of special characters..haven’t come up with anything yet. Let me know if you have any tips.
November 28th, 2007 at 6:01 pm
To spedoinkle
$ pkill readit.desktop
It happened the same thing to me hahah. It was funny
November 29th, 2007 at 4:34 pm
Do you know of any ubuntu/linux or even free/open source windows software to do the opposite. i.e. You talk into the microphone and text comes out the other end?
November 29th, 2007 at 9:06 pm
Like egron stated above, Sphinx will for Linux, not sure of the complexity level, I have not tried it out yet.
http://cmusphinx.sourceforge.net/html/cmusphinx.php
November 29th, 2007 at 10:13 pm
Shane:
about the disabling of special characters, you can always run the input through sumthing like “sed” before sending it to festival like
$ cat file|sed ’s/[^a-zA-Z .,!?]//g’|festival -tts
would remove everything except a-z,A-Z, space, “,”,”.”,”!”,”?”.
cheers ps
November 30th, 2007 at 5:37 pm
@Alp,
You forgot a second “-”. The command would be:
echo “My talking Linux PC efin rocks” | festival –tts
November 30th, 2007 at 8:46 pm
@Cheater, as you can see the HTML automatically renders “- -” (without the space) as –
@ps, That acually produces some really weird results, it acually says all of the spaces and dots. I will look into sed, I didn’t know about that. Thanks for the tip.
November 30th, 2007 at 10:56 pm
Hi…Thanks for the nice read, keep up the interesting posts about charles moran..what a nice Friday .
December 1st, 2007 at 11:14 pm
No, no, no. What you do is install this on a machine in the middle of the office, then ssh into it and freak everybody out.
December 4th, 2007 at 3:50 am
This is awesome, thanks for the ideas. :) I’ve got some ideas to try out tomorrow. With festival and PulseAudio, I’m going to broadcast important announcements from my router to the rest of my network. mdadm alerts, internet connection going down, reboots, whatever. It’s hard to miss an alert when the TV, the laptop, and the office computer all say “/dev/md0 is running in a degraded state!”
December 4th, 2007 at 5:15 am
Well, it seems text-to-speech hasn’t got any better sounding since my BBC micro in 1984.
December 6th, 2007 at 3:56 pm
[...] Festival (text-to-speech engine) [...]
December 6th, 2007 at 4:18 pm
yeah, isn’t there any other nice voices out there? i am kinda bored with this guy…
December 8th, 2007 at 2:27 pm
Thanks for the post. I took your idea about the cron saying what time it is and also added a feature to say what the outside temperature is. Yeah I know that’s useless! All the details on my blog.
http://eric.legallais.ca/blog/?p=48
December 8th, 2007 at 5:06 pm
doesn’t sound useless to me, nice work Eric. ;)
December 22nd, 2007 at 6:01 pm
[...] have prepared the document in Mp3 audio format via festival — download it [...]
December 22nd, 2007 at 11:34 pm
[...] you haven’t already, check out the Transform Linux into a Talking Companion post to learn how to install and use [...]
December 23rd, 2007 at 1:42 am
thanks for sharing it
you will also get in mine just search
jasmine
tech-chek.blogspot.com
January 2nd, 2008 at 11:34 am
@Alp,
To avoid the /dev/dsp issue (and infact, to use this system at all while music is playing), add the following to your ~/.festivalrc file:
;make festival use ALSA output:
(Parameter.set ‘Audio_Method ‘Audio_Command)
(Parameter.set ‘Audio_Command “aplay -q -c 1 -t raw -f s16 -r $SR $FILE”)
Thanks to the guys at the Gentoo doc wiki:
http://gentoo-wiki.com/HOWTO_speechd
January 2nd, 2008 at 1:19 pm
Hey Navaburo.
Thanks for the tip and welcome to Hackosis.
January 3rd, 2008 at 3:08 am
Nice tip. I had played with this briefly a while back. I think I’m ready to actually start putting it to use. I normally do something like “sleep 10m && mplayer -loop 0 /usr/share/sounds/KDE_Event_2.ogg” to remind myself the pizza will be done in 10 minutes. I look forward to seeing the reaction from my friends when, instead of a friendly little chime, they here, “The pizza is ready” in a monotone voice.
March 27th, 2008 at 11:19 pm
@contrast
If you order your pizza from Dominos, you could get real time status updates as it is being made, like in this python script.
March 31st, 2008 at 7:13 am
Chris. Thanks for the heads up! Neat script.
March 31st, 2008 at 7:50 am
[...] to Chris for the heads up! And pizza thumbnail via jetalone. Tags: Linux, Monitoring, Pizza, [...]