![打开 RawStream 时出错:采样率无效 [PaErrorCode -9997] RPi 上的 google assistant SDK](https://linux22.com/image/1600976/%E6%89%93%E5%BC%80%20RawStream%20%E6%97%B6%E5%87%BA%E9%94%99%EF%BC%9A%E9%87%87%E6%A0%B7%E7%8E%87%E6%97%A0%E6%95%88%20%5BPaErrorCode%20-9997%5D%20RPi%20%E4%B8%8A%E7%9A%84%20google%20assistant%20SDK.png)
我正在尝试通过以下链接在 rpi 上安装 google assistant SDK“https://developers.google.com/assistant/sdk/guides/service/python/embed/run-sample“
执行此命令时googlesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model
我得到:
Traceback (most recent call last):
File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 10, in <module>
sys.exit(main())
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/pi/env/lib/python3.5/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 351, in main
flush_size=audio_flush_size
File "/home/pi/env/lib/python3.5/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 190, in __init__
blocksize=int(block_size/2), # blocksize is in number of frames.
File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 1264, in __init__
**_remove_self(locals()))
File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 780, in __init__
'Error opening {0}'.format(self.__class__.__name__))
File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 2572, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate [PaErrorCode -9997]
答案1
该问题已在这里得到解决和答复: https://stackoverflow.com/questions/43958779/google-assistant-sdk-on-raspberrypi-3-sounddevice-portaudioerror
我测试了这个解决方案并且它对我来说同样有效。
只需将其更改.asoundrc
为:
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "hw:0,0"
}
capture.pcm {
type plug
slave.pcm "hw:1,0"
}
}