Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Google Assistant with Raspberry Pi
Search
Yuki Anzai
June 22, 2017
Technology
3
520
Google Assistant with Raspberry Pi
Yuki Anzai
June 22, 2017
Tweet
Share
More Decks by Yuki Anzai
See All by Yuki Anzai
MediaPipe と ML Kit ってどう ちがうの? / What is the difference between MediaPipe and ML Kit?
yanzm
0
760
アプリをリリースできる状態に保ったまま 段階的にリファクタリングするための 戦略と戦術 / Strategies and tactics for incremental refactoring
yanzm
8
3.9k
Kotlinらしいコードを書こう - Convert Java File to Kotlin File のあとにやること / What to do after Convert Java File to Kotlin File
yanzm
1
4.8k
個人アプリ開発 (メンテナンス) 14年の歴史 / My personal app development history
yanzm
1
870
Material 3 やめました / Good-bye M3 design system
yanzm
4
7.8k
Compose Multiplatform で Bluesky のクライアント作ってみた / Bluesky client with Compose Multiplatform
yanzm
0
600
Compose Transition Animation
yanzm
3
710
Material3 with Jetpack Compose
yanzm
3
3.8k
Jetpack Compose 1.2 新機能 / new features of Jetpack Compose 1.2
yanzm
0
510
Other Decks in Technology
See All in Technology
Amazon Kendra GenAI Index 登場でどう変わる? 評価から学ぶ最適なRAG構成
naoki_0531
0
110
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
200
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
310
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
280
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
170
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
10
7.9k
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
2
110
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
36
13k
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
3
2.3k
ゼロから創る横断SREチーム 挑戦と進化の軌跡
rvirus0817
2
270
Featured
See All Featured
Site-Speed That Sticks
csswizardry
2
190
Git: the NoSQL Database
bkeepers
PRO
427
64k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Building an army of robots
kneath
302
44k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
Designing for Performance
lara
604
68k
A better future with KSS
kneath
238
17k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
A designer walks into a library…
pauljervisheath
204
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Transcript
Raspberry Pi Ͱ Google Assistant Λମݧ͠Α͏ ͋Μ͍͟Ώ͖ʢ@yanzmʣ GTUG Girls Meet
Up #33
ࢿྉ goo.gl/CDHpi4
Google Assistant • https://assistant.google.com/ • SDK • https://developers.google.com/assistant/sdk/ prototype/getting-started-pi-python/
ඞཁͳͷ • Raspberry Pi 3ʢRaspberry Pi 2 + WiFiυϯάϧͰ Մʣ
• Raspbian JessieͷΠϯετʔϧ͞ΕͨmicroSD • ిݯΞμϓλ ͘͠ microUSBέʔϒϧ • USB ϚΠΫ ͘͠ϚΠΫଂܕͷUSBΧϝϥ • εϐʔΧʔʢUSB or 3.5mmδϟοΫʣ
४උ • Raspberry Pi Λ WiFi ʹଓ͢Δ
४උ • Raspberry Pi ͰίϯιʔϧΛ։͖ɺifconfig ίϚϯ υΛ࣮ߦͯ͠IPΞυϨεΛϝϞ͢Δ
४උ • Raspberry Pi Ͱ SSH Λ༗ޮʹ͢Δ • Preferences -
Raspberry Pi Configuration - Interfaces • SSH Λ Enabled ʹͯ͠ OK ΛΫϦοΫ
४උ2 • ࣌ࠁઃఆΛ֬ೝ͢Δʢ͕࣌ؒਖ਼͚͠ΕOKʣ • JST ʹ͍ͨ͠ͳΒ • Preferences - Raspberry
Pi Configuration - Localisation • Set Timezone ΛΫϦοΫ • Area: Asia, Location: Tokyo • ࠶ىಈ
४උ3 • Raspberry Pi ʹ PC ͔Β SSH ͰϩάΠϯ͢Δ $
ssh pi@[ϝϞͨ͠IPΞυϨε] password: [σϑΥϧτraspberry] • ࣌ࠁઃఆΛ֬ೝ͢Δʢ͕࣌ؒਖ਼͚͠ΕOKʣ $ date
։ൃϓϩδΣΫτͱ ΞΧϯτͷઃఆ • https://developers.google.com/assistant/sdk/ prototype/getting-started-pi-python/config-dev- project-and-account Λ։͘ • goo.gl/GxLUSW •
Ҏ߱ɺ͜ͷϖʔδΛʮઃఆखॱυΩϡϝϯτʯͱݺ ͼ·͢ɻ
৽͍͠ϓϩδΣΫτΛ࡞Δ - 1 • ʮઃఆखॱυΩϡϝϯτʯʹ͋Δ GO TO THE PROJECT PAGE
ϘλϯΛΫϦοΫ͢Δ
৽͍͠ϓϩδΣΫτΛ࡞Δ - 2 • ্ͷํʹ͋ΔϓϩδΣΫτΛ࡞ΛΫϦοΫ • ϓϩδΣΫτ໊Λೖྗͯ͠࡞ΛΫϦοΫ • ͳΜͰΑ͍Ͱ͢ɻAssistant with
Raspberry Pi ͱ͔
Google Assistant API ༗ޮԽ • ʮઃఆखॱυΩϡϝϯτʯʹ͋Δ ENABLE THE API ϘλϯΛΫϦοΫ͢Δ
OAuth Client ID ͷઃఆ - 1 • OAuth ಉҙը໘Λઃఆ͢Δ
OAuth Client ID ͷઃఆ - 2 • OAuth ΫϥΠΞϯτ ID
Λ࡞͢Δ
OAuth Client ID ͷઃఆ - 3 • OAuth ΫϥΠΞϯτ ID
Λ࡞͢Δ • μΠΞϩά͕දࣔ͞ΕͨΒ OK ΛΫϦοΫ
OAuth Client ID ͷઃఆ - 4 • ΫϥΠΞϯτ ID secret
JSON ϑΝΠϧΛμϯ ϩʔυ
OAuth Client ID ͷઃఆ - 5 • μϯϩʔυͨ͠ΫϥΠΞϯτ ID secret
JSON ϑΝΠϧΛ Raspberry Pi ʹసૹ $ scp [μϯϩʔυͨ͠JSONϑΝΠϧ] pi@[ϝϞ ͨ͠IPΞυϨε]:/home/pi/ password: [σϑΥϧτraspberry]
ΞΫςΟϏςΟίϯτϩʔϧͷ ઃఆ - 1 • ʮઃఆखॱυΩϡϝϯτʯͷԼͷํʹ͋Δ Activity Controls page ͷϦϯΫΛ։͘
ΞΫςΟϏςΟίϯτϩʔϧͷ ઃఆ - 2 • ҎԼͷ߲Λ༗ޮʹ͢Δ • ΣϒͱΞϓϦͷΞΫςΟϏςΟ • ϩέʔγϣϯཤྺ
• ใ • ԻΞΫςΟϏςΟ
Իͷઃఆͱ֬ೝ - 0 • RaspberryPi ʹ SSH ͰϩάΠϯ͢Δ
Իͷઃఆͱ֬ೝ - 1 • εϐʔΧʔͷςετ • Front, Left ͕܁Γฦ͠ฉ͑͜ΕOK •
Ի͕໐Βͳ͍ਓ࣍ͷεϥΠυ $ speaker-test -t wav
εϐʔΧʔ͔ΒԻ͕໐Βͳ͍ ਓ͜ΕΛΔ $ sudo raspi-config • ʲAdvanced OptionsʳΛબ • ʲAudioʳΛબ
• ʲForce 3.5mmʢ'headphone'ʣjackʳΛબ
Իͷઃఆͱ֬ೝ - 2 • ϚΠΫͷςετʢ5ඵؒԻʣ • Τϥʔ͕ग़ͳ͔ͬͨΒదʹ͠Όͬͯ 7 •
Τϥʔ͕ग़ͨΒ 3ʢ࣍ʣ $ arecord --format=S16_LE --duration=5 -- rate=16k --file-type=raw out.raw
Իͷઃఆͱ֬ೝ - 3 • ϚΠΫͷΧʔυ൪߸ͱσόΠε൪߸ΛௐΔ • ͜ΕͳΒΧʔυ൪߸ 1, σόΠε൪߸ 0
$ arecord -l **** List of CAPTURE Hardware Devices **** card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Իͷઃఆͱ֬ೝ - 4 • εϐʔΧʔͷΧʔυ൪߸ͱσόΠε൪߸ΛௐΔ • ͜ΕͳΒΧʔυ൪߸ 0, σόΠε൪߸ 0
$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Իͷઃఆͱ֬ೝ - 5 • SSH ͷଓΛΔ • ઃఆϑΝΠϧΛ࡞Δ • ϑΝΠϧ໊
: .asoundrc • ༰: ࣍ͷεϥΠυ
pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic
{ type plug slave { pcm "hw:[ϚΠΫͷΧʔυ൪߸],[ϚΠΫͷσόΠε൪߸]" } } pcm.speaker { type plug slave { pcm "hw:[εϐʔΧʔͷΧʔυ൪߸],[εϐʔΧʔͷσόΠε൪߸]" } }
pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic
{ type plug slave { pcm "hw:1,0" } } pcm.speaker { type plug slave { pcm "hw:1,1" } } ྫʣ
Իͷઃఆͱ֬ೝ - 6 • Raspberry Pi ͷ /home/pi/ ʹஔ͘ •
2 ʹΔ $ scp .asoundrc pi@[ϝϞͨ͠IPΞυϨε]:/ home/pi/ password: [σϑΥϧτraspberry]
Իͷઃఆͱ֬ೝ - 7 • 2ͰԻͨ͠ԻΛ࠶ੜ • ͳ͘Ի͞Ε͍ͯΕ OK • Իྔͷௐઅ
$ aplay --format=S16_LE --rate=16k out.raw $ alsamixer
Python ͷઃఆ • Python virtual environment ΛͬͯγεςϜͷ Python ύοέʔδ͔Β SDK
ͱґଘ͢ΔΖΖΛ ִ • ݱঢ় Google Assistant ͷϥΠϒϥϦ Python 3.x ͰͷΈಈ͘ • Πϯετʔϧͷ్தͰฉ͔ΕͨΒ y ͰਐΜͰͩ͘͞ ͍
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
ϥΠϒϥϦͱαϯϓϧίʔυ Λऔͬͯ͘Δ (env) $ python -m pip install --upgrade google-assistant-library
αϯϓϧίʔυͷೝূ - 1 • ϒϥβΛ։͍ͯ Google ΞΧϯτʹϩάΠϯ͢ Δ • ΞΫςΟϏςΟίϯτϩʔϧͷઃఆΛͨͭ͠
• ೝূπʔϧΛΠϯετʔϧ͢Δ (env) $ python -m pip install --upgrade google-auth-oauthlib[tool]
αϯϓϧίʔυͷೝূ - 2 • ೝূπʔϧΛ࣮ߦ͢Δ • จࣈίʔυͷΤϥʔ͕ग़ͨΒ (env) $ google-oauthlib-tool
--client- secrets /home/pi/[લʹసૹ͓͍ͯͨ͠JSON] -- scope https://www.googleapis.com/auth/ assistant-sdk-prototype --save --headless (env) $ export LC_ALL=C.UTF-8 (env) $ export LANG=C.UTF-8
• ͱදࣔ͞ΕΔͷͰ … ෦ͷ URL Λίϐʔͯ͠ϒϥ βʹషΓ͚ͯදࣔ • ΞΧϯτΛબʢඞཁͳ߹ʣ͠ɺALLOW ʢڐ
ՄʣΛΫϦοΫ • දࣔ͞ΕΔίʔυΛίϐʔ͠ Please visit this URL to authorize this application: … Enter the authorization code: • ʹೖྗ
αϯϓϧίʔυͷ࣮ߦ • OK, google. What’s the weather in Tokyo •
ͱݴͬͯΈΑ͏ (env) $ google-assistant-demo