Flite (festival-lite) is a small, fast open source text to speech synthesis engine developed at CMU and primarily designed for small embedded machines and/or large servers. Flite is designed as an alternative text to speech synthesis engine to Festival for voices built using the FestVox suite of voice building tools.

While flite can be installed using the usual 'apt-get install flite' the current version will not work on Raspberry Pi's as of April 2019. The package was built without support for alsa which is required for Raspberry Pi. We will walk you through building your own version from scratch along with a few example commands for usage. You can replace festival in our code examples with "flite" should you need a faster more flexible program.

Building Flite

Method 1:

There should be a package available. At the command line:

sudo apt install flite

And try the Reading Text section if it appears to work. If this method doesn't work, try the following to get the source and install it:

Method 2:

Move to the Downloads folder and install the necessary libasound2-dev package that flite requires:

cd ~/Downloads
sudo apt-get install libasound2-dev

Next we will grab the latest version of the flite "tarball".

wget http://www.festvox.org/flite/packed/flite-2.1/flite-2.1-release.tar.bz2

Now we can uncompress the files, change into the new source code directory and start the configure process. 

tar -xvf flite-2.1-release.tar.bz2
cd flite-2.1-release
./configure --with-audio=alsa --with-vox=awb

It will take several minutes to compile the source even on todays fastest Raspberry Pi B+. We will use the make command command to start the compilation.

Once the make command has completed without errors we can install the files using the following command:

sudo make install

Reading Text

You are now set to try it out.  For simple text, use text after the -t flag:

flite -t "All good men come to the aid of the rebellion"

and you can have flite speak the contents of a file with -f

flite -f Thomas_Jefferson.txt

Sounds pretty good, eh?

You are not limited to the default voice.  If you type:

flite -lv

you get a list of available voices like this:

To use a different voice, use the -voice flag followed by one of the voices in the listing

flite -voice awb -t "The Raspberry Pi is a great Maker platform!"

If you would like one of the voices listed but not installed by default, they can be downloaded from the Flite website.

There is a large selection of voices to choose from in the download area of the Flite website

WAV File Output

If you have only a fixed set of phrases, it might be better to have the sentences in an audio file instead of generating them every time you want them spoken.  Fortunately Flite will save its voice to a wav file (a standard sound file format):

flite -t "Shall we play a game?" -o wargames1.wav
flite -t "Lets play global thermonuclear war." -o wargames2.wav

You can then use a number of Linux programs to output the text file when you need to.  aplay is one such program already on the Raspberry Pi:

aplay wargames1.wav
aplay wargames2.wav

You can even copy these wav files to your PC/Mac or Arduino wave shield SD card and play the voices on other equipment.

This guide was first published on Feb 01, 2016. It was last updated on Jan 18, 2016.

This page (Bonus : Speak Easier: Flite) was last updated on Jan 19, 2016.

Text editor powered by tinymce.