Hardware Reference
In-Depth Information
his shows that multiple arguments can be passed to a command. he -v en-rp is used to
specify how espeak sounds. It can be fun to play around with diferent pronunciations, or
even languages.
Testing the Espeak module
Now is a good time to check the Python module you've just created. Enter the following into
the ile try_espeak.py :
#!/usr/bin/env python
# try_espeak.py
# Show use of espeak.py
import espeak as talker
def main():
talker.say(“Hello World”)
if __name__ == '__main__':
main()
Run try_espeak.py and check that you hear “Hello World” from the speakers.
Try espeak with different pronunciation options, such as American or caricatures of British
accents such as Northern, West Midlands or Scottish. The codes needed are described in the
espeak documentation at http://espeak.sourceforge.net/languages.html . You
could add another argument to the say function in Python and pass information to set the
accent. If you are really adventurous, you could try passing pitch, speed and voice arguments,
and you'll get some very silly sounding voices.
Making It Move
he next step is to turn on the motors of the toy to make the mouth move while it is speak-
ing. To control the motors, you'll use PiFace Digital. You should have set up PiFace Digital as
speciied in Chapter 9, “Test Your Reactions”. Because there are LEDs on the board, these will
indicate that the outputs are active so you can test the code before connecting the chicken.
Create a new ile named chicken.py and enter the following:
import piface.pfio as pfio
import espeak as talker
VERBOSE_MODE = True
class Chicken():
 
Search WWH ::




Custom Search