Hardware Reference
In-Depth Information
Uses of TTS
TTS is used when a visual display isn't appropriate. This includes assistive technology for
people with visual impairments or when it is not possible to look at a screen, a satnav or
automatic telephone exchanges.
These applications use TTS because the range of words that can be said is large. If the
computer is required to say just a few hundred different words, then for better quality, an
actor will record the separate words, with the computer forming sentences and playing
back a sequence of clips separated by short pauses. In some applications, there are too
many different words to have a recording of each one, so the computer will generate them
from syllables. In the case of a satnav, it's a lot of work recording the name of every road
and every place. Some words will be frequently used so they may be recorded, and a mix-
ture of synthesized TTS and recorded may be used. You might like to try putting your own
voice in the soft toy by recording a set of words and writing a program that plays them back.
See the “More Ideas section at the end of this chapter.
Install espeak by typing the following in a terminal:
sudo apt-get install espeak
Plug in some speakers and then test that TTS works by typing this in a terminal:
espeak “hello world from espeak”
If you cannot hear sound, you may need to change how audio is routed. The Raspberry Pi can
output sound via the HDMI cable or the audio jack plug. It will try to automatically select the
correct one, but that doesn't always work with some displays. To switch it by hand, type sudo
amixer cset numid=3 n , where n is 0 for automatic, 1 for audio jack and 2 for hdmi.
TIP
Using Espeak in Python
The next step is to call the espeak program from Python. Because you might want other pro-
grams that you write in the future to use espeak, you'll create a module for it. It's worth
studying how the module works because it shows how you can run another program from
Python, which can be very useful. Enter the following code into espeak.py :
 
Search WWH ::




Custom Search