-
First iteration: Jasper
03/28/2018 at 00:03 • 0 commentsAs a first step, I set up Jasper on a clean Raspbian install, on a Raspberry Pi, with a few modules. The idea was to see that it all worked, before trying to add the visuals.
Since it was only a proof of concept, I downloaded some animated GIF of a cat and extracted the images and divided it in two parts: the cat moving around, and the cat talking. To animate, I decided to go with Pygame; it's fairly straightforward, and easy to set up, you can see the code in the file, catalk.py.
Next step was to insert the animation into the system. The way Jasper works is:
- wait for the wake word (or button press)
- record speech and transcribe
- send the transcription to a module which returns a text answer
- turn the answer into a sound file
- play the sound file.
My intervention was between the last two, in this fashion: create and start a thread
isTalking = threading.Thread(target=os.system, args=('mpg123 -q {}response.mp3'.format(path),)) isTalking.start()
Animate the cat while the sound is playing
while isTalking.isAlive(): catalk.talkingcat()
That's it! All in all, at that point, it wasn't too difficult (for someone not too used to Python).
Next, we assemble it into a magic mirror.