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
How to make Alexa self client
Search
haruharuharuby
July 27, 2016
Technology
0
180
How to make Alexa self client
2016.07.27(Wed) JAWS-UG-KOBE Study meeting
Alexa Meetup.
How to make Alexa self client basics
haruharuharuby
July 27, 2016
Tweet
Share
More Decks by haruharuharuby
See All by haruharuharuby
Effective AWS Step Functions
haruharuharuby
0
170
JP_Stripes 5th anniversary - Plan migration consideration -
haruharuharuby
0
84
Alexa Warming Up my Live Stream!
haruharuharuby
1
81
AAJUG meetup September
haruharuharuby
0
38
How Voice Technology is Changing Customer Experience from Brain Perspectives
haruharuharuby
0
65
IVSの盛り上げ役にAlexaをつかってみようか
haruharuharuby
0
760
Let's make a blog with live streaming in 10 minutes
haruharuharuby
0
510
Alexa Audio Player @Deep Diving
haruharuharuby
0
280
VoiceLunchJp#02 Share VUI App and reputation
haruharuharuby
1
290
Other Decks in Technology
See All in Technology
使いたいMCPサーバーはWeb APIをラップして自分で作る #QiitaBash
bengo4com
0
1.9k
LLM時代の検索
shibuiwilliam
2
160
american aa airlines®️ USA Contact Numbers: Complete 2025 Support Guide
aaguide
0
150
SEQUENCE object comparison - db tech showcase 2025 LT2
nori_shinoda
0
140
敢えて生成AIを使わないマネジメント業務
kzkmaeda
2
450
ビギナーであり続ける/beginning
ikuodanaka
3
760
NewSQLや分散データベースを支えるRaftの仕組み - 仕組みを理解して知る得意不得意
hacomono
PRO
2
160
改めてAWS WAFを振り返る~業務で使うためのポイント~
masakiokuda
2
260
What’s new in Android development tools
yanzm
0
310
AI専用のリンターを作る #yumemi_patch
bengo4com
5
4.3k
20250705 Headlamp: 專注可擴展性的 Kubernetes 用戶界面
pichuang
0
270
20250707-AI活用の個人差を埋めるチームづくり
shnjtk
4
3.9k
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
The Cult of Friendly URLs
andyhume
79
6.5k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
950
Designing Experiences People Love
moore
142
24k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Raft: Consensus for Rubyists
vanstee
140
7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Thoughts on Productivity
jonyablonski
69
4.7k
Documentation Writing (for coders)
carmenintech
72
4.9k
Transcript
Making a self Alexa client 2016.07.27 Alexa meetup #01. JAWS-UG-KOBE
自己紹介( TiNm’S ) TiNm’S( ティムズ )と読みます。 プログラマー。 Ruby On Rails、AWSが主戦場。
好きなAWS サービスは、OpsWorks。 花澤香菜ちゃん好き。 JAWS-UG-KOBE コアメンバー。
Alexa Voice Service 1. Overview 2. 認証 3. Request &
Response
Overview
None
デバイスをAVSに認証させる。
Authentication 1. Security Profile 2. Refresh token と access token
3. Refresh tokenとaccess token
1. Security Profile
AVSを利用するデバイスの認証情報 Security Profileをamazon.comの認証URLに送信して、 access_tokenとrefresh tokenを取得する。
None
None
2. access token と refresh token
access token AVSのAPIをCallする際に付与するセキュリティコード Authorization ヘッダーに付与する。 Atza|IQEBLjAsAhQ3yD47Jkj09BfU_qgNk4 Access tokenの有効期間は1時間
refresh token access token の有効期間が過ぎた場合に、再度取得するた めのトークン。 後述する認証方式によっては、必ずしも必要ではない。 Atzr|IQEBLzAtAhUAibmh-1N0EsdqwqwdqdasdvferrE
3. 認証方法
3. 認証方法 2種類のログイン方法 Amazon.comの アカウントとパスワードを入 力する。
Implicit Grant Client IDを送信してログインする。 https://www.amazon.com/ap/oa?client_id=amzn1.application-oa2-client. b91a4d2fd2f641f2a15ea469&scope=alexa%3Aall&scope_data=%7B%22alexa%3Aall%22%3A%7B% 22productID%22%3A%22Speaker%22,%22productInstanceAttributes%22%3A%7B% 22deviceSerialNumber%22%3A%2212345%22%7D%7D% 7D&response_type=token&redirect_uri=https%3A%2F%2Flocalhost http://localhost/?access_token=Atza%
7CIQEBLjAsAhQhzDgHuUPvSgvM&token_type=bearer&expires_in=3600& scope=alexa%3Aall Request Response
Authorization Code Grant Client ID、Client secretを送信してログインする。 https://www.amazon.com/ap/oa?client_id=amzn1.application-oa2-client. b91a4d2fd2f641f2a15ea469&scope=alexa%3Aall&scope_data=%7B%22alexa%3Aall%22%3A%7B% 22productID%22%3A%22Speaker%22,%22productInstanceAttributes%22%3A%7B% 22deviceSerialNumber%22%3A%2212345%22%7D%7D%
7D&response_type=code&redirect_uri=https%3A%2F%2Flocalhost Request Response https://localhost/?code=ANdNAVhyhqirUelHGEHA&scope=alexa%3Aall
Authorization Code Grant Client ID、Client secretを送信してログインする。 https://www.amazon.com/ap/oa?client_id=amzn1.application-oa2-client. b91a4d2fd2f641f2a15ea469&scope=alexa%3Aall&scope_data=%7B%22alexa%3Aall%22%3A%7B% 22productID%22%3A%22Speaker%22,%22productInstanceAttributes%22%3A%7B% 22deviceSerialNumber%22%3A%2212345%22%7D%7D%
7D&response_type=code&redirect_uri=https%3A%2F%2Flocalhost Request Response https://localhost/?code=ANdNAVhyhqirUelHGEHA&scope=alexa%3Aall 次のページへつづく
Authorization Code Grant https://api.amazon.com/auth/o2/token POST /auth/o2/token HTTP/1.1 Host: api.amazon.com Content-Type:
application/x-www-form-urlencoded Cache-Control: no-cache grant_type=authorization_code&code=ANBzsjhYZmNCTeAszagk&client_id=amzn1.application-oa2-client. b91a4d2fd2f64&client_secret=6963038c1c2063c33ab9eedc0cf8&redirect_uri=https%3A%2F%2Flocalhost Request [POST] Response HTTP/1.1 200 OK { "access_token": "Atza|IQEBLjAsAhRBejiZKPfn5HO2562GBt26qt23EA", "expires_in": 3600, "refresh_token": "Atzr|IQEBLzAtAhUAibmh-1N0EsdqwqwdqdasdvferrE", "token_type": "bearer" }
Implicit Grant access tokenは1時間で無効になる。 amazon.comにログインして再認証が必要。
Authorization Code Grant access tokenはrefresh tokenを利用して再認 証なしに更新できる。
access token の更新 https://api.amazon.com/auth/o2/token POST /auth/o2/token HTTP/1.1 Host: api.amazon.com Content-Type:
application/x-www-form-urlencoded Cache-Control: no-cache grant_type=refresh_token&refresh_token=Atzr%7CIQEBLzAtAhUAibmh-1N0E&client_id=amzn1.application-oa2-client. b91a4d2fd2f6&client_secret=6963038c1c2063c33ab9eedc0cf822 Request [POST] Response HTTP/1.1 200 OK { "access_token": "Atza|IQEBLjAsAhRBejiZKPfn5HO2562GBt26qt23EA", "expires_in": 3600, "refresh_token": "Atzr|IQEBLzAtAhUAibmh-1N0EsdqwqwdqdasdvferrE", "token_type": "bearer" }
Request & Response
None
EventとDirectives AVSのAPIをCallする場合、デバイスから AVSにリクエストを送る場合に付与するメッセージのこと。 デバイスからAVSにキャプチャした音声を送る場合は、 SpeechRecognizerインターフェースのrecognize イ ベントを使う。 Event Directives AVSからデバイスにレスポンスとして送られるメッセージのこと。
AVSが応答した音声は、 SpeechSynthesizerインターフェースのSpeakディレクティブメッセージとともにデ バイスに返される。
None
Request
{ "context": [ { "header": { "namespace": "AudioPlayer", "name": "PlaybackState"
}, "payload": { "token": "{{STRING}}", "offsetInMilliseconds": {{LONG}}, "playerActivity": "{{STRING}}" } } ], "event": { "header": { "namespace": "SpeechRecognizer", "name": "Recognize", "messageId": "{{STRING}}", "dialogRequestId": "{{STRING}}" }, "payload": { "profile": "CLOSE_TALK", "format": ""AUDIO_L16_RATE_16000_CHANNELS_1 } } } First Part: json object Second Part: audio binary Content-Disposition: form-data; name="audio" Content-Type: application/octet-stream {{BINARY AUDIO ATTACHMENT}}
Audio binaryのフォーマット • 16bit Linear PCM • 16kHz sample rate
• Single channel • Little endian byte order
Response
{ "directive": { "header": { "namespace": "SpeechSynthesizer", "name": "Speak", "messageId":
"{{STRING}}", "dialogRequestId": "{{STRING}}" }, "payload": { "url": "{{STRING}}", "format": "{{STRING}}", "token": "{{STRING}}" } } } First Part: json object Second Part: audio binary Content-Disposition: form-data; name="audio" Content-Type: application/octet-stream {{BINARY AUDIO ATTACHMENT}}
API Overview https://developer.amazon.com/public/solutions/alexa/alexa-voice- service/content/avs-api-overview Authentication https://developer.amazon.com/public/solutions/alexa/alexa-voice- service/docs/authorizing-your-alexa-enabled-product-from-a-website
ありがとうございました。