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
怖くない!はじめてのClaude Code
shinya337
0
400
改めてAWS WAFを振り返る~業務で使うためのポイント~
masakiokuda
2
260
LangSmith×Webhook連携で実現するプロンプトドリブンCI/CD
sergicalsix
1
240
Lazy application authentication with Tailscale
bluehatbrit
0
210
ゼロからはじめる採用広報
yutadayo
3
950
PO初心者が考えた ”POらしさ”
nb_rady
0
210
United Airlines Customer Service– Call 1-833-341-3142 Now!
airhelp
0
170
AIの全社活用を推進するための安全なレールを敷いた話
shoheimitani
2
520
AWS Organizations 新機能!マルチパーティ承認の紹介
yhana
1
280
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
10
130k
成長し続けるアプリのためのテストと設計の関係、そして意思決定の記録。
sansantech
PRO
0
120
AWS認定を取る中で感じたこと
siromi
1
190
Featured
See All Featured
Side Projects
sachag
455
42k
Typedesign – Prime Four
hannesfritz
42
2.7k
Fireside Chat
paigeccino
37
3.5k
Automating Front-end Workflow
addyosmani
1370
200k
Building Applications with DynamoDB
mza
95
6.5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Agile that works and the tools we love
rasmusluckow
329
21k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
4 Signs Your Business is Dying
shpigford
184
22k
Music & Morning Musume
bryan
46
6.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
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
ありがとうございました。