Stay organized with collections
Save and categorize content based on your preferences.
The content on this page is hardware-dependent. Please select from the following:
Before running the sample, you must configure the audio system on the
Raspberry Pi.
Find your recording and playback devices.
Locate your USB microphone in the list of capture hardware devices. Write
down the card number and device number.
arecord -l
Locate your speaker in the list of playback hardware devices. Write down
the card number and device number. Note that the 3.5mm-jack is typically
labeled Analog or bcm2835 ALSA (not bcm2835 IEC958/HDMI).
aplay -l
Create a new file named .asoundrc in the home directory (/home/pi). Make
sure it has the right slave definitions for microphone and speaker; use the
configuration below but replace <card number> and <device number> with
the numbers you wrote down in the previous step. Do this for both pcm.mic
and pcm.speaker.
Press the up arrow key to set the playback volume level to around 70.
Play a test sound (this will be a person speaking). Press Ctrl+C when
done. If you don't hear anything when you run this, check your speaker
connection.
Check the recording by replaying it. If you don't hear anything, you may
need to check the recording volume in alsamixer.
aplay --format=S16_LE --rate=16000 out.raw
If recording and playback are working, then you are done configuring audio.
If not, check that the microphone and speaker are properly connected. If
this is not the issue, then try a different microphone or speaker.
Note that if you have both an HDMI monitor and a 3.5mm jack speaker
connected, you can play audio out of either one. Run the following command:
sudo raspi-config
Go to Advanced options > Audio and select the desired output device.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["The Google Assistant Library for Python is deprecated; use the Google Assistant Service instead."],["This guide provides instructions to configure audio on Raspberry Pi for use with Google Assistant."],["Users need to identify and configure their microphone and speaker devices using provided commands."],["Verify audio setup by testing playback and recording functionalities with given commands."],["Upon successful audio configuration, proceed to configure a developer project and account settings."]]],["The content outlines configuring audio for hardware, specifically on a Raspberry Pi. Key actions include identifying microphone and speaker devices using `arecord -l` and `aplay -l`, and noting their card and device numbers. Then create `.asoundrc` file and update it with specific hardware details. Users then verify audio functionality by adjusting volume using `alsamixer`, testing playback with `speaker-test`, and testing recording using `arecord` and `aplay`. Lastly a command `sudo raspi-config` is suggested to choose the audio output.\n"]]