Just a quick note on Speech Synthesis a Raspberry Pi project. I had to research some of the options on the Raspberry Pi while looking into a project where I need some audio announcements.

Configuring Sound

echo 'snd-bcm2835' >> /etc/modules
sudo modprobe snd-bcm2835

sudo apt-get install mplayer alsa-base alsa-utils pulseaudio mpg123
# make mplayer use mpg123 codec instead of default ffmp3float
echo "afm=mp3lib" >> ~/.mplayer/config

Since I am using Raspbian which is a Debian based (Wheezy) Distribution I used some Ubuntu documentation (https://help.ubuntu.com/community/TextToSpeech) as the starting point.

Festival

sudo apt-get install festival festival-english
echo "Hello World - Testing" | festival --tts

Plus: Local install (no internet connection required)
Minus: Mechanical sounding voice

Espeak

sudo apt-get install espeak
espeak -v en "Hello World - Testing"

Plus: Local install (no internet connection required)
Minus: Mechanical sounding voice (slightly better than Festival)

Google Translate

Create a shell script tts.sh
#!/bin/bash
mplayer -ao alsa -noconsolecontrols "http://translate.google.com/translate_tts?tl=en&q=$*" > /dev/null 2>&1

chmot +x tts.sh
./tts.sh "Hello World - Testing"

Plus: needs live internet connection
Minus: excellent human sounding voice

Google Speech API

I will most likely look at this in the long run to get better control rather than calling the Google Translate url too much.

Leo Gaggl

ict business owner specialising in mobile learning systems. interests: sustainability, internet of things, ict for development, open innovation, agriculture

This Post Has 3 Comments

  1. Gary Hayman

    Is there a way to use unicode text and have the Google Translate API do an auto detect of the language?

  2. Debra

    Hello Gary,

    I’m not sure if you can do that with Google Translate API, but I just tried and iSpeech Text to Speech API provides that feature, check it out:
    http://www.ispeech.org/text.to.speech
    You can easily implement it in the raspberry too.
    You

  3. Steve Z

    I tried the google translate script tts.sh today but it does not seem to work for. Did Google Translate change things around again?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.