RaspberryPi 3上的Google助手SDK - sounddevice.PortAudioError

时间:2017-05-13 23:01:43

标签: python raspberry-pi google-assistant-sdk

当我尝试按Configure and Run the sample -

运行示例Google AI时出现以下错误
y

不确定这是否相关。但是,我也有 arecord 问题 -

(env) pi@raspberrypi:~ $ python -m googlesamples.assistant
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/__main__.py", line 26, in <module>
    from googlesamples.assistant import (
  File "/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/audio_helpers/__init__.py", line 24, in <module>
    import sounddevice as sd
  File "/home/pi/env/lib/python3.4/site-packages/sounddevice.py", line 2787, in <module>
    _initialize()
  File "/home/pi/env/lib/python3.4/site-packages/sounddevice.py", line 2744, in _initialize
    _check(_lib.Pa_Initialize(), 'Error initializing PortAudio')
  File "/home/pi/env/lib/python3.4/site-packages/sounddevice.py", line 2671, in _check
    raise PortAudioError(msg)
sounddevice.PortAudioError: Error initializing PortAudio: Unanticipated host API -10000 error 0: ''

音频输出测试,如Google AI setup guide中所述。另外,我已完成链接中描述的步骤2到4。但它并没有修复错误。

此命令有效 -

(env) pi@raspberrypi:~ $ sudo arecord --format=S16_LE --duration=5 --rate=16k --file-type=raw out.raw
arecord: main:722: audio open error: No such file or directory

是否有解决方案可以实现这一目标?

感谢。

1 个答案:

答案 0 :(得分:0)

将〜/ .asoundrc更改为

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