Trick or Treat Dispenser

Voice-activated treat dispenser.

COVID-19. Novel coronavirus. Social Distancing. Despair. Loneliness. No friends.

It’s the opposite of Halloween.

I love Halloween. One of my favorite holidays of all time, ever since I got to dress up like Gordy from Star Trek (life goals). So, in this time of social distancing and fear of catching the plague, what’s the savior for Halloween, the most blessed days to live your dreams?

Answer: Voice Control!!

And with sound!

How? It was easy. By combining a Matrix Voice with the open source wake word engine from PicoVoice, Porcupine, I was able to get this thing up and running just in time for all the little childrens to come get some candies on 10/31. The best part: It can run offline. Thanks to the on-device processing using Porcupine, it doesn’t need an internet connection to work. Brilliant. Build a lot of these and distribute them around the neighborhood.

The steps:

Train your or grab a model:

Porcupine has a lovely training engine that let me train “trick or treat” optimized for the Raspberry Pi. There are tons of wake word models for Porcupine, so pick your wake word.

Integrate with Matrix Voice:

This one was relatively easy. I followed this example here from the Matrix Voice team(Thanks!). For this, you don’t need the whole Google Assistant, you just need the wake word detection since this is a single function device. My trick_or_treat.py script is just a renamed porcupine.py script without the integration to the main() function. Next year maybe I’ll have a more complicated one and people can ask for specific candies….

Motor control:

I knew this would be the tricky part for me. Ideally, I’d have some kind of gate that would open and let gravity do the rest, but I had a few motors. Still, relatively simple with the standard Raspberry Pi GPIO library. I had a CamJam Robotics kit so I used the motor hat from that. Here we just have two wheels that spin in the same direction, shooting the candy down the tube; similar to a tennis ball launcher.

The remote operation:

Originally, I wanted to do all of this from a single Pi. Totally doable, and in fact, one is overpowered for this kind of work. However, I had a few laying around and had lots of hats, and couldn’t stack them. So I went remote. On the plus side, this means that the listening Pi and the motor Pi don’t need to be anywhere near each other. I found the paramiko library that lets python integrate with an SSH connection, so it was only the mater of remoting into one Pi from another and executing the motor control python script. Easy.

Conclusion:

That’s it! That’s all the steps this needed. Thanks to the open source libraries, it’s also not a lot of code. Feel free to modify. Next year (depending on the world) I might build a more permanent model. Next steps are either doing this on a Microcontroller OR upping the vocabulary and intents to get some more options.

Source: Trick or Treat Dispenser

Scroll to Top
Read previous post:
SENSING-DANGER-WITH-SPINACH
SENSING DANGER WITH SPINACH

Do you need more proof that we’re living in the future? A group of MIT engineers have found a way for...

Close