In this project we will be making an animated face that will move its mouth while the Raspberry Pi is speaking text. This will make it look like the face is actually speaking the words.
We first create sprite variable for both when the face's mouth is open and when its
closed by using led_matrix.LEDSprite()
followed by the location of the .spr files
have been made.
Then just has before in easy we use speaker.say()
to
start speaking, however this time we wait wait=False
because we want the program
to continue executing the next lines of code while the speaker is playing the speech.
Finally, we create a while
loop that will continuously loop until the speech that we just started
playing has finished playing. This loop will continuously open and close the mouth while the speech is playing
by displaying the open and closed mouth sprites one after the other. (Similar to
scrolling text medium)
Try using longer and shorter text.
time.sleep(.1)
.