The first part of this example has you do a microphone check. I did this, but when I try to play back the recorded wav file (aplay test.wav), there is no sound. I checked and neither the microphone nor the speaker are muted and their volume is turned up. I copied the file to my Mac and it played back just fine there using VLC, so the problem is definitely not the microphone or the wav file. I went back to example 15, rerunning the Piper test, and it speaks so the problem is not the speaker either. I also tried playing back the wav file using VLC on the Raspberry Pi, but that produced no sound either (although it worked on my Mac). Any idea what the problem is?
Please try running the following command to enable the speaker before playing the audio file:
robot_hat enable_speaker
The speaker on the Robot HAT needs to be activated before it will produce sound. This activation is automatically included in our example scripts, so after running any example, the speaker should work even when playing audio files directly.
Thanks, but I still hear nothing when I try to play back test.wav. I again checked that the speaker is not muted and the volume is up to maximum. Also, again I tried this using both aplay and VLC, and it didn’t worth with either on the PiCar-X Raspberry Pi.
Will Windham
Please provide your detailed address and phone number and original order number if possible to get a robot hat via service@sunfounder.com
My address is:
William Windham
1896 Hardin Ln NE
Palm Bay, FL 32905
My cell phone number is 321-745-0043. My original order number is 1000020514. Do I need to send that to service@sunfounder.com?
My address is:
William Windham
1896 Hardin Ln NE
Palm Bay, FL 32905
My cell phone number is 321-745-0043. My original order number is 1000020514.
Let me know if you need any other information.
William Windham
Thank you for providing your address, phone number, and order number.
We have arranged to send you a replacement Robot HAT.
Please note that delivery typically takes 7–14 working days depending on your location and customs processing.
We apologize for the inconvenience and appreciate your patience.
My new Robot HAT arrived yesterday and I just finished installing it. Unfortunately, that didn’t help at all. I still have exactly the same situation. The sound works just fine in examples 13, 14, and 15, but when I try to play back the wave file in example 16, I get nothing. I have verified that file is valid by copying it to an external drive and playing it on my Mac where it plays just fine. I have also used
robot_hat enable_speaker
but still no sound when trying to play back the wave file. I have also run alsamixer again to verify that the robot_hat speaker is selected and that the volume is up and it is not muted.
So what now?
Will Windham
Thank you very much for your patience, and for running all these tests with us.
We’ve now identified the cause of the problem: the Raspberry Pi’s default audio output is HDMI, not the Robot HAT’s sound card snd_rpi_googlevoicehat_soundcar. In Example 16, the command aplay test.wav is used without specifying a device, so it goes to the system default output (HDMI) — that’s why the sound is sent to the wrong output and you hear nothing. Examples 13, 14, and 15 do produce sound because the robot_hat audio library actively enables the Robot HAT speaker.
The fix is simple: right-click the speaker icon in the top-right corner of the desktop and switch the output device to snd_rpi_googlevoicehat_soundcar (the Robot HAT sound card).
Also, we’ve confirmed that the “1. Check Your Microphone” step in Example 16 is actually not necessary, and we will remove it from the tutorial so that other customers don’t run into the same issue as you.
For now, please continue with the next step of the tutorial and test Vosk speech recognition:
Go into the example directory:
cd ~/picar-x/example
Create and edit the test script:
sudo nano test_stt_vosk.py
Copy the Vosk test code from the tutorial into it, then save and exit (Ctrl+O to save, Ctrl+X to exit).
Run the script:
sudo python3 test_stt_vosk.py
Then speak into the microphone and see whether the terminal shows any recognition result.
Please send us the output from the terminal (a screenshot or text is fine). If you can see recognition results, that means the microphone and Vosk pipeline are working, and we’ll continue to the next step. If there is no output or an error appears, please send us the full details and we’ll keep helping you troubleshoot.
I appreciate the quick reply, but there is no device in the list with that name (snd_rpi_googlevoicehat_soundcar) when I click on the Volume control (i.e., speaker) icon in the top right corner. There is, however, one named snd_rpi_hifiberry_dac. Is that the one that you are referring to? I have attached a screen shot of this.
Also, and its a minor point, but the default is AudioAV Jack, not HDMI.
Yes, running test_stt_vosk.py shows that is working. I have also attached a screen shot of that.
Let me know how to proceed.
Will Windham
Thank you for your continued patience. Regarding the snd_rpi_hifiberry_dac you see, we’ve confirmed that this is very likely because the Device Tree Overlay (audio driver configuration) you have loaded is different, which causes the sound card to be recognized as snd_rpi_hifiberry_dac. This is normal — that device is the I2S sound card used by the Robot HAT.
Two options:
Simply select snd_rpi_hifiberry_dac as the output device from the volume icon in the top-right corner of the desktop, then try playing test.wav;
Or run aplay -l in the terminal to confirm whether it shows up as snd_rpi_hifiberry_dac, then play with aplay -D plughw:,0 test.wav (replace with the corresponding number).
Also, since you’ve already verified that both the speaker and microphone work properly, there’s no hardware issue — you can go ahead and continue testing the other examples.
Thank you again for your patience, and please let us know if you have any questions.
Again, thanks for the quick reply.
snd_rpi_hifiberry_dac was already selected as the output device from the volume icon in the top-right corner of the desktop. I verified that the speaker was not muted and the volume was up. However, “aplay test.wav” still produces no sound.
I then tried aplay with the -D option as you suggested, but I got the error message:
wwindham@PICARXRP4:~/picar-x/example $ aplay -D plughw:,0 test.wav
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for
aplay: main:850: audio open error: Invalid argument
I wish that you had given a bit more of an explanation when you said to “replace with the corresponding number”. Replace what with what? In any case, I tried replacing the “0” with a “4” (which is the card number of the sound card -shown farther below) in the command, but I got the same error:
wwindham@PICARXRP4:~/picar-x/example $ aplay -D plughw:,4 test.wav
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for
aplay: main:850: audio open error: Invalid argument
The portion of the output for the speaker of the “aplay -l” command is shown below:
card 4: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [HifiBerry DAC HiFi pcm5102a-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
I would appreciate it if you could give me a better explanation of how to use the “aplay -D” command. The man pages give you almost nothing and there is almost nothing available online as far as examples.
Will Windham
Thank you very much for your patience and for running all these tests — and for sharing every command and error message in such detail. It really helps us narrow this down. I’m sorry this has taken up so much of your time.
Let me start with the conclusion: based on what you’ve described, this is almost certainly an audio output device selection (ALSA configuration) issue rather than a hardware problem. You’ve already replaced the Robot HAT, Examples 13, 14 and 15 all produce sound, and test_stt_vosk.py recognizes your speech correctly — all of which tells us the speaker and microphone themselves are fine.
Let me go through your points one by one:
You see snd_rpi_hifiberry_dac instead of snd_rpi_googlevoicehat_soundcar. This is usually caused by a different audio driver configuration (Device Tree Overlay). It corresponds to the I2S sound card used by the Robot HAT and can be used normally — please just select it as the output device.
You’re right that the default output is Audio AV Jack, not HDMI. Because aplay test.wav doesn’t specify a device, it goes to the system default output, so the sound is sent to the wrong output — that’s why you hear nothing.
About the aplay -D syntax — I apologize that my earlier explanation wasn’t clear enough and made you try several times. After plughw you need to write two numbers: “card,device”. The card number cannot be left blank. Your earlier commands plughw:,0 and plughw:,4 left the card number empty, which is why you got “Cannot get card index for” and “Invalid argument”.
Please follow these steps:
Step 1 — First confirm the card and device numbers:
aplay -l
From the output you posted, the Robot HAT sound card is card 4, device 0, so the correct playback command is:
aplay -D plughw:4,0 test.wav
If aplay -l shows a different card number, replace the 4 with the actual card number shown; the device number is normally 0.
Step 2 — If there’s still no sound, click the volume (speaker) icon in the top-right corner of the desktop, select snd_rpi_hifiberry_dac as the output device, make sure it isn’t muted and the volume is turned up, then run:
aplay -D plughw:4,0 test.wav
Step 3 — The “1. Check Your Microphone” step in Example 16, which plays back the wav file, is not actually necessary. You can skip it for now and continue with the Vosk speech recognition part. Since you’ve confirmed test_stt_vosk.py works, the microphone and Vosk pipeline are working, and you can move on to the next steps.
If there is still no sound after the steps above, please send us the following so we can keep troubleshooting:
The full output of aplay -l;
The full terminal output after running aplay -D plughw:4,0 test.wav;
A screenshot of the output device list from the volume icon on the desktop.
If convenient, please upload the screenshots or logs to Google Drive (or another cloud drive) and send us the share link. Please also set the link permission to “Anyone with the link can view” in the cloud drive — otherwise we won’t be able to open them.
Thank you again for your patience and cooperation.
Thanks, but still no sound with the aplay command. Accessing Google Drive is not convenient, so I have just attached the two files with the data that you requested. Note that the card number came up as card 3 this time, so I adjusted the aplay command accordingly (shown in the attached text file). Also note that snd_rpi_hifiberry_dac is selected in the attached photo.
And just to mention, I tried running the aplay command again after running
robot_hat enable_speaker
but there was still no sound output.
Will Windham
(Attachment Debug.txt is missing)
Thanks, but still no sound with the aplay command. I have attached a file with the first part of the data that you requested. Note that the card number came up as card 3 this time, so I adjusted the aplay command accordingly (shown in the attached text file).
Accessing Google Drive is not convenient so I will just describe what is shown when I right click on the speaker icon:
It shows:
AV Jack
HDMI
snd_rpi_hifiberry_dac
(Attachment Debug.txt is missing)
Not that it gives you any more information, but I have put the screen shot in Google Drive. The link is:
https://drive.google.com/file/d/1a-2OPXn07h6lsDCCRP9EgOzEIKPhwlYp/view?usp=sharing
Will windham
I just discovered that it was the text file that caused the problem. It’s hard to believe you can’t accept text files (i.e., .txt). Anyway, here is the information from the file that I attempted to send.
wwindham@PICARXRP4:~/picar-x/example $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 3: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [HifiBerry DAC HiFi pcm5102a-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
wwindham@PICARXRP4:~/picar-x/example $ aplay -D plughw:3,0 test.wav
Playing WAVE ‘test.wav’ : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
Great to hear it’s solved! Playing with aplay -D plughw:3,0 test.wav (card 3: snd_rpi_hifiberry_dac) works, which confirms the speaker, microphone, wav file, and Vosk recognition are all fine — the earlier silence was just because the correct output device wasn’t specified.
Thanks for your patience, and enjoy your PiCar-X!
You seem to have misunderstood. When I said that it was the text file that caused the problem in my last message, I was referring to the problem with sending data to you, not the problem with playing sound. What I said was that it still produces no sound when played with aplay -D plughw:3,0 test.wav. The problem still is not solved.
Thank you for all the information you’ve provided. Before we continue troubleshooting the audio output, we’d like to clarify one important point about Lesson 16 and make sure we correctly understand the problem you’re experiencing.
Lesson 16, “Voice Controlled Car with Vosk (Offline),” uses the PiCar-X microphone to capture your voice and Vosk to convert that speech into text. The recognized commands are then used to control the car.
The lesson itself does not normally play the recorded WAV audio back through the Robot HAT speaker.
For example, during the Vosk test, after you say something, the expected result is that the recognized text appears in the terminal. In the final program, saying “hey robot” followed by commands such as “forward,” “backward,” “left,” or “right” should cause the car to respond with the corresponding movement.
Since you have also confirmed that Examples 13, 14, and 15 can produce sound through the Robot HAT speaker, we’d like to first make sure we are troubleshooting the correct issue rather than asking you to perform more audio-output tests.
Could you please clarify what is currently not working in Lesson 16?
For example, does Vosk fail to recognize your speech, does the recognized text appear correctly but the car does not respond, or is Lesson 16 otherwise working correctly and your concern is specifically that the recorded test.wav file does not play through the Robot HAT speaker?
Once we understand which behavior is failing, we can focus on that specific issue.



