Start by making sure you've installed I2C support, see the previous page (Blinka Setup) on how to do it!

Install Voicecard software

Make sure you've got the BrainCraft HAT or Voice Bonnet installed, and I2C support installed as well!

When you run sudo i2cdetect -y 1

you should see an entry under 1A, indicating the hardware sees the audio card. The number may also appear as UU if you already installed software

At the command line run:

cd ~
sudo apt-get install -y git
git clone
cd seeed-voicecard

Depending on your kernel version, you may need to change your branch. You can check your kernel version by typing uname -r.

If your have a more recent kernel version of 5.10 or higher, use the following:

git checkout v5.9
sudo ./

If your running an older kernel version around 5.4, use the following:

git checkout v5.5
sudo ./

At the end you should see something like this:

Reboot with

sudo reboot

and on reboot run

sudo aplay -l

To list all sound cards, you should see it at the bottom

On a Raspberry Pi 4, your card number may be Card 2 instead of 1 because of the second HDMI port. You'll need to make some changes to some of the commands to reflect this further down.

If your card number differs from the above image, take note of your number.

You can use alsamixer to adjust the volume, dont forget to select the card with F6

A gain of about 60% is plenty loud!

Headphone/Speaker Test

Make sure the Audio On/Off switch is set to ON!

With either headphones plugged into the headphone jack or a speaker attached to the speaker port, run

speaker-test -c2

you will hear white noise coming out of the speakers/headphones!

If you don't hear anything, make sure you have the audio on/off switch set!

Microphone Test

There are two microphones, and now we can test that they work. This test is best done with headphones, not using the speaker port, because it can cause a painful feedback effect if the speakers are next to the mics!


sudo arecord -f cd -Dhw:2 | aplay -Dhw:2

If your sound card ID is not #2, then replace the number in both of the -Dhw: parameters with your actual number.

Then either gently rub each microphone, or speak to hear yourself echoed!

Control-C to quit when done

Your audio subsystem is now completely tested!

Python Libraries

The Microphone and Voice Card are installed as Linux level devices, so using them in is done as you would with any system level audio device. If you would like to make use of audio in Python, you can use the PyAudio library. To install pyaudio and its dependencies, run the following code:

sudo apt-get install libportaudio2 portaudio19-dev
sudo pip3 install pyaudio

Python Usage

Here is a basic test script to enumerate the devices and record for 10 seconds. When prompted, choose the device called seeed-2mic-voicecard.

Copy and paste the following code into a file called

import pyaudio
import wave

FORMAT = pyaudio.paInt16
CHANNELS = 1           # Number of channels
BITRATE = 44100        # Audio Bitrate
CHUNK_SIZE = 512       # Chunk size to 
RECORDING_LENGTH = 10  # Recording Length in seconds
WAVE_OUTPUT_FILENAME = "myrecording.wav"
audio = pyaudio.PyAudio()

info = audio.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
    if (audio.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
        print("Input Device id ", i, " - ", audio.get_device_info_by_host_api_device_index(0, i).get('name'))

print("Which Input Device would you like to use?")
device_id = int(input()) # Choose a device
print("Recording using Input Device ID "+str(device_id))

stream =
    input_device_index = device_id,

recording_frames = []

    data =


waveFile =, 'wb')

Run the code with the following command:

sudo python3

When finished, you can test playing back the file with the following command:

aplay recordedFile.wav

This guide was first published on Oct 06, 2020. It was last updated on Sep 16, 2020.

This page (Audio Setup) was last updated on Sep 16, 2020.

Text editor powered by tinymce.