简体   繁体   中英

Google assistant SDK on RaspberryPi 3 - sounddevice.PortAudioError

I get following error when I try to run Sample Google AI as in Configure and Run the sample -

(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: ''

Not sure if this is related. But, I also have a arecord issue-

(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

Audio output testing as described in Google AI setup guide works. Also, I have completed steps 2 to 4 described in link. It does not fix the error though.

This command works -

(env) pi@raspberrypi:~ $ sudo arecord --format=S16_LE --duration=5 --rate=16k -D hw:1,0 --file-type=raw out.raw
Recording raw data 'out.raw' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
Warning: rate is not accurate (requested = 16000Hz, got = 44100Hz)
     please, try the plug plugin

Is there a solution to get this going?

Thanks.

change ~/.asoundrc to below

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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