Script for text to speech


2 posts
by ax206geek » Thu Jun 28, 2012 1:28 pm
8-) A little debian script to get your R-Pi to speak to you:

Sorting out the dependency
Code: Select all
sudo apt-get install mplayer


The script itself:
Code: Select all
#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?tl=en&q=$*"; }
say $*


You probably need to modprobe snd_bcm2835 as well. The R-Pi's speech is output from hdmi so my /boot/config.txt contains this line:
Code: Select all
hdmi_drive=2


A little test
Code: Select all
./speak my raspberry pi speaks to me
Posts: 52
Joined: Sat Jun 16, 2012 2:55 pm
by mikerr » Mon Jul 02, 2012 5:37 pm
Good idea using google's text-to-wave engine, but that will obviously only work if the pi always has internet access.

Festival TextToSpeech worked straightaway for me on debian wheezy:
Code: Select all
apt-get install festival
uses around 20MB on the SD card.
Code: Select all
echo "I'm sorry dave, I'm afraid I can't do that" | festival --tts
Got a Pi Camera? View it in my android app - Raspicam Remote ! No software required on the pi
User avatar
Posts: 1263
Joined: Thu Jan 12, 2012 12:46 pm
Location: NorthWest, UK