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!

https://youtu.be/I4BTGUyFCDg

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


About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top