树莓派谷歌助手

问题描述 投票:0回答:2

我哪里出错了,需要帮助。我关注了https://pimylifeup.com/raspberry-pi-google-assistant/。该程序要求我输入一个请求,但它不会通过扬声器输出答案。当我对着麦克风说话时(发送请求),我附上了。

(env) pi@raspberrypi:~ $ googlesamples-assistant-pushtotalk --project-id raspberry-pi--home1 --device-model-id raspberry-pi--home1-google-assistant-fr9vci
INFO:root:Connecting to embeddedassistant.googleapis.com
INFO:root:Using device model raspberry-pi--home1-google-assistant-fr9vci and device id 2c9c8f3a-6286-11ec-b862-b827ebae3b0b
Press Enter to send a new request...
INFO:root:Recording audio request.
INFO:root:Transcript of user request: "what".
INFO:root:Transcript of user request: "what time".
INFO:root:Transcript of user request: "what time is".
INFO:root:Transcript of user request: "what time is it".
INFO:root:Transcript of user request: "what  time is it".
INFO:root:Transcript of user request: "what time  is it".
INFO:root:End of audio request detected.
INFO:root:Stopping recording.
INFO:root:Transcript of user request: "what time is it".
INFO:root:Playing assistant response.
Traceback (most recent call last):
  File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 8, in <module>
    sys.exit(main())
  File "/home/pi/env/lib/python3.9/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/env/lib/python3.9/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/pi/env/lib/python3.9/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/env/lib/python3.9/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/env/lib/python3.9/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 458, in main
    continue_conversation = assistant.assist()
  File "/home/pi/env/lib/python3.9/site-packages/tenacity/__init__.py", line 241, in wrapped_f
    return self.call(f, *args, **kw)
  File "/home/pi/env/lib/python3.9/site-packages/tenacity/__init__.py", line 329, in call
    do = self.iter(result=result, exc_info=exc_info,
  File "/home/pi/env/lib/python3.9/site-packages/tenacity/__init__.py", line 279, in iter
    return fut.result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 433, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/home/pi/env/lib/python3.9/site-packages/tenacity/__init__.py", line 333, in call
    result = fn(*args, **kwargs)
  File "/home/pi/env/lib/python3.9/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 154, in assist
    self.conversation_stream.write(resp.audio_out.audio_data)
  File "/home/pi/env/lib/python3.9/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 326, in write
    buf = normalize_audio_buffer(buf, self.volume_percentage)
  File "/home/pi/env/lib/python3.9/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 57, in normalize_audio_buffer
    buf = arr.tostring()
AttributeError: 'array.array' object has no attribute 'tostring'
(env) pi@raspberrypi:~ $
python-3.x raspberry-pi raspberry-pi3
2个回答
0
投票

我不认为这是一个答案。在树莓上安装 Assistant SDK 时遇到了同样的问题。不幸的是没有用 Python 做太多,但我认为关键是

File "/home/pi/env/lib/python3.9/site-backages/googlesamples/assistant/grpc/audio_helpers.py", line 57, in normalize_audio_buffer
buf = arr.tostring()
AttributeError: 'array.array' object has no attribute 'tostring'

可能是某些类型转换问题?或已弃用的功能。明天我会回滚到旧的 Python 并再试一次。

迭戈。


0
投票

我遇到过这个问题。通过在第 57 行编辑文件

/home/pi/env/lib/python3.9/site-backages/googlesamples/assistant/grpc/audio_helpers.py
并将
tostring
更改为
tobytes
它应该可以工作。

© www.soinside.com 2019 - 2024. All rights reserved.