Using a Raspberry Pi as a Realtime Voice Changer for Halloween

As most readers know, I’ve been working on my magic staff project for the last year and a half. I incorporated into the ‘Technomancer’ costume for Halloween and Arisia last year, and it was a big hit. I’m continuing to expand the costume, and one thing I’ve always wanted was a voice changer that would let me have a nice sepulchral voice to go with the creepy visage. My own voice from behind the mask is extremely muted, so it’s hard to carry on conversations or even talk to someone, so some external hookup was needed.

My 'bench' test run of the Pi with external USB sound board.
My ‘bench’ test run of the Pi with external USB sound board.

What surprised me was… no one had done this. I searched all over the web for realtime voice processing setups using a Raspberry Pi or Arduino, and while some folks had come close, no one (that I found) had put all the pieces together. So, it was time to do it!

The first component is naturally a Raspberry Pi. I used the pretty awesome CanaKit, which included lots of goodies (most importantly a good, solid case for the board, as well as a microSD card and other accessories). $69 was a great price.

Next, the Pi has onboard audio, but… well, it sucks. I needed separate mic input and outputs, and off-CPU sound processing. Fortunately, there’s huge numbers of these USB sound adapters going for less than $10 a pop. I got 2 just to be careful.

Pyle Audio portable PA
Pyle Audio portable PA

Next, I needed an amplifier. Something portable, loud, and with a remote microphone. This is one just for my setup. Obviously whatever you choose for your own project, pick whatever audio options you’d like. THe sound adapter has standard 1/8th” jacks for mic in and audio out, so just plug right in (I had a small problem with my Mic connection, in that the mic cable I used needed to be ‘out’ a quarter inch to connect properly. I used a small O-ring to keep the spacing proper). The amp I used is Pyle Pro PWMA50B ‘portable PA system’. At $29, it’s well worth it. Comes with a mic, built in rechargeable batteries, a belt mount, and, most importantly, an Auxiliary input.

Now comes the hard part. Getting the audio set up so it could handle recording and playing back in realtime required installing the ‘sox’, toolset, as well as all the alsa tools (most of ALSA comes with the Pi, but make sure they’re there). First, make sure you can play audio through the USB card to the PA. I used ‘aplay’ for this (this ALSA simple player), and a small WAV file I had lying around.

I also recommend running ‘alsamixer’ beforehand, to make sure you can see all the devices, and they’re not muted. ‘aplay -l’ and ‘arecord -l’ are handy in making sure you’re seeing everything you need.

Assuming you have working audio, now comes the fun part. Set up a sox pipe to read from the default audio device and write to the default audio device. Like this:

play "|rec -d"

If all goes well, you should be able to speak into the microphone, and have it come out the speaker. There will almost certainly be a delay of anywhere from a tenth to a half a second. There’s ways to mitigate that, but we’ll get to that in a minute.

If you have that path working, you’re 90% of the way done!

For my costume, I needed a deep voice, so I added -pitch -300 like this

play "|rec -d pitch -300"

I also had a problem with a very high pitched whine coming through the speakers, so I added a band filter to remove that (this syntax means “Remove sound centered on 1.2khz, with a bandwidth of 1.5khz on either side”) :

play "|rec -d pitch -300 band 1.2k 1.5k"

Only a little more tweaking, adding some echos, and I had the voice I wanted. The –buffer command shortens how much data is buffered for processing. This helped cut down the delay a bit, but runs the risk of buffer overruns if you talk a lot.

play "|rec --buffer 2048 -d pitch -300 echos 0.8 0.88 100 0.6 150 .5 band 1.2k 1.5k"

Here’s a sound sample of what it sounded like. Note this is before I added in the band filter, so you can hear the whine…
(direct link here)

The last thing needed was to have the changer start up when the pi reboots. I’m planning on carrying the Pi in a pouch on my belt, powered via one of those cell phone external battery packs. I can’t log in and start the tool whenever it boots. The fix is to put the ‘play’ and other amixer commands into a simple shell script (I put it in /root/, and using the @reboot entry that the Pi’s version of Linux supports, add this line to root’s crontab:

@reboot sh /root/ > /root/sound.log 2>&1

Rebooting now works without a monitor and keyboard attached, and the sound processor starts right up. Ready to go!

Leave a comment if you have any questions, this post will be updated as I continue work on the system…


A wandering geek. Toys, shiny things, pursuits and distractions.

View all posts by

17 thoughts on “Using a Raspberry Pi as a Realtime Voice Changer for Halloween

    1. Hi Matt, sorry for the long delay getting back to you. “play” is part of hte ‘sox’ package, so do an apt-get install sox and you should get th e’play’ binary. Good luck!

  1. Hello Dave, I am a design student and I was wondering if you think this would work, but instead of changing the pitch of your voice, adding something that can change your voice, such as make it sound as a robot, helium voice, etc..
    Any info you could give is useful! Thanks

  2. Thanks for this, really helpful 🙂 I would like to record audio to a file while also playing it through the speaker. How would I do this? I basically want to do these two things at the same time:
    play “|rec -d”
    rec myfile.wav

  3. Could you please explain in more detail about scripting your command for those of us who aren’t familiar with creating shell scripts.

    1. A shell script is just a bunch of commands that you’d normally put ont he command line into a script. In the post I mention ‘’ – just put the commands you’d use from the command line into and make it executable (chmod +x Then you can run the script by typing ‘./’ (or wherever you end up putting it). The article also has a link on how to set up to have the script automatically start on reboot. If you have a specific question, I’d be happy to answer!

  4. Could you explain the coding part? I’m more of an arduino and c++ programmer and have no idea how linux works (especially on something like Raspberry PI).

  5. I successfully got this technique to work on a Pi Zero W. This makes it more viable for a costume simply due to the size and slightly better power consumption. The main issue I had was that if the original voice is audible it can spoil the effect given the delay on the output.

    Apart from the cost of an amplified speaker it’s a fairly easy project to just try out regardless. I had trouble with the USB audio adapter as the mic only worked if it wasn’t pushed all the way into the mic socket but it only cost £2/$3 so can’t really complain.

    1. Matt, glad you got it working! You’re right that the delay can cause some awkwardness. For the costume I built, my ‘original’ voice was heavily masked and mnuffled, so you couldn’t hear it at all, so all anyone could hear was what was coming from the speaker. The Pi Zero is definitely the better approach now, since it’s so much smaller. Thanks for checking in!

Leave a Reply

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