Voice Recognition Harry Potter Spells

by Kevin_Ciardelli in Circuits > Microcontrollers

501 Views, 1 Favorites, 0 Comments

Voice Recognition Harry Potter Spells

IMG_4766.JPG
IMG_4769.JPG

We have a voice activated harry potter spell involving a Circuit Playground Bluefruit and a Raspberry PI 3 A+. As of now there are two spells programmed in, but it is easy enough to program more or change the ones I have. I primarily use the google cloud voice recognition api alongside bluetooth built into both machines for them to communicate.

Supplies

Raspberry Pi Model 3 A+

Circuit Playground Bluefruit

Acrylic 1/8"

NeoPixel Strip (RGB)

Wood plank 1/8"

8 count of alligator clips

Microphone to usb or adapter for audio port to usb: https://www.amazon.com/gp/product/B07RS11M1T/ref=p...

Speaker with audio

Implementing Code Using Circuitpython

Screen Shot 2022-05-02 at 6.34.27 PM.png

For both the circuit playground and raspberry pi I will be using circuit python and the mu editor.

Link to how to install circuitpython on raspberry pi and cpb:

From there import the necessary libraries from this link for the cpb: https://circuitpython.org/libraries

For the raspberry pi we will need to install: pip3 install pyaudio, sudo apt-get install SpeechRecognition, and sudo apt-get install flac

Code for CPB

To walk you through the code: we first establish a bluetooth connection to the Raspberry Pi and we use the pixels on the CPB as an indicator to show that it is connected. Once connected we continuously get input from the Raspberry Pi through bluetooth. Since the word lumos is of length 5, we fill up the strip when recieved a word of length five, so the limitation of this program is that it can only have one spell per length of word. We then turn on our light strip connected to pin A1 on the CPB to indicate Lumos worked.

Downloads

Raspberry Pi Code

To walk you through this code, once we establish connection via bluetooth, the microphone slot in the Raspberry Pi will start detecting any input and call googles speech recognition api to determine if it's a legitimate word. Based on that we can make a simple if statement to gather that word and then send an audio file or a signal for lights. Included here is the two audio files you have to put into your raspberry pi for audio in a folder named sounds.

Construction of Light Box

IMG_4751.JPG
IMG_4745.JPG
IMG_4767.JPG

We first cut out two 5" by 5" pieces of wood to make a base and roof for the lumos box. Secondly we create a pillar where the neopixel light strip can rest. I constructed a 7" tall pillar out of the same wood with around a 1/2" thickness. If your neopixel strip does not have alligator clips of the end simply solder some to the end for data, ground, and power. These will connect to the cpb. Next We will create for panels of 5"x7"x1/8" acrylic with a lumos design on them by throwing it into a laser printer. On one of the four panels make sure to include a hold where the wires from the light strip can come out of as shown above. Test your connection for gluing anything. If all is good, start hot gluing everything together. After that all u have to do is attach the wires to the correct pins listed before on the playground and you will be good to go!