如何修复sounddevice.PortaudioError。打开RawStream时出错:无效的采样率[PaErrorCode -9997]

时间:2019-07-05 19:35:39

标签: google-assistant-sdk

我正在尝试在我的Pi 3b +上安装google助手,并且一切正常,没有错误,我的麦克风和扬声器正在工作,我的.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:0,0"
  }
}

并且我遵循了很多教程,并且确实像它们一样,还在线尝试了其他一些修复程序,但是都没有修复此问题。有人可以帮忙吗?

这是整个消息

INFO:root:Connecting to embeddedassistant.googleapis.com
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.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 351, in main
    flush_size=audio_flush_size
  File "/home/pi/env/lib/python3.7/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.7/site-packages/sounddevice.py", line 1264, in __init__
    **_remove_self(locals()))
  File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 780, in __init__
    'Error opening {0}'.format(self.__class__.__name__))
  File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 2572, in _check
    raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate [PaErrorCode -9997]

2 个答案:

答案 0 :(得分:0)

可以测试一些东西,我尝试将速率16000放在pcm.speaker下,现在可以了

$ ssh me@118.247.237.49 -p 8822
ssh: connect to host 118.247.237.49 port 8822: Connection refused

答案 1 :(得分:0)

对于仍然存在此问题的人:

确保您编辑 /etc/asound.conf 文件。我被卡住了,因为我编辑了 /home/pi/.asoundrc 文件。