You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在树莓派3上为Google Assistant SDK安装USB声卡驱动及排查识别故障

Hey there, let's work through getting your USB sound card recognized and set up for the Google Assistant SDK on your Raspberry Pi 3. I’ve dealt with this exact scenario a few times, so here’s a step-by-step guide to get you up and running:

1. First Rule Out Basic Hardware Issues

Before diving into software fixes, let’s eliminate simple hardware problems:

  • Try plugging the USB sound card into a different USB port on the Pi (preferably one of the blue USB 3.0 ports, though USB 2.0 works too).
  • Swap out the USB cable if you have a spare—sometimes faulty cables cause detection failures.
  • Test the sound card on another computer (like a laptop) to confirm it works at all. If it doesn’t, the card itself might be defective.
2. Check if the Pi Detects the USB Sound Card

Let’s verify the system sees the hardware:

  • Open a terminal and run this command to list all USB devices:
    lsusb
    Look for an entry related to your sound card—something like C-Media Electronics, Inc. Audio Adapter or the brand name of your device. If you don’t see it, the Pi isn’t detecting the hardware at all (go back to step 1).
  • Next, check if ALSA (the Pi’s audio system) recognizes the card as an audio device:
    aplay -l (lists playback devices)
    arecord -l (lists recording devices)
    You should see your USB sound card listed here, with a card number (e.g., card 1) and device number (e.g., device 0). Jot these down—you’ll need them later.
3. Install Required Audio Drivers & Tools

Most USB sound cards are plug-and-play on Raspberry Pi OS, but we can ensure all necessary packages are installed:

  • Update your system packages first:
    sudo apt update && sudo apt upgrade -y
  • Install ALSA utilities and common audio firmware:
    sudo apt install alsa-utils firmware-linux-free -y
  • Reboot your Pi to apply any changes:
    sudo reboot
4. Set the USB Sound Card as the Default Audio Device

The Google Assistant SDK will use the system’s default audio device, so we need to make sure the USB card is prioritized:

  • Create or edit the ALSA configuration file for your user:
    nano ~/.asoundrc
  • Paste the following content, replacing card 1 and device 0 with the numbers you noted from aplay -l:
    pcm.!default {
        type hw
        card 1
        device 0
    }
    
    ctl.!default {
        type hw
        card 1
    }
    
  • Save the file (press Ctrl+O, then Enter) and exit nano (Ctrl+X).
  • Alternatively, you can edit the system-wide ALSA config if you want the change to apply to all users:
    sudo nano /usr/share/alsa/alsa.conf
    Find lines starting with defaults.ctl.card and defaults.pcm.card and change their values to your USB card’s number.
5. Test Audio Playback & Recording

Let’s confirm the audio works before setting up the SDK:

  • Test playback with a sample sound:
    aplay /usr/share/sounds/alsa/Front_Center.wav
    You should hear audio through the USB speaker.
  • Test recording (press Ctrl+C after 5 seconds to stop):
    arecord -d 5 test.wav
  • Play back the recording to check the microphone:
    aplay test.wav
    If this works, your audio setup is good to go.
6. Configure Google Assistant SDK to Use the USB Sound Card

If you’ve already installed the SDK, make sure it’s using the correct audio devices:

  • When running the push-to-talk sample, specify the audio devices explicitly using the card/device numbers:
    googlesamples-assistant-pushtotalk --audio-input-device=hw:1,0 --audio-output-device=hw:1,0
  • If you’re using the SDK in a custom script, ensure your code references the USB sound card instead of the Pi’s built-in audio.
Troubleshooting Tips
  • If you still don’t see the sound card in aplay -l, check if your user has audio permissions:
    groups
    If audio isn’t listed, add your user to the group:
    sudo usermod -aG audio $USER
    Then log out and back in, or reboot.
  • Some niche USB sound cards might require specific drivers. If you know the exact model, search for its Linux driver (but most common cards work with the default ALSA setup).

内容的提问来源于stack exchange,提问作者Sravan kunnummal.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:47:12