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
610
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 VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
200
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
380
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
200
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
270
事業貢献を考えるための技術改善の目標設計と改善実績 / Targeted design of technical improvements to consider business contribution and improvement performance
oomatomo
0
100
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
180
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
150
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
290
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
200
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
360
Storage Browser for Amazon S3
miu_crescent
1
240
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
360
Featured
See All Featured
Facilitating Awesome Meetings
lara
50
6.1k
Why Our Code Smells
bkeepers
PRO
335
57k
KATA
mclloyd
29
14k
The Cult of Friendly URLs
andyhume
78
6.1k
Gamification - CAS2011
davidbonilla
80
5.1k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Documentation Writing (for coders)
carmenintech
66
4.5k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Practical Orchestrator
shlominoach
186
10k
A designer walks into a library…
pauljervisheath
204
24k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.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