Thursday, January 24, 2013

Text to speech engine

Now we make the raspberry speak. I tried two different text-two-speak engines:
In the end I think espeak is the better choice, because it works more stable and the voice sounds better.
Installing is quite simple:
sudo apt-get install espeak
sudo apt-get install festival
Now for testing:
espeak "hello world"
espeak -f readFile

echo "hello world" | festival --tts
festival --tts readFile
The standard voice is english and male with a speed of 175. You can change that - for example:
espeak -s 150 -v german "hallo welt"
This changes the speed of the voice and sets the language to German.
If you have problems with the audio output, try running the command with sudo.
To check if it is a problem with your audio configuration or just with espeak, try playing a test audio file:
sudo aplay /usr/share/sounds/alsa/Front_Center.wav
Still no audio? Check your mixer settings - you can force an output channel:
sudo amixer cset numid=3 <n>
n=0 auto, n=1 analog, n=2 hdmi

To get the sound over HDMI working with my TV (LG 32LH2000) I also had to change the config.txt file in the boot directory. Add/uncomment the following line and restart the raspberry pi:
Still not working for some reason hmpf? Try loading the sound driver:
sudo modprobe snd_bcm2835

Removing a package
Since the festival package is not needed anymore, we remove it:
sudo apt-get remove --purge festival
sudo apt-get clean


vignesh kalai said...

how to make a text to speech conversion for a .txt or .docx file .. we are on a raspberry pi project so please reply as soon as possible

David said...

It depends which text to speech engine you are using. If you are using espeak just use this command (as mentioned in my blog post):

espeak -f "yourTextFile.txt"

For more information just visit the espeak or festival hompages. Good luck.

jowdjbrown said...

And here we are, we’re standing here, and we’re talking about this shit, and it’s real.speech recognition software