How to get your Raspberry Pi to Talk
This short post is a long overdue update on giving the Raspberry Pi a voice with Espeak, the light weight yet powerful TTS (text to speech) program using its python library on the Raspbian Stretch or Buster operating systems.
So if your just getting started or you’ve recently updated your system and are going crazy because your pi’s giving you the silent treatment, read on!
For the longest time, I’ve wanted a companion a.i. much like jarvis (or any other sci-fi computer for that matter) that is able to Speak its data and Listen to my requests and maybe get it to one day “feel” on a limited scale. In this post we will begin to execute that goal starting by granting your pi the power of speech.
The bare bones setup for what we need to get this going is thankfully minimal. Typically requiring only your standard pi set up to get up and running.
-The Raspberry pi. My “anything goes” computer of choice. So far, I’ve tested this on the 3b, 3b+ and the zero(w).
(For more accessory options to give you ideas to optimize your pi for any given project such as portable batteries and power switches, refer to my post on Pi Upgrades)
Using the audio from a tv works just fine but if you’re thinking of going portable, you’d probably want to look into a speaker of some kind.
My voice of choice: The Altec Lansing USB lite speaker. Not quite as small as I’d like and its volume definitely suffers outdoors but it’s a marvelous option for an independent indoor set up or a wearable device.
You could also use headphones and bluetooth speakers work great as well depending on your intentions but i chose a usb speaker option because i wanted more portability and wasn’t crazy about the idea of having to charge another gadget.
Audio Output Settings
To be sure your appropriate audio option is being used hdmi, bluetooth, usb etc, right click your speaker option on your desktop screen and select your option (Took me like 2 hours to figure that out lol). For my usb speaker, I select ‘Audio Advantage Microll‘.
Fun with Espeak
Espeak is probably the quickest, cleanest way to imbue your Raspberry Pi with a voice. It works out of the box and is very easy to apply to your scripts.
Espeak’s compact and contains many built in options for accents and languages for only 2 mb making it a painless install as well as considerate to your disk space.
To install Espeak, go to the terminal and first update your system:
$ sudo apt-get update
$ sudo apt-get -y upgrade
$ sudo apt-get -y dist-upgrade
Next we install espeak:
$ sudo apt install python3-espeak speech-dispatcher-espeak
Once installed, My good ol’ Githubs got a handy simple start script for using some of the built in voice options. And it should come out like this when you run the program:
(As a side note, phonetics and pronunciation adjust based on the punctuation of your inputted strings).
What i truly love is Espeaks straight forward usability and it’s hefty built in custom options like accent, talk speed and voice pitch. Not to mention its Deeper customization options such as breath, gender and tone, you’d have a high, near intimate degree of control over your pis voice.
And with all those accents and language options, one can realistically apply them to create a translator. And with espeaks ability to save voice output to wav file, you can design a Logger. It really opens a lot of doors for the pi and for the imagination. 🙂
If you’re not crazy about the default voice which can sound robotic at times, you can experiment with the Mbrola voices which are an alternative way to synthesize speech using Espeak as a front end.
Here’s my simple start Mbrola script. When ran, it should sound like this:
The Mbrola voices use their own set of customization options and can sound more natural than the standard voice set with enough modification. Here’s a list of some Mbrola voice options to help you experiment.
And thats pretty much it! At this point, your Raspberry pi should be talking up a storm and wide open for new directions to take your ideas! Stay tuned for part 2 where we’ll take the next step with Speech Recognition which will give our Pi an “ear” to be able to listen, interpret and operate under voice commands.
Please like, share and consider a donation or show support by buying some Sanitizer if you found this post useful. Your gratitude aids and abets my tech obsession and helps me get more gadgets to research so i can share more knowledge with the world. Thank you for finding me. Cheers! 🙂