Comparing Text-to-Speech (TTS) Converters available for Raspberry Pi - eSpeak, Festival, Google TTS, Pico and PYTTSX3

Comparing Text-to-Speech (TTS) Converters available for Raspberry Pi - eSpeak, Festival, Google TTS, Pico and PYTTSX3

raspberry pi

ByAshish Choudhary 0

Best Text-to-Speech (TTS) Converter

Text-to-speech (TTS) is a type of speech synthesis program that is used to produce a spoken sound version of the text, such as a document file or a Web page. TTS can make it easier for a visually impaired person to interpret computer display information or can be used to improve the comprehension of a text message. Other than that, it can be used to make your robot speak or can be used in blind stick projects to speak out the written instructions like street name, building name, etc.

There are many free and paid Text-to-Speech applications such as Cepstral and eSpeak. So, in this tutorial, we are going to compare different open-source TTS applications by installing them on Raspberry Pi. Previously, we used TTS to build a Raspberry Pi Based Jarvis themed Speaking Alarm Clock

Components Required for Text to Speech

  • Raspberry Pi with Raspbian Buster installed
  • Speaker
  • Aux Cable

Install Required Packages

Before proceeding with Raspberry Pi Text-to-Speech, we need to install a few audio software packages to get audio output on Raspberry Pi. So, start with updating your Raspbian distribution using the commands given below:

sudo apt-get update
sudo apt-get upgrade

Then install the alsa sound utilities. This package contains various tools to configure audio devices via ALSA (Advanced Linux Sound Architecture).

sudo apt-get install alsa-utils

Then use the command given below to install the MPlayer audio/movie player:

sudo apt-get install mplayer

Note: Don’t forget to select a 3.5 mm jack as audio output. To do this, issue the ‘sudo raspi-config’ command, then go to "System Options", "Audio", "Force 3.5mm ('headphone') jack" and finally "Finish".

Open Source Text-to-Speech Applications

  1. eSpeak Text-to-Speech
  2. Festival Text-to-Speech
  3. Google Text-to-Speech
  4. Pico Text-to-Speech
  5. PYTTSX3

1. eSpeak Text-to-Speech

eSpeak is a compact open-source software speech synthesizer for English and other languages like Linux and Windows. It is a modern and easy-to-use TTS package compared to other open-source packages available. It sounds clearer but does wail a little. Overall, it is a good all-rounder with great customization options.

Use the below command to install eSpeak:

sudo apt-get install espeak

Then test eSpeak with:

espeak “Hello Everyone”

Modifying eSpeak:

Above was a simple example for using eSpeak. You can modify it by changing the voice, volume, speed, accent, and delay between words.

Test eSpeak with: English female voice, emphasis on capitals (-k), speaking slowly (-s) in low volume (-a) using direct text:-

espeak -ven+f2 -k5 -s150 -a 100 -g10 "Hi, Welcome to Circuit Digest Tutorial"

install_espeak_on_raspberrypi

Here:

eSpeak: Launch the eSpeak program

-ven+f2: Indicates the language to use. ‘en’ indicates the English language and f2 is the female voice 2. You can choose between a few different male and female voices :+m1,+m2,+m3,+m4,+m5,+m6,+m7, and +f1,+f2,+f3,+f4.

-s150: Indicates the speed of the sound. Default is 175.

-a 200: Indicates the volume to use of the sound. It ranges from 0 to 200.

-g10: Indicates the pause between words; the “g” stands for “word gap”.

2. Festival Text-to-Speech

Festival is another open-source Text-to-Speech tool. It's developed by The Centre for Speech Technology Research in the UK, it offers a framework for building speech synthesis systems. The Festival currently supports British English, American English, and Spanish. It produces a voice like a rough-sounding robot but still, the sound quality is better than eSpeak.

Use the below command to install Festival:

sudo apt-get install festival

Test the Festival with:

echo “Hi, Welcome to Circuit Digest Tutorial” | festival --tts

install_festival_raspberrypi

3. Google Text to Speech

Google Text to Speech engine doesn’t work offline unlike Festival and eSpeak. It first sends the text to Google’s servers to generate the speech file which is then returned to your Pi and played using MPlayer. Google Text-to-Speech has the best quality sound among all other TTS tools but the only drawback is that it requires an active internet connection.

Create a file speech.sh using the below command:

nano speech.sh

Add these lines to the file and save it using CTRL+X > Y.

#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$*&tl=en"; }
say $*

Then set permissions to your script using the below command:

chmod u+x speech.sh

Test it using:

./speech.sh “Hi, Welcome to Circuit Digest Tutorial”

 

4. Pico Text to Speech

The Pico Text-to-Speech (TTS) service uses the TTS binary from SVOX for producing spoken text. This requires installing the pico TTS library on the system. On Debian, just do sudo apt-get install libttspico-utils. On Debian Buster, the package is missing, but you can download and install the packages manually using the below commands:

wget http://ftp.us.debian.org/debian/pool/non-free/s/svox/libttspico0_1.0+git20130326-9_armhf.deb
wget http://ftp.us.debian.org/debian/pool/non-free/s/svox/libttspico-utils_1.0+git20130326-9_armhf.deb
sudo apt-get install -f ./libttspico0_1.0+git20130326-9_armhf.deb ./libttspico-utils_1.0+git20130326-9_armhf.deb

Test the Pico text-to-speech with:

pico2wave -w lookdave.wav "Hi, Welcome to Circuit Digest Tutorial" && aplay lookdave.wav

Pico TTS currently supports British English, American English, Spanish, Dutch, French, and Italian. The language codes are en-GB, en-US, es-ES, de-DE, fr-FR, and it-IT. The command for speaking the above text in Italian is given below:

pico2wave -l it-IT -w lookdave.wav "Hi, Welcome to Circuit Digest Tutorial" && aplay lookdave.wav

Pico_on_Raspberrypi

 

5. PYTTSX3

pyttsx3 is a text-to-speech conversion library in Python. It works offline and is compatible with both Python 2 and 3. The sound in PYTTSX is not clear and does wail a little. Use the below command to install PYTTSX3:

pip install pyttsx3

Use the below code to test PYTTSX3 with default options

import pyttsx3
engine = pyttsx3.init()
engine.say("Hi, Welcome to Circuit Digest Tutorial")
engine.runAndWait()

PYTTSX_on_Raspberrypi

Conclusion

Listed above are the best 5 open-source text-to-speech applications. As to which TTS application to recommend, Google Text to Speech has the best quality sound but requires an internet connection. In offline TTS packages, Pico TTS gives very good quality and supports multiple languages, Festival also has good sound, eSpeak is easy to use and has good customization options but the sound quality is not good. Hope you found this guide useful. The complete working of this project is demonstrated in the video attached below.

/>

Video

Get Our Weekly Newsletter!

Subscribe below to receive most popular news, articles and DIY projects from Circuit Digest

Comments

Log in or register to post Comment