简体   繁体   English

Raspberry Pi 3上的Google Assistant SDK 3:音频设置不起作用

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

I have been trying to install G assistant in to a Raspberry Pi3. 我一直在尝试将G Assistant安装到Raspberry Pi3中。 I have question in the following link 我在以下链接中有疑问

https://developers.google.com/assistant/sdk/prototype/getting-started-pi-python/configure-audio 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. 因此,我尝试了Step2使用所有硬件信息创建了一个新文件(.asoundrc)。 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) 但是我遇到了以下错误(如果重命名.asoundrc,我看不到此错误,但无法记录)

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! 谢谢!

That happens if your .asoundrc doesn't have the correct structure. 如果您的.asoundrc结构不正确,则会发生这种情况。 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. 警告:如果您使用rpi gui(桌面)音量控制来更改输入,它将为您修改.asoundrc,从而破坏了Google助手的ALSA。 You'll have to go and fix it up. 您必须去修复它。 The instructions on google's website are correct. Google网站上的说明正确无误。

To fix it delete the new entries created. 要解决此问题,请删除创建的新条目。 Then, at the top, look for the line 'type hw'. 然后,在顶部查找“ type hw”行。 It has been sneakily modified... you'll have to change it back to 'type asym' to match the config google specify. 它已经被偷偷修改了...您必须将其改回'type asym'以匹配google指定的配置。

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. 我将gui(桌面)音量的输入/输出设置为模拟,一旦开始使用google助手就不要触摸它,这样它就不会再与.asoundrc混在一起了。

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: 我使用的是Logitech USB耳机,它同时具有麦克风和扬声器(我不使用外部扬声器),因此,鉴于我的音频输入和输出都进入了耳机,我的.asoundrc如下所示:

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. 最后,如果您重新启动Pi,则必须重置助手二进制文件的源路径,否则它将无法找到启动助手演示的命令。 Do this by typing "source env/bin/activate" Then you can run it again by typing "google-assistant-demo" 输入“ source env / bin / activate”来执行此操作,然后输入“ google-assistant-demo”即可再次运行

Good luck! 祝好运!

Yes I was seeing this error -- weirdly after I had everything working fine, i never thought that the .asoundrc file would have been corrupted. 是的,我看到了这个错误-奇怪的是,在一切正常之后,我从未想到.asoundrc文件会被损坏。

Invalid value card arecord: main:722: audio open error: no such file or directory 无效的储值卡记录:main:722:音频打开错误:没有此类文件或目录

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. 我确认Xeneck Stoher说过有关Rasbian gui音量/音频输入/输出选择的问题,将您的〜.asoundrc文件弄乱了,替换掉它可以解决此问题,并且录制/播放现在可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM