0

I tried to follow the documentation and got stuck in the point

  1. Open a terminal and follow the instructions to configure a new Python virtual environment and install the `google-assistant-library.

The link in this point redirects to a general page (Introduction to the Google Assistant Library) rather than the instructions. I think it misses the explanation what it means to open the terminal and exact steps to be followed. Is the link really correct?

Maybe I need help in using the console correctly, but I am not getting it from that poor documentation. I can connect to RP with Serial to USB cable and Putty. But simply I do not know what that point 11 and onwards mean... Any idea? Thank you

4

2 回答 2

1

看起来 Assistant SDK 文档中的链接被修改了,但它应该指向这个页面:

sudo apt-get update
sudo apt-get install python3-dev python3-venv # Use python3.4-venv if the package cannot be found.
python3 -m venv env
env/bin/python -m pip install --upgrade pip setuptools
source env/bin/activate

python -m pip install --upgrade google-auth-oauthlib[tool]
google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype \
      --save --headless --client-secrets /path/to/client_secret_client-id.json

这会将凭据保存在/path/to/.config/google-oauthlib-tool/credentials.json,然后您可以将其复制到您的项目中以验证 Google 助理。

于 2018-01-25T20:32:30.470 回答
0

正如 Nick 和 proppy 所指出的,一个步骤是获取授权码以在后续步骤中使用。不幸的是,文档跳过了一些非常重要的步骤,这可能会导致混乱。遗憾的是,谷歌没有简化将智能助理集成到同一开发环境中的过程,并希望他们将这个笨拙的过程集成到 Android Studio 中,就像与其他服务一样

如果你在Windows下开发,你需要:

  1. 使用 Linux 环境并按照该 Linux PC 控制台中的步骤操作(而不是在 RP 的 Android Things 控制台中!)。或者在 Windows 中安装 Python。我在我的 RP3 中使用 Raspbian 来执行 Linux 版本的程序...
  2. 先在Linux PC控制台安装Python环境

sudo apt-get update sudo apt-get install python3-dev python3-venv python3 -m venv env env/bin/python -m pip install --upgrade pip setuptools source env/bin/activate

  1. 在这个 Python 环境中安装 google-auth-oauthlib,它将生成凭证文件

python -m pip install --upgrade google-auth-oauthlib[工具]

  1. 更改目录以放置您在文档中的步骤 11 之前的步骤中保存下载的 json 文件。例如

cd /home/pi/下载/

  1. 使用您下载的 json 文件的路径运行 google auth 工具(包括其长名称,将 idxxx 替换为您的 id)

google-oauthlib-tool --client-secrets /home/pi/Downloads/client_secret_client-idxxx.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless

  1. 控制台中会生成一个链接。您必须将链接插入浏览器。浏览器将提示您让该工具使用您的帐户,您将收到一个验证码。将此代码输入到控制台中的提示符中。

  2. 在控制台提示的文件夹中找到生成的认证授权码文件,继续原文档步骤

于 2018-01-26T05:52:20.620 回答