Google Assistant on RPI3 with Android Things

独自空忆成欢 提交于 2019-12-11 16:17:50

问题


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


回答1:


It looks like the links in the Assistant SDK docs were modified, but it should be pointing to this page:

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

This will save the credentials at /path/to/.config/google-oauthlib-tool/credentials.json, which you can then copy into your project in order to authenticate the Google Assistant.




回答2:


As Nick and proppy noted, one step is to obtain authorization code to be used in later steps. Unfortunately the documentation skipped few very important steps and it can lead to confusion. Sadly Google did not simplify the process of integrating the Assistant in the same development environment and hope they will integrate this clumsy process to Android Studio as with other services

If you are developing under Windows you need to:

  1. use a Linux environment and follow the steps in console of that Linux PC (not in the Android Things console of the RP!). Or install Python in Windows. I used the Raspbian in my RP3 to do the Linux version of the procedure...
  2. install Python environment first in the Linux PC console

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. in this Python environment install google-auth-oauthlib that will generate the credential file

python -m pip install --upgrade google-auth-oauthlib[tool]

  1. change the directory to place you saved the downloaded json file from step before step 11 in the documenatation. e.g.

cd /home/pi/Downloads/

  1. run the google auth tool with the path to your downloaded json file (including its long name, replace idxxx with your 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. there will be a link generated in the console. You have to insert the link into browser . You will be prompted in browser to let the tool to use your account and the you will receive an authentication code. Enter this code to the prompt back in the console.

  2. find the generated authenticated authorization code file in the folder prompted in the console and continue in the original documentation steps



来源:https://stackoverflow.com/questions/48448844/google-assistant-on-rpi3-with-android-things

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!