#author("2020-03-14T21:16:31+00:00","default:mizutu","mizutu") [[私的AI研究会]] > VoiceKit on Pi4 * Voice Kit V2 on Raspberry Pi4 [#t71d13ce] > Voice Kit V2 を Raspberry Pi4 で動かす #contents ** 目的と準備 [#j6598b10] >「Google Cloud」サイトの変更により、書籍「Raspberry Pi + AI 電子工作入門」やサイトの情報が交錯して正確な情報がつかみにくいので、「Google AIY Project」のサイトを検証してみる。~ 販売されている「Voice Kit V2」は Raspberry Pi Zero 他一式のセットだがこれを利用せず、サイトのソフトウェアを使用して Raspberry Pi4 上で動作させ 2020/03 現在の手順を確立する。~ > Raspberry Pi3 ではすでに各種事例がある。 - [[AIY ProjectのVoice KitをVocie Kitなしでやってみた>+https://intellectualcuriosity.hatenablog.com/entry/2017/06/18/030506]] - [[How to build your own digital assistant with a Raspberry Pi>+https://www.androidauthority.com/build-google-assistant-raspberry-pi-770296/]] *** ハードウェア [#w67d1e63] #ref(画像一覧/20200121_115948_001s.jpg,right,around,25%,20200121_115948_001s.jpg) #ref(画像一覧/20200111_163013_001s.jpg,right,around,25%,20200111_163013_001s.jpg) #ref(画像一覧/daiso_spks.jpg,right,around,25%,daiso_spks.jpg) #ref(画像一覧/raspberry_pi4.jpg,right,around,50%,raspberry_pi4.jpg) - Raspberry Pi4 - スピーカー&アンプ(DAISO のUSBスピーカーを分解して利用) - USBマイク - タクトSW #clear *** Google AIY Project Voice Kit V2 [#qc863de7] #ref(voice_kit01m.jpg,left,around,13%,voice_kit01m.jpg) #ref(voice_kit03m.jpg,left,around,13%,voice_kit03m.jpg) ● [[オフィシャルサイト>+https://aiyprojects.withgoogle.com/voice/]]~ ● [[GitHab ソフトウェアリリースページ>+https://github.com/google/aiyprojects-raspbian/releases]]~ #clear ** 最新のシステムイメージを取得 [#b1605afc] #ref(voice_kit02m.jpg,left,around,13%,voice_kit02m.jpg) #ref(voice_kit04m.jpg,left,around,13%,voice_kit04m.jpg) #ref(voice_kit05s.jpg,left,around,25%,voice_kit05s.jpg) ● GitHubのリリースページから最新のイメージファイルをダウンロード~ ● ダウンロードしたファイルを解凍し、Rufus(Windowsの場合)などのプログラムを使用して MicroSDカードにコピーする。~ > [[linuxのインストールメディアを作る>+https://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=2ahUKEwi3hMjluZrnAhVLFogKHWYZBvEQFjACegQIBhAB&url=https%3A%2F%2Fpc-freedom.net%2Fsoftware%2Frufus%25E3%2581%25A7linux%25E3%2581%25AE%25E3%2582%25A4%25E3%2583%25B3%25E3%2582%25B9%25E3%2583%2588%25E3%2583%25BC%25E3%2583%25AB%25E3%2583%25A1%25E3%2583%2587%25E3%2582%25A3%25E3%2582%25A2%25E3%2582%2592%25E4%25BD%259C%25E3%2582%258B%25E3%2580%2582%2F&usg=AOvVaw3GYwyCzZCetqhRZP4QPTuW]]~ #clear ** Raspbian の起動 [#w6fbaf7b] #ref(voice_kit06m.jpg,left,around,13%,voice_kit06m.jpg) #ref(voice_kit07m.jpg,left,around,13%,voice_kit07m.jpg) ● Raspberry Pi4 にMicroSD カードをいれて、モニター、マウス、キーボードを接続する。~ ● 日本語のページをGoogle Chrome ブラウザで表示しながら手順を確認する。~ ● Raspberry を起動する。~ #clear ** Raspbian の初期設定 [#m622bc69] #ref(画像一覧/20200312_171730_001s.jpg,left,around,25%,20200312_171730_001s.jpg) #ref(画像一覧/20200312_172333_001s.jpg,left,around,25%,20200312_172333_001s.jpg) ● 初期設定ウイザードに従い設定を進める。~ 初期ユーザー(rootユーザー) としてあらかじめ「pi」が設定されている。初期設定でパスワードの入力は必要。~ ● 無線LANの設定をする。~ ● 最後のステップでソフトウェアのアップデートをする。(数分~数十分)~ ● 再起動して、AIYプロジェクトのロゴマークの入ったデスクトップが表示されれば最初のセットアップは完了。~ #clear *** 詳細設定 [#b71abd7c] - オーディオの設定を変更する。~ Google AIYのSDイメージは、キットのマイクを使うことを想定しているので、ラズパイ標準の音声管理がOFFになっているので以下の手順で有効にする。 $ sudo vi /boot/config.txt #dtparam=audio=on → dtparam=audio=on コメントをはずす $ sudo reboot 再起動 - raspi-config を起動する。~ デスクトップ環境の場合、「アクセサリ」→「LXTerminal」でターミナルを起動しコマンドを入力する。 $ sudo raspi-config -- 「2 Network Option」→「N1 Hostname」からホスト名を入力。 -- 「5 Interfacing Option」から必要な各種機能の有効化をする。 -- 「7 Advanced Option」→「A1 Expand Filesystem」からmicroSDカードの容量拡張をする。~ 「A4 Audio」から優先的に使用するオーディオを選択。 -- 以上で詳細設定 完了。 *** SSH のリモートターミナル接続 [#t471379a] - Mac の場合 -- ターミナルからSSH接続 - Windows の場合 -- 「Tera Term」による接続 -- 「RLogin」による接続 - iPhone/iPad の場合 -- 「Termius」による接続~ *** VNC リモート接続 [#jaced351] - tightvncserver をインストールする。~ $ sudo apt install tightvncserver パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 以下の追加パッケージがインストールされます: xfonts-base xfonts-encodings xfonts-utils 提案パッケージ: tightvnc-java 以下のパッケージは「削除」されます: realvnc-vnc-server 以下のパッケージが新たにインストールされます: tightvncserver xfonts-base xfonts-encodings xfonts-utils アップグレード: 0 個、新規インストール: 4 個、削除: 1 個、保留: 220 個。 7,104 kB のアーカイブを取得する必要があります。 この操作後に 26.8 MB のディスク容量が解放されます。 続行しますか? [Y/n] y 取得:1 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf tightvncserver armhf 1:1.3.9-9+deb10u1 [551 kB] 取得:2 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf xfonts-encodings all 1:1.0.4-2 [574 kB] 取得:3 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf xfonts-utils armhf 1:7.7+6 [82.5 kB] 取得:4 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf xfonts-base all 1:1.0.5 [5,897 kB] 7,104 kB を 4秒 で取得しました (1,665 kB/s) (データベースを読み込んでいます ... 現在 145384 個のファイルとディレクトリがインストールされています。) realvnc-vnc-server (6.5.0.41824) を削除しています ... 以前に未選択のパッケージ tightvncserver を選択しています。 (データベースを読み込んでいます ... 現在 145305 個のファイルとディレクトリがインストールされています。) .../tightvncserver_1%3a1.3.9-9+deb10u1_armhf.deb を展開する準備をしています ... tightvncserver (1:1.3.9-9+deb10u1) を展開しています... 以前に未選択のパッケージ xfonts-encodings を選択しています。 .../xfonts-encodings_1%3a1.0.4-2_all.deb を展開する準備をしています ... xfonts-encodings (1:1.0.4-2) を展開しています... 以前に未選択のパッケージ xfonts-utils を選択しています。 .../xfonts-utils_1%3a7.7+6_armhf.deb を展開する準備をしています ... xfonts-utils (1:7.7+6) を展開しています... 以前に未選択のパッケージ xfonts-base を選択しています。 .../xfonts-base_1%3a1.0.5_all.deb を展開する準備をしています ... xfonts-base (1:1.0.5) を展開しています... tightvncserver (1:1.3.9-9+deb10u1) を設定しています ... update-alternatives: /usr/bin/vncserver (vncserver) を提供するために自動モードで /usr/bin/tightvncserver を使います update-alternatives: /usr/bin/Xvnc (Xvnc) を提供するために自動モードで /usr/bin/Xtightvnc を使います update-alternatives: /usr/bin/vncpasswd (vncpasswd) を提供するために自動モードで /usr/bin/tightvncpasswd を使います xfonts-encodings (1:1.0.4-2) を設定しています ... xfonts-utils (1:7.7+6) を設定しています ... xfonts-base (1:1.0.5) を設定しています ... fontconfig (2.13.1-2) のトリガを処理しています ... desktop-file-utils (0.23-4) のトリガを処理しています ... mime-support (3.62) のトリガを処理しています ... hicolor-icon-theme (0.17-2) のトリガを処理しています ... gnome-menus (3.31.4-3) のトリガを処理しています ... man-db (2.8.5-2) のトリガを処理しています ... shared-mime-info (1.10-1) のトリガを処理しています ... - tightvncserver を設定する。(vncサーバーのパスワード設定) $ tightvncserver You will require a password to access your desktops. Password: Verify: Would you like to enter a view-only password (y/n)? y Password: Verify: New 'X' desktop is raspberrypi-aiy:1 Creating default startup script /home/pi/.vnc/xstartup Starting applications specified in /home/pi/.vnc/xstartup Log file is /home/pi/.vnc/raspberrypi-aiy:1.log #ref(voice_kit08m.jpg,left,around,13%,voice_kit08m.jpg) ● ホストコンピュータから、VNCクライアントで接続する。 接続先のipアドレス指定に必ずポート番号を付加すること (アドレス:5901)~ ● 詳しくは → [[VNC リモート接続>Raspbian覚書#o3edb237]]~ #clear *** 音声の動作を確認する。 [#z62837b8] - オーディオ出力のリスト pi@raspberrypi-aiy:~ $ aplay -l **** ハードウェアデバイス PLAYBACK のリスト **** カード 0: ALSA [bcm2835 ALSA], デバイス 0: bcm2835 ALSA [bcm2835 ALSA] サブデバイス: 7/7 サブデバイス #0: subdevice #0 サブデバイス #1: subdevice #1 サブデバイス #2: subdevice #2 サブデバイス #3: subdevice #3 サブデバイス #4: subdevice #4 サブデバイス #5: subdevice #5 サブデバイス #6: subdevice #6 カード 0: ALSA [bcm2835 ALSA], デバイス 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 0: ALSA [bcm2835 ALSA], デバイス 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1] サブデバイス: 1/1 サブデバイス #0: subdevice #0 - オーディオ入力のリスト pi@raspberrypi-aiy:~ $ arecord -l **** ハードウェアデバイス CAPTURE のリスト **** カード 1: Device [USB PnP Sound Device], デバイス 0: USB Audio [USB Audio] サブデバイス: 1/1 サブデバイス #0: subdevice #0 - スピーカーのテスト ザーというホワイトノイズが聞こえればOK (終了はctrl+C) $ speaker-test -c2 speaker-test 1.1.8 再生デバイス: default ストリームパラメータ: 48000Hz, S16_LE, 2 チャネル 16 オクターブのピンクノイズを使用 レート 48000Hz (要求値 48000Hz) バッファサイズ範囲 480 ? 32768 ピリオドサイズ範囲 480 ? 32768 最大バッファサイズ 32768 を使用 ピリオド数 = 4 period_size = 8192 で設定 buffer_size = 32768 で設定 0 - Front Left 1 - Front Right ピリオド時間 = 5.134241 0 - Front Left 1 - Front Right - 詳しくは → [[オーディオ]] ** 資格(認証)情報の取得 [#s43aa00d] #ref(voice_kit09m.jpg,left,around,13%,voice_kit09m.jpg) #ref(voice_kit10m.jpg,left,around,13%,voice_kit10m.jpg) ● Google Platform をアクセスする。~ もし、ログインしていなければログイン画面が表示されるのでGoogleアカウントでログインする。 #clear *** プロジェクトを作成 [#xf4d4b6c] #ref(voice_kit11m.jpg,left,around,13%,voice_kit11m.jpg) ● Google Console トップ画面(左)から「プロジェクトを選択」~ #clear #ref(voice_kit12m.jpg,left,around,13%,voice_kit12m.jpg) #ref(voice_kit13m.jpg,left,around,13%,voice_kit13m.jpg) ● 「新しいプロジェクト」を選択。~ ● プロジェクト名(例:AIJproject)を入力。~ ● 「作成「」を押しプロジェクトを作成する。~ #clear *** プロジェクトを開く [#qa02c4ec] #ref(voice_kit14m.jpg,left,around,13%,voice_kit14m.jpg) ● 左ナビゲーションの[ ホーム]リンクをクリックする。~ ● 画面上部の「プロジェクトの選択」をもう一度クリック、作成したプロジェクトを選択する。~ #clear *** Google API ライブラリに移動 [#i5273464] #ref(voice_kit15m.jpg,left,around,13%,voice_kit15m.jpg) ● 左側のナビゲーションがまだ表示されていない場合は、ページの左上にある3行のメニューアイコンをクリックして開く。~ ● 「APIとサービス」の上にマウスを移動し、「ライブラリ」をクリックする。 #clear *** Google Assistant API の設定 [#ef1aaa4c] #ref(voice_kit16m.jpg,left,around,13%,voice_kit16m.jpg) #ref(voice_kit17m.jpg,left,around,13%,voice_kit17m.jpg) ● 検索ボックスに「google assistant」と入力~ ● Google Assistant APIというラベルの付いたカードをクリックする。 #clear #ref(voice_kit18m.jpg,left,around,13%,voice_kit18m.jpg) ● Google Assistant APIを有効にする~ #clear ** 資格(認証)情報を作成 [#idc5ea70] #ref(voice_kit19m.jpg,left,around,13%,voice_kit19m.jpg) ● Google Assistant APIのダッシュボードページに移動する。~ ●「認証情報の作成」ボタンを押す。~ #clear *** プロジェクトの資格情報を追加する。 [#kd6e7ac7] #ref(voice_kit20m.jpg,left,around,13%,voice_kit20m.jpg) ●「どのAPIを使用していますか」で、「Google Assistant API」を選択。~ ●「どこからAPIを呼び出すのですか?」で、「その他のUI(Windows、CLIツールなど)」を選択。~ ●「どのデータにアクセスしますか?」で、「ユーザーデータ」を選択。~ ●「必要な認証情報」をクリックする。~ #clear *** OAuth 同意画面の設定 [#v244c0ab] #ref(voice_kit21m.jpg,left,around,13%,voice_kit21m.jpg) ●「同意画面の設定」を押す。 #clear #ref(voice_kit22m.jpg,left,around,13%,voice_kit22m.jpg) ●「外部」を選ぶ。(外部しか選べない)~ ●「作成」を押す。~ #clear #ref(voice_kit23m.jpg,left,around,13%,voice_kit23m.jpg) #ref(voice_kit24m.jpg,left,around,13%,voice_kit24m.jpg) ●「アプリケーション名」を入力する。(例:AIYapp)~ ● ページを下にスクロールし、「保存」ボタンを押す。~ #clear #ref(voice_kit25m.jpg,left,around,13%,voice_kit25m.jpg) ● 最初の「OAuth 同意画面の設定」ページに戻る。~ ● 自動的に次の画面になる。~ #clear *** OAuth 2.0クライアントIDを作成 [#ra0fcc6d] #ref(voice_kit26m.jpg,left,around,13%,voice_kit26m.jpg) #ref(voice_kit27m.jpg,left,around,13%,voice_kit27m.jpg) ● クライアントIDを入力します。以前に使用したものと同じプロジェクト名の使用を推奨。~ ●「更新」ボタンを押す。~ ●「OAuthクライアントIDの作成」ボタンを押す。~ #clear *** 認証情報ファイルをダウンロード [#n974e376] #ref(voice_kit28m.jpg,left,around,13%,voice_kit28m.jpg) #ref(voice_kit29m.jpg,left,around,13%,voice_kit29m.jpg) ●「ダウンロード」ボタンを押す。~ ● ダウンロード開始ダイアログで「保存」ボタンを押しファイルをダウンロードする。~ ●「完了」ボタンを押す。~ #clear *** 認証情報ファイルを Raspberry Pi に送る [#nd88ceb5] - ダウンロードした client_id.json ファイルをメモ帳などのテキストエディタで開く。~ -「編集」→「すべて選択」→「コピー」と操作しクリップボードにコピーする。~ - ターミナルから Raspberry Pi を操作する。~ $ vi assistant.json で新規ファイルを作成し、クリップボードの内容をペーストする。~ - vi エディタを終了してできたファイルを確認する。 $ cat assistant.json {"installed":{"client_id":"1029345425416-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com","project_id":"aijproject","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"Wsl-IjR_tO0t7UEFv-VHOTU2","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}} -「認証情報」の取得完了‼ #br ** デモフォルダに移動する。 [#q5d41c8c] - ターミナルからRaspberry Pi を操作する。 pi@raspberrypi-aiy:~ $ cd AIY-voice-kit-python pi@raspberrypi-aiy:~/AIY-voice-kit-python $ ls *** デモフォルダを確認する。 [#ic90fe5e] > pi@raspberrypi-aiy:~/AIY-voice-kit-python/src/examples $ ls button_led.py buzzer gpiozero leds_example.py vision voice pi@raspberrypi-aiy:~/AIY-voice-kit-python/src/examples $ ** アシスタントデモを実行する [#a0bcd6ec] > pi@raspberrypi-aiy:~/AIY-voice-kit-python/src/examples $ voice/assistant_grpc_demo.py DEBUG:requests_oauthlib.oauth2_session:Generated new state XgTsap1N3etZNBuFXZoE6evP9CeJSL. Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=1029345425416-ud313r0lt4ttrsu4ebmb00v20udao5m0.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fassistant-sdk-prototype&state=XgTsap1N3etZNBuFXZoE6evP9CeJSL&prompt=consent&access_type=offline Enter the authorization code: ■ *** Google Assistant の使用許可を与える [#fdca04ca] - URLにアクセスしてアプリケーションを許可することについてのメッセージが表示される。~ - http://以下のURLをコピーする。~ - Webブラウザーで上記URL のページを開き表示される認証コードを得る(コピー)。~ - 停止しているデモソフトにターミナルから認証コードを入力(ペースト)する。~ Enter the authorization code: 4/xgFTln6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx DEBUG:requests_oauthlib.oauth2_session:Requesting url https://oauth2.googleapis.com/token using method POST. DEBUG:requests_oauthlib.oauth2_session:Supplying headers {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'} and data {'grant_type': 'authorization_code', 'code': '4/xgFTln6RpRfFYYjyX67NZXp6ExauaZEpjbMox5TSBDQhNz0cJFUXLFQ', 'client_id': '1029345425416-ud313r0lt4ttrsu4ebmb00v20udao5m0.apps.googleusercontent.com', 'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob', 'client_secret': 'Wsl-IjR_tO0t7UEFv-VHOTU2'} DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'json': None, 'timeout': None, 'auth': None, 'verify': True, 'proxies': None}. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oauth2.googleapis.com:443 DEBUG:urllib3.connectionpool:https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 200 None DEBUG:requests_oauthlib.oauth2_session:Prepared fetch token request body grant_type=authorization_code&code=4%2FxgFTln6RpRfFYYjyX67NZXp6ExauaZEpjbMox5TSBDQhNz0cJFUXLFQ&client_id=1029345425416-ud313r0lt4ttrsu4ebmb00v20udao5m0.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&client_secret=Wsl-IjR_tO0t7UEFv-VHOTU2 DEBUG:requests_oauthlib.oauth2_session:Request to fetch token completed with status 200. DEBUG:requests_oauthlib.oauth2_session:Request headers were {'User-Agent': 'python-requests/2.21.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/json', 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Content-Length': '266'} DEBUG:requests_oauthlib.oauth2_session:Request body was grant_type=authorization_code&code=4%2FxgFTln6RpRfFYYjyX67NZXp6ExauaZEpjbMox5TSBDQhNz0cJFUXLFQ&client_id=1029345425416-ud313r0lt4ttrsu4ebmb00v20udao5m0.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&client_secret=Wsl-IjR_tO0t7UEFv-VHOTU2 DEBUG:requests_oauthlib.oauth2_session:Response headers were {'Content-Type': 'application/json; charset=utf-8', 'Vary': 'Origin, X-Origin, Referer', 'Content-Encoding': 'gzip', 'Date': 'Fri, 13 Mar 2020 04:04:58 GMT', 'Server': 'scaffolding on HTTPServer2', 'Cache-Control': 'private', 'X-XSS-Protection': '0', 'X-Frame-Options': 'SAMEORIGIN', 'X-Content-Type-Options': 'nosniff', 'Alt-Svc': 'quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000', 'Transfer-Encoding': 'chunked'} and content { "access_token": "ya29.a0Adw1xeV-Hs3pmXqRWGEL-9cL34qlnLt2s1E9ON47-exrOxeHAw2nm0rcB2-mIKaicy-mAZty_AYbNDNDW80W1hiSort9XeabBypY508cde6tZJcZIrbXTv_7ULvQ7gOvR2zHYyBRsH30LtexYHwiEMD5ZRPLuBoGH2o", "expires_in": 3599, "refresh_token": "1//0eae-GiYSU1CBCgYIARAAGA4SNwF-L9IrfI8KVWYSnx-YEfVFhrfcN5METqR2rrlJfZeBkq5RwTv93FJPU-mURdiO2sA59MAHUdI", "scope": "https://www.googleapis.com/auth/assistant-sdk-prototype", "token_type": "Bearer" }. DEBUG:requests_oauthlib.oauth2_session:Invoking 0 token response hooks. DEBUG:requests_oauthlib.oauth2_session:Obtained token {'access_token': 'ya29.a0Adw1xeV-Hs3pmXqRWGEL-9cL34qlnLt2s1E9ON47-exrOxeHAw2nm0rcB2-mIKaicy-mAZty_AYbNDNDW80W1hiSort9XeabBypY508cde6tZJcZIrbXTv_7ULvQ7gOvR2zHYyBRsH30LtexYHwiEMD5ZRPLuBoGH2o', 'expires_in': 3599, 'refresh_token': '1//0eae-GiYSU1CBCgYIARAAGA4SNwF-L9IrfI8KVWYSnx-YEfVFhrfcN5METqR2rrlJfZeBkq5RwTv93FJPU-mURdiO2sA59MAHUdI', 'scope': ['https://www.googleapis.com/auth/assistant-sdk-prototype'], 'token_type': 'Bearer', 'expires_at': 1584075897.5179968}. INFO:root:OAuth credentials initialized: /home/pi/.cache/voice-recognizer/assistant_credentials.json DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None) DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): embeddedassistant.googleapis.com:443 DEBUG:urllib3.connectionpool:https://embeddedassistant.googleapis.com:443 "GET /v1alpha2/projects/aijproject/deviceModels/aijproject-voice-kit HTTP/1.1" 404 None DEBUG:urllib3.connectionpool:https://embeddedassistant.googleapis.com:443 "POST /v1alpha2/projects/aijproject/deviceModels HTTP/1.1" 200 None DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None) DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): embeddedassistant.googleapis.com:443 DEBUG:urllib3.connectionpool:https://embeddedassistant.googleapis.com:443 "GET /v1alpha2/projects/aijproject/devices/aijproject-voice-kit-dfab0b2a-9abc-4b3c-be51-e9cd1e423f48 HTTP/1.1" 404 None DEBUG:urllib3.connectionpool:https://embeddedassistant.googleapis.com:443 "POST /v1alpha2/projects/aijproject/devices HTTP/1.1" 200 None INFO:aiy.assistant.grpc:device_model_id: aijproject-voice-kit INFO:aiy.assistant.grpc:device_id: aijproject-voice-kit-dfab0b2a-9abc-4b3c-be51-e9cd1e423f48 DEBUG:google.auth.transport.requests:Making request: POST https://oauth2.googleapis.com/token DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oauth2.googleapis.com:443 DEBUG:urllib3.connectionpool:https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 200 None INFO:aiy.assistant.grpc:Connecting to embeddedassistant.googleapis.com INFO:root:Press button to start conversation... ^CTraceback (most recent call last): File "voice/assistant_grpc_demo.py", line 57, in <module> main() File "voice/assistant_grpc_demo.py", line 52, in main board.button.wait_for_press() File "/home/pi/AIY-projects-python/src/aiy/board.py", line 164, in wait_for_press return event.wait(timeout) File "/usr/lib/python3.7/threading.py", line 552, in wait signaled = self._cond.wait(timeout) File "/usr/lib/python3.7/threading.py", line 296, in wait waiter.acquire() KeyboardInterrupt pi@raspberrypi-aiy:~/AIY-voice-kit-python/src/examples $ - 一応デモソフトは動作するようだ。 ** デバイスの登録 [#x3d89400] > [[Google Actionページ>+https://console.actions.google.com/]] にアクセスし、デバイスを登録する。~ #ref(voice_kit30m.jpg,left,around,13%,voice_kit30m.jpg) ●「New Project」を押し登録してあるプロジェクト名を入れる。~ #clear #ref(voice_kit31m.jpg,left,around,13%,voice_kit31m.jpg) ●「Language」→ Japanese 「Country」→ Japan を選択して「inprt project」を押す。~ #clear #ref(voice_kit32m.jpg,left,around,13%,voice_kit32m.jpg) ●「Device registration」を選択する。~ #clear #ref(voice_kit33m.jpg,left,around,13%,voice_kit33m.jpg) ● デモソフトの実行ですでにモデルが登録されている。~ ● 登録されている名前を選択する。~ #clear ***「traits」の設定 [#p5e08909] #ref(voice_kit34m.jpg,left,around,13%,voice_kit34m.jpg) ● Product name:Voice Kit~ ● Model Id :aijproject-voice-kit~ ● Manufacturer name :AIY Projects~ ● Device type :Speaker~ ● 右端のペンマークを押して「traits」の設定をする。~ #clear #ref(voice_kit35m.jpg,left,around,13%,voice_kit35m.jpg) ● On/Off と Start/Stop にチェックを入れる。 ●「Save」を押す。~ #clear #ref(voice_kit36m.jpg,left,around,13%,voice_kit36m.jpg) ●「traits」の項目が追加される。~ #clear ** デモプログラムを再実行する [#sb1e0f01] -「Voice Kit」のタクトSWとLED を追加してデモプログラムを実行する。 #ref(画像一覧/20200314_173510_001s.jpg,left,around,25%,20200314_173510_001s.jpg) #ref(画像一覧/fig7.jpg,left,around,25%,fig7.jpg) ・基本的に push_talk プログラムで、スイッチを押してから話しかける。~ ・hot-word のデモソフトではない。~ ・サイトには「次のステップ」の項目があるので、こちらの方を進めていく方が期待できる。 #clear pi@raspberrypi-aiy:~ $ cd AIY-projects-python pi@raspberrypi-aiy:~/AIY-projects-python $ ls CHANGES.md CONTRIBUTING.md HACKING.md LICENSE MANIFEST.in Makefile README.md checkpoints docs schematics scripts setup.py src stdeb.cfg pi@raspberrypi-aiy:~/AIY-projects-python $ src/examples/voice/assistant_grpc_demo.py DEBUG:google.auth.transport.requests:Making request: POST https://oauth2.googleapis.com/token DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oauth2.googleapis.com:443 DEBUG:urllib3.connectionpool:https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 200 None INFO:aiy.assistant.grpc:device_model_id: aijproject-voice-kit INFO:aiy.assistant.grpc:device_id: aijproject-voice-kit-dfab0b2a-9abc-4b3c-be51-e9cd1e423f48 DEBUG:google.auth.transport.requests:Making request: POST https://oauth2.googleapis.com/token DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oauth2.googleapis.com:443 DEBUG:urllib3.connectionpool:https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 200 None INFO:aiy.assistant.grpc:Connecting to embeddedassistant.googleapis.com INFO:root:Press button to start conversation... INFO:root:Conversation started! INFO:aiy.assistant.grpc:Recording started. INFO:aiy.assistant.grpc:You said: "今日". INFO:aiy.assistant.grpc:You said: "今日の". INFO:aiy.assistant.grpc:You said: "今日のて". INFO:aiy.assistant.grpc:You said: "今日の天". INFO:aiy.assistant.grpc:You said: "今日の天気". INFO:aiy.assistant.grpc:You said: "今日の天気は". INFO:aiy.assistant.grpc:You said: "今日の天気は". INFO:aiy.assistant.grpc:You said: "今日の天気は". INFO:aiy.assistant.grpc:End of audio request detected. INFO:aiy.assistant.grpc:You said: "今日の天気は". INFO:aiy.assistant.grpc:Assistant said: "足元に注意してお出かけください 今日の八尾は、予想最高気温12度、最低気温7度で、断続的に雨が降るでしょう。 現在気温8度、雨です。 --- (weather.com でもっと見る)" INFO:aiy.assistant.grpc:Not expecting follow-on query from user. INFO:aiy.assistant.grpc:Recording stopped. INFO:aiy.assistant.grpc:Playing started. INFO:aiy.assistant.grpc:Playing stopped. INFO:root:Press button to start conversation... INFO:root:Conversation started! INFO:aiy.assistant.grpc:Recording started. INFO:aiy.assistant.grpc:You said: "今". INFO:aiy.assistant.grpc:You said: "今の". INFO:aiy.assistant.grpc:You said: "今何". INFO:aiy.assistant.grpc:You said: "今何時". INFO:aiy.assistant.grpc:End of audio request detected. INFO:aiy.assistant.grpc:You said: "今何時". INFO:aiy.assistant.grpc:You said: "今何時". INFO:aiy.assistant.grpc:Assistant said: "時刻は、9:23です。" INFO:aiy.assistant.grpc:Not expecting follow-on query from user. INFO:aiy.assistant.grpc:Playing started. INFO:aiy.assistant.grpc:Recording stopped. INFO:aiy.assistant.grpc:Playing stopped. INFO:root:Press button to start conversation... INFO:root:Conversation started! INFO:aiy.assistant.grpc:Recording started. INFO:aiy.assistant.grpc:You said: "さや". INFO:aiy.assistant.grpc:You said: "佐用". INFO:aiy.assistant.grpc:You said: "さような". INFO:aiy.assistant.grpc:You said: "さようなら". INFO:aiy.assistant.grpc:End of audio request detected. INFO:aiy.assistant.grpc:You said: "さようなら". INFO:aiy.assistant.grpc:Recording stopped. INFO:aiy.assistant.grpc:Assistant said: "はい、ありがとうございました??" INFO:aiy.assistant.grpc:Not expecting follow-on query from user. INFO:aiy.assistant.grpc:Playing started. INFO:aiy.assistant.grpc:Playing stopped. INFO:root:Press button to start conversation... ^CTraceback (most recent call last): File "src/examples/voice/assistant_grpc_demo.py", line 57, in <module> main() File "src/examples/voice/assistant_grpc_demo.py", line 52, in main board.button.wait_for_press() File "/home/pi/AIY-projects-python/src/aiy/board.py", line 164, in wait_for_press return event.wait(timeout) File "/usr/lib/python3.7/threading.py", line 552, in wait signaled = self._cond.wait(timeout) File "/usr/lib/python3.7/threading.py", line 296, in wait waiter.acquire() KeyboardInterrupt pi@raspberrypi-aiy:~/AIY-projects-python $ #br * 参考資料 [#f1561dd0] ** Voise Kit を Raspberry Pi 上で動かす [#b506d8f6] - [[AIY ProjectのVoice KitをVocie Kitなしでやってみた>+https://intellectualcuriosity.hatenablog.com/entry/2017/06/18/030506]] - [[How to build your own digital assistant with a Raspberry Pi>+https://www.androidauthority.com/build-google-assistant-raspberry-pi-770296/]] ** カスタマイズ関連 [#e41ef83f] - [[Google Assistant SDKサンプルコードをカスタマイズ>+https://www.pentacreation.com/blog/2017/07/170706.html]] #br