2018年6月5日火曜日

googleアシスタントをwindowsで動かす

わかる人向けです。 抜けミスあるかも。
ちゃんとした手順とチェックはまた今度で。。。

0.はじめに
・python3環境を構築しておきましょう。
コマンドプロンプトでpy -3で動けばOK

・作業ディレクトリを作っておきます。
 僕の場合D:\googleAssistantとしました。

・githubリポジトリをローカルにクローンしておきます。
https://github.com/googlesamples/assistant-sdk-python
D:\googleAssistant\assistant-sdk-pythonとしました。

1.プロジェクト作成
https://developers.google.com/assistant/sdk/guides/library/python/embed/config-dev-project-and-account

2.デバイスモデル登録&credentials.jsonダウンロード
https://developers.google.com/assistant/sdk/guides/library/python/embed/register-device
credentials.jsonは作業ディレクトリ(D:\googleAssistant)へダウンロードします。

3.環境構築
以下を作業ディレクトリにて打つ。
py -3 -m venv env
py -3 -m pip install --upgrade pip setuptools wheel
"D:\googleAssistant\assistant-sdk-python\env\Scripts\activate.bat"

4.認証
google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype --scope https://www.googleapis.com/auth/gcm --save --headless --client-secrets credentials.json

 webアドレス出るのでブラウザで開き、認証コードをコマンドプロンプトへコピペ。

4.pythonサンプルを動かす
py -3 "D:\googleAssistant\assistant-sdk-python\google-assistant-sdk\googlesamples\assistant\grpc\textinput.py" --device-model-id [デバイスモデルID] --lang ja-JP --device-id [適当な端末名]