Ubuntu 16.04 X86_64下Google Assistant SDK Python示例无声音求助
Hey there! Let's figure out why your Google Assistant isn't playing sound even though it's correctly recognizing your query ("TF1 21h") and processing responses. From your logs, the conversation flow is working perfectly—so the issue is definitely tied to audio output configuration. Here are step-by-step fixes to try:
1. First, Verify System Audio Works
Before blaming the SDK, make sure your Ubuntu system can play sound at all:
- Test your speakers/headphones with a system sound:
aplay /usr/share/sounds/alsa/Front_Center.wav - Check your default audio output device:
Look for the line markedpacmd list-sinks* index:—that's your default device. If it's not the one you're using, set the correct one with:
(Replacepacmd set-default-sink <sink-name><sink-name>with thename:value from the output, likealsa_output.pci-0000_00_1b.0.analog-stereo)
2. Force the SDK to Use the Correct Audio Device
The Google Assistant SDK might be using the wrong output device. Try running the sample with explicit audio output settings:
- If you're using the library demo, add the
--output-deviceflag:python -m googlesamples.assistant.library.demo --output-device=<your-sink-name> - If you're using a custom script, ensure the
AudioOutcomponent is initialized with the correct device. Check the SDK's built-in audio helper notes for how to specify devices in code.
3. Fix Audio Permissions and Service Issues
Ubuntu 16.04 uses PulseAudio by default—let's make sure permissions and services are set right:
- Ensure your user is in the
audiogroup (required for accessing audio devices):
Ifgroupsaudioisn't listed, add yourself and log out/in:sudo usermod -aG audio $USER - Restart PulseAudio to clear any stuck processes:
pulseaudio -k && pulseaudio --start - Reset your ALSA config if there's a misconfiguration (back up first):
sudo mv /etc/asound.conf /etc/asound.conf.bak
4. Reinstall Audio Dependencies
Missing or outdated audio libraries can cause issues. Refresh your dependencies:
- Install system-level audio dev packages:
sudo apt-get install portaudio19-dev libasound2-dev - Upgrade Python audio packages:
pip install --upgrade pyaudio sounddevice
5. Test with a Minimal Audio Sample
To isolate the issue, run the SDK's audio helper test to confirm output works:
python -m googlesamples.assistant.audio_helpers --output-device=<your-sink-name>
This should play a test tone—if it does, the SDK can access your audio device, and the problem might be in your main sample setup.
Since your logs confirm the Assistant is processing queries correctly, focusing on these audio output tweaks should get sound working in no time!
内容的提问来源于stack exchange,提问作者Thierry Donnadieu

