Raspberry Pi

Make Your Raspberry Pi Speak through eSpeak

Want your Raspberry Pi to speak to you? Try installing eSpeak on it. It’s a lightweight text-to-speech program that can easily be installed on your Raspberry Pi system and help you convert your Pi into a talking robot. It reads the commands and text from a file and speaks in different languages, including English, French, Dutch and more.

This article will show you how you can install eSpeak on a Raspberry Pi system and make your Raspberry Pi speak.

Make Your Raspberry Pi Speak

eSpeak is already available in the default system repository and you can apply the following command to install it on the Raspberry Pi system.

$ sudo apt install espeak -y

 

You can also install the eSpeak Python utility from the following command, as it allows you to import eSpeak in your Python code.

$ sudo apt install python3-espeak -y

 

Once the installation is done, follow the below-given command to make your Raspberry Pi speak:

$ espeak "Text-to-be-heard-from-Raspberry-Pi"

 

If you want your Raspberry Pi to read text from a file, you can use the following command:

$ espeak -f <file_name>

 

Note: You must connect the speaker to your Raspberry Pi device, or you can use Android mobile as your Raspberry Pi speakers by following the guidelines here to listen to the audio played from your Raspberry Pi device.

For different voices selection, you can use the following command:

$ espeak --voices

 

For speaking in the different programming languages, just follow the below-given syntax:

$ espeak "Text-to-be-heard-from-Raspberry-Pi" <language_code>

 
In my case, I am using the Romanian language “ro” as an example.

eSpeak Using Python

You can also make your Raspberry Pi speak from the Python code. For this purpose, you first have to run Python on the Raspberry Pi terminal using the following command:

$ python3

 

Then import the eSpeak library using the following code:

from espeak import espeak

 

Once the library is imported, you can run the following code to make Raspberry Pi speak:

espeak.synth("Text-to-be-heard-from-Raspberry-Pi")

 

Remove eSpeak from Raspberry Pi

You can remove eSpeak, and eSpeak python module from the Raspberry Pi system using the following command:

$ sudo apt remove espeak python3-espeak -y

 

Conclusion

eSpeak is a speech-to-text program that can convert Raspberry Pi into a talking machine. The apt package manager can install the program on Raspberry Pi. After the installation, you must enter the text with the “espeak” command or use the Python code to make Raspberry Pi speak. You can also allow Raspberry Pi to read text from a source file or use different languages for speaking.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.