Let's start using Festival with some command line examples.

First, to test the installation, we will send a simple message to Festival via the Linux/unix echo command via a pipe.  A Pipe can be thought of as receiving the result of the command to the left of it in a command.  You may have seen using a pipe in verbose directory listings by typing "ls -l | more".  The directory output was taken in by the more command to display one page at a time.  So for speaking our first sentence, we'll type:

echo "Hello World!" | festival --tts

You should hear the Pi utter Hello World either over HDMI or the headphone jack. Adjust the volume if you do not hear it at first.  If you have nothing (and no error message), be sure you have plugged in your audio (HDMI cable with audio out or headphones or amplified speaker on the audio jack).  Then be sure you selected that audio output in raspi-config as listed on the previous page.

The Festival command line argument --tts tells the program to treat the input as text to speech.  With no arguments, Festival will put you into its interactive mode which you can exit by pressing the Ctrl key and simultaneously pressing the z key (abbreviated Ctrl-z) if you get stuck.

Typing festival --help gives you a quick listing of commands.  But to get a full feeling of all Festival can do, you can go to the project main page and read up including the extensive manual.

Something more useful is having Festival reading text from a file.  You can have different files for different phrases, and invoke them in a shell script, Python, C or other programming environment.

For example, the text of US President Thomas Jefferson's inaugural address is available free by typing:

wget https://ia800202.us.archive.org/14/items/uspresidentialin04938gut/inagu10m/Thomas_Jefferson.txt

Then you can have festival read the text file by typing the command line. You can interrupt a voice stream by pressing the Ctrl-C key sequence.

festival --tts Thomas_Jefferson.txt

This guide was first published on Feb 01, 2016. It was last updated on May 23, 2024.

This page (Speaking!) was last updated on Mar 08, 2024.

Text editor powered by tinymce.