Using Voice RSS to make a Raspberry Pi talk

Using Voice RSS to Make a Raspberry Pi Talk

With this post I would like to introduce a simple to run, text-to-speech (TTS) system for the Raspberry Pi. Yes, you type it and it gets spoken! – using Voice RSS to make a Raspberry Pi talk.

The basic idea behind TTS is to give your system output in the form of sentences which can then be used as a vocal output to communicate instead of displaying it on a screen. Much more fun right?

The instructions on this post will enable you to use the tts command in the form of tts "Hello, world." and it will be spoken to you.


I was experimenting with some TTS software packages and a time ago came across Steven Hickson’s PiAUISuite. It used Google Speech to take basic vocal commands through a microphone, runs basic logic which can give output in various forms – speech being one of them. Sadly most of this functionality has ceased since Google stopped/changed? – who knows? – their STT and TTS services around November 2015.

I’ve also experimented with other systems like eSpeak which is very easy to set up, does not need an active connection to the internet and has an overall okay but decent output. The original PiAUISuite was still better.

Since I had PiAUISuite installed on a few Raspberry Pis, I thought to take its ‘tts’ command and show how to tweak it a little to at least have a good TTS ability — we will be using Voice RSS for this.


Apart from some additional Linux packages which we will be installing during this post, you’ll obviously need a fully installed Raspberry Pi with Raspbian. You will also need to be on a local network, an internet connection and if you don’t have a screen, keyboard and mouse you will need PuTTY and/or WinSCP to do the testing and coding.

A basic, free Voice RSS account — you will be able to do up to 350 requests per day.

Superuser permissions in order to do some editing.

Very Important: I haven’t written anything about the sound on the Raspberry Pi yet, but you will need sound (ALSA at least). The newest Raspberry Pi 2 has HDMI and a 3.5 mm audio jack which can be used for sound. By default, Rasbian should have most things installed for ALSA to work.


Although not always a limitation per se, this system is mainly controlled from running terminal commands. It is actually great for Python and Bash scripts. Like mentioned above, a free Voice RSS account will only give you a maximum of 350 requests per day.

A modified version of PiAUISuite

PiAUISuite will install a nifty command called ‘tts. This is what we’ll be using after some modification. Start by installing some packages and then PiAUISuite from Github by typing the following on your terminal from a freshly booted Raspbian:

sudo apt-get install git
sudo apt-get install mpg123
git clone
cd PiAUISuite/Install
cd /home/pi

Say yes to install the dependencies – so initially you’ll be saying yes twice. Afterwards, PiAUISuite will one by one try to install and set up playvideo, downloader, gvapi, gtextcommand, youtube, youtube-safe and voicecommand. We will only be needing the last one on the list, voicecommand – so say no for installing the rest.

After all the dependencies and voicecommand is installed (which can take a while), the installer will automatically prompt to set up voicecommand. On a fresh install, there will be no commands found and it will ask you to try to set itself up. We won’t be using this, so say no. (You can do this later by using voicecommand -s.

Next, we will be changing some code on the newly created tts file to use Voice RSS’s TTS service instead of Google’s.

To continue we will need a Voice RSS API key, so go and get one.

To edit the original tts file, use the following command from the Raspbian terminal:

sudo nano /usr/bin/tts

to edit the original code from Steven Hickson:


#for the Raspberry Pi, we need to insert some sort of FILLER here since it cuts off the first bit of audio

if [ "$1" == "-l" ] ; then
    string=`echo "$string" | sed -r 's/^.{6}//'`

#empty the original file
echo "" > "/dev/shm/speak.mp3"

while [ $len -ge 100 ] ;
    #lets split this up so that its a maximum of 99 characters

    #now we need to make sure there aren't split words, let's find the last space and the string after it
    lastspace=${tmp##* }

    #here we are shortening the tmp string
    tmplen=`expr 100 - $tmplen`

    #now we concatenate and the string is reconstructed

    #get the first 100 characters
    wget -q -U Mozilla -O "/dev/shm/tmp.mp3" "${lang}&q=$tmp&ie=UTF-8&total=1&idx=0&client=t"
    cat "/dev/shm/tmp.mp3" >> "/dev/shm/speak.mp3"
#this will get the last remnants
wget -q -U Mozilla -O "/dev/shm/tmp.mp3" "${lang}&q=$string&ie=UTF-8&total=1&idx=0&client=t"
cat "/dev/shm/tmp.mp3" >> "/dev/shm/speak.mp3"
#now we finally say the whole thing
cat "/dev/shm/speak.mp3" | mpg123 - 1>>/dev/shm/voice.log 2>>/dev/shm/voice.log

After getting your Voice RSS API, Keven recommended to replace the entire script with the following shorter version:

#for the Raspberry Pi, we need to insert some sort of FILLER here since it cuts off the first bit of audio
if [ "$1" == "-l" ] ; then
    string=`echo "$string" | sed -r 's/^.{6}//'`

#empty the original file
echo "" > "/dev/shm/speak.mp3"

wget -q -U Mozilla -O "/dev/shm/tmp.mp3" "$string&f=22khz_16bit_mono&hl=$lang"
cat "/dev/shm/tmp.mp3" >> "/dev/shm/speak.mp3"
#now we finally say the whole thing
cat "/dev/shm/speak.mp3" | mpg123 - 1>>/dev/shm/voice.log 2>>/dev/shm/voice.log

Simply replace MYAPIKEYGOESHERE with your own and exit (Ctrl + X & y) to save.

The command can now be used from any directory without sudo like so:

tts "Hello, world"

which will convert your text to speech, which can be heard on your default sound card and audio out. Voice RSS allows for up to 10 000 characters per call.

(If you’re having formatting troubles with the code above, just comment and I will get back to you to help.)

You can go through the Voice RSS documentation yourself and see what languages they have available, but I was happy with the quality of the default English voice.

About the author
Renier busies himself with improving his English writing, creative web design and his websites, photoshopping, micro-electronics, multiple genres of music, superhero movies and badass series.
Behind the Scenes is a free, informative website. If you find value in any of our content, please consider making a donation to our cause.
Donate via PayPal

Save, share & discuss

Your comment is important, but don't be a knob. Keep it constructive and polite.

Leave a Reply

Your email address will not be published. Required fields are marked *

More Raspberry Pi related posts