The Voice

A couple of days back, my kids were watching The Voice.

You probably know it: It’s a singing contest, but the jury can’t see the singers. When they like the song, they press their button to turn around.

My kids were playing jury: They sat backwards in the couch, and only turned when they liked the song.

I liked the idea, but I wanted to give them a real button to press. So I’ve recycled some components from my Timer Button and Wicked Witch project, and used them to build a working Voice button.

Now it’s even more realistic!

And the coding for it is actually quite simple:

from gpiozero import Button
import time
import pygame

#initialize button
button = Button(12)

#initialize sound
pygame.mixer.pre_init(frequency=44100, size=-16, channels=2, buffer=4096)

#Start script: play sound when button is pressed
print ("Start script...")

while True:
        print ("Button pressed! ")"/home/pi/Documents/Programs/TheVoice/VoiceButton.mp3")
        while == True:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s