Some advanced projects with Raspberry Pi can foresee also the use of voice controls. While these projects are not simple to setup (I’m scheduling some tests in the very next future), giving a microphone to your RPI can be a very simple operation. A very interesting project, in this sense, is the Google home assistant project.
Remember that Raspberry Pi doesn’t come with a built-in audio device. A very cheap solution is the use of some USB microphones which can be found on-line, costing a few dollars.
Installing USB microphone from a terminal is simple and is the only way if you don’t have a desktop environment installed.
In this tutorial I’m going to show you how to setup an USB microphone with a Raspberry Pi 3 A+, but the procedure is the same for all recent Raspberry PI models.
What We Need
We’ll use an SSH session to connect our Raspberry Pi, so no USB keyboards or video cables are needed.
As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if continue with the project or remove them from the shopping cart. So, hardware will be only:
- Raspberry PI (including proper power supply or using a smartphone micro usb charger with at least 3A)
- high speed micro SD card (at least 16 GB, at least class 10)
- An USB mini microphone
Check hardware prices with following links:
Once OS is installed and the USB Microphone is plugged in, check the USB device connection:
this will show the following output:
Bus 001 Device 001 is the phisical hub inside RPI board, while Bus 001 Device 002 is my USB microphone. With RPI model B this could show 5 devices, being Raspberry PI model B equipped with 4 USB ports (+ internal hub).
Let’s check the list of audio input devices with the following:
this output should be shown:
So, my microphone matches with card 1 / device 0. This will be mapped in the following with plughw:1,0.
Now, we can test a simple recording by typing:
arecord -D plughw:1,0 -d 3 test.wav
The following output will appear:
Now you can simple check this file by connecting and downloading it with your favourite FTP software (for example Filezilla) to your RPI with ad SFTP connection (using your RPI user and password, pi and raspberry if you left the factory ones).
Recording volume can be very low in some cases. Alsamixer helps us with a simple interface to manage audio devices volumes. Type in your terminal:
You’ll see the default console:
Now, you have to switch to the correct audio device by pressing F6:
In my case, the correct sound card is the one marked as bcm2835 ALSA:
Use up / down arrow keys to regulate at your choice. Press ESC to save and exit. Test againg.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?