Adding a USB microphone to your Raspberry Pi can unlock all sorts of new functionality. The most common use for giving your Pi ears is to create a voice assistant such as Alexa or Picroft. But with Python speech-to-text modules such as SpeechRecoginition the fun projects you can take on with a Pi and a mic are endless.
A few summer “camps” ago one of those spectacular projects jumped into my head. I would let the students use their voices to control a robot car! It was going to be a blast!
I already had the cars built. The Raspberry Pis were set up and could pilot the robots around the track with HTTP requests. Now all I needed was some microphones, so I went down to the local superstore and bought some USB microphones that looked like would work.
To see some other things you can make with WiFi-enabled microcontrollers check out my WiFi-controlled LED strip guide or my article on how to make an automated dust extractor.
Table of Contents
- Why didn’t the USB Microphone work with my Raspberry Pi?
- The right quality and sensor for the job
- Foxxray USB Gaming Microphone (with RGB for higher DPS)
- EBooks USB Conference Microphone
- Blue Snowball Ice USB Microphone
Why didn’t the USB Microphone work with my Raspberry Pi?
Getting back to the office, I tore the microphone out of its cardboard and molded-plastic home, hooked it up to a free USB port, and fired up my Python script. I demanded into the mic, “Car, please go forward!” (manners were to be part of my lesson).
The car didn’t move. Looking at the screen, I saw what the Pi heard me say: “Car lease go fore”. That didn’t quite make a match in the script, so I tried again. And again. Finally, on the third attempt, the car lurched forward.
I asked my local co-teacher to come to try. No matter how hard she tried, she couldn’t quite get it. Nothing a little regex can’t fix I said to myself.
When it came to the day of the lesson, the students thought they were controlling the cars with their voices. They didn’t notice the volunteers hovering around with iPads sending the actual commands.
The right quality and sensor for the job
Had I put a little more thought and research into what I wanted to accomplish I might have had better outcomes. Maybe.
The first problem was the quality of the microphone. All the posters on the forums point to the Blue Snowball as the “it-just-works” USB microphone for the Raspberry Pi. But, at that time no store near me in my country carried them, and anyways, I was paying for these mics out of pocket. So I just picked up some mid-range ones (around $20US each).
The second problem is the type of USB microphone I used. Specifically, what kind of pickup pattern should I have chosen for a classroom full of noisy children. I can’t really find any specs for the microphones I bought, but I think most had an omnidirectional pickup pattern:
Omnidirectional. That’s Greek for “picks up all the noise in the classroom.” It turns out that what I wanted was a mic with a cardioid pickup pattern. These mics only pick up sound directly in front of them.
I had a gamer mic that fit the bill. Unfortunately, it is not optimized for the Raspberry Pi.
My friends recently bought a Blue Snowball Ice for their Chinese language learning podcast, Taiwan Feng (shameless plug). The failure of my voice-controlled car lesson always bugged me, so I asked them if I could borrow their Snowball to see how much of a difference it would have made. Results below.
Just a note, the Snowball Ice is a cheaper model of the classic Snowball. The main difference is that the Ice only features the cardioid pickup pattern (perfect for my application). The classic version can switch between three patterns, including omnidirectional, and is probably a better choice if you are building a voice assistant with your Raspberry Pi.
I used a fresh install of Raspberry OS Lite Jammy on a Raspberry Pi 4 4GB updated and upgraded in June 2022. I didn’t install any additional software.
First, I made sure that the microphone was being recognized by typing the following command into the terminal:
If you’re sure if your mic is showing up, unplug it, re-run the command, and check if the length of the list of devices has changed.
Satisfied that the USB microphone was connected and recognized, I then got its card and device numbers with the following command:
Once you get the card and device number, you can record with
arecord and the options
-D plughw: followed by the card and device from the previous command, duration in seconds, and the filename to write out to. My command looked like this (BUT CHANGE YOURS TO MATCH YOUR MIC):
arecord -D plughw:3,0 --duration=10 snowballfan.wav
Here’s what my terminal looked like:
You can also check the gain level on your microphone with:
I recorded four clips for each mic: one with no fan in the room (it’s 33C in this box), one with the fan, one with a clip of a noisy classroom in the background, and one of me making noise with a broken, out-of-tune guitar.
For each clip, I said “Testing, testing, 1, 2, 3” (may be some slight variations) twice: once about a foot away from the mic, and once almost touching the mic.
Here are the results:
Foxxray USB Gaming Microphone (with RGB for higher DPS)
Here’s a clip with a little background noise.
A clip with little background noise:
And noisy background noise coming from my speakers:
And some crappy guitar strumming:
As you can hear, there is a persistent clicking noise in all of the clips. My voice was audible when I was close to the microphone, but the quality wasn’t great.
EBooks USB Conference Microphone
Same as the gaming mic, first a little test with a fan blowing at me.
And without the fan (no real difference in sound at all):
And the same YouTube clip.
And me “jamming” again:
Even when I was very close to the microphone, my voice was barely audible. I used this kind of microphone for most of the stations during my voice car lesson. Oops.
Blue Snowball Ice USB Microphone
Again, no real difference with the fan:
With noise, the volume is about the same as the gaming mic, but there is not clicking sound:
Guitar (not gonna quit my day job:
With alsamixer set to max (the other two mics didn’t have any adjustment available):
My voice was loud and the sound quality was good even with the noisy classroom in the background.
The Blue Snowball Ice was the clear winner of these three USB microphones hooked up to a Raspberry Pi. Even though the extra quality costs double the price, it would have made my lesson much more enjoyable for my students. If I had to do it again (I won’t), I’d shell out the extra bucks.
Check back soon for a write-up of how to make the WiFi car I used and a real-life test controlling it with the Snowball Ice mic.