Google Assistant SDK on Raspberry Pi 3: Audio setup does not work

拜拜、爱过 提交于 2020-01-11 07:35:49

问题


I have been trying to install G assistant in to a Raspberry Pi3. I have question in the following link

https://developers.google.com/assistant/sdk/prototype/getting-started-pi-python/configure-audio

A partial text from above link

# Record a short audio clip. If you get an error, go to step 2.
$ arecord --format=S16_LE --duration=5 --rate=16k --file-type=raw out.raw

As expected I got error in this step. So I tried the Step2 created a new file (.asoundrc) with all the hardware info. Then I tried following

speaker-test -t wav

But I got following error ( If I rename .asoundrc I don't see this error but I cannot record)

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
WAV file(s)
ALSA lib conf.c:1697:(snd_config_load1) toplevel:9:17:Unexpected char
ALSA lib conf.c:3417:(config_file_open) /home/pi/.asoundrc may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3339:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:3788:(snd_config_update_r) hooks failed, removing configuration
Playback open error: -22,Invalid argument

How can I fix this? Thanks!


回答1:


That happens if your .asoundrc doesn't have the correct structure. Warning: If you use the rpi gui (desktop) volume control to change inputs it will modify the .asoundrc for you, breaking ALSA for google assistant. You'll have to go and fix it up. The instructions on google's website are correct.

To fix it delete the new entries created. Then, at the top, look for the line 'type hw'. It has been sneakily modified... you'll have to change it back to 'type asym' to match the config google specify.

I leave the input/output for the gui (desktop) volume set to analogue and don't touch it once I start using google assistant so it won't go and mess with .asoundrc again.

I am using a Logitech USB headset and which has both mic & speaker (I don't use external speaker) So, given my audio input and output goes to the headset, my .asoundrc looks like this:

pcm.!default {
  type asym
  capture.pcm "mic"
  playback.pcm "speaker"
}
pcm.mic {
  type plug
  slave {
    pcm "hw:1,0"
  }
}
pcm.speaker {
  type plug
  slave {
    pcm "hw:1,0"
  }
}

Lastly, if you reboot your Pi, you'll have to reset the source path for the assistant binary, otherwise it won't be able to find the command that starts the assistant demo. Do this by typing "source env/bin/activate" Then you can run it again by typing "google-assistant-demo"

Good luck!




回答2:


Yes I was seeing this error -- weirdly after I had everything working fine, i never thought that the .asoundrc file would have been corrupted.

Invalid value card arecord: main:722: audio open error: no such file or directory

I confirm that Xeneck Stoher says about the Rasbian gui volume/audio in/out selection messing up your ~.asoundrc file, replacing it fixed this issue and the recording / playback now works fine.



来源:https://stackoverflow.com/questions/44374669/google-assistant-sdk-on-raspberry-pi-3-audio-setup-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!