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
150
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
130
JP_Stripes 5th anniversary - Plan migration consideration -
haruharuharuby
0
73
Alexa Warming Up my Live Stream!
haruharuharuby
1
56
AAJUG meetup September
haruharuharuby
0
18
How Voice Technology is Changing Customer Experience from Brain Perspectives
haruharuharuby
0
40
IVSの盛り上げ役にAlexaをつかってみようか
haruharuharuby
0
600
Let's make a blog with live streaming in 10 minutes
haruharuharuby
0
490
Alexa Audio Player @Deep Diving
haruharuharuby
0
250
VoiceLunchJp#02 Share VUI App and reputation
haruharuharuby
1
230
Other Decks in Technology
See All in Technology
Databricks における 『MLOps』
databricksjapan
2
170
テストプロセスで大事にしていること #jasstnano
makky_tyuyan
0
160
Kernel MemoryでAzure OpenAI Serviceとお手軽データソース連携
mitsuzono
1
190
VSCodeの拡張機能を作っている話
ebarakazuhiro
1
200
本当のAWS基礎
toru_kubota
0
490
家族アルバム みてねにおけるGrafana活用術 / Grafana Meetup Japan Vol.1 LT
isaoshimizu
1
280
レガシーをぶっ壊せ。AEONで始めるDevRelの話 / Qiita Night 2024-2-22
aeonpeople
3
1.3k
Java EE/Jakarta EEの現状と将来―クラウドネイティブ時代にJava EEは対応できるのか?―
takakiyo
1
130
私が trocco を推す理由
__allllllllez__
1
200
生産性向上チームの紹介
cybozuinsideout
PRO
1
860
Janus
bkuhlmann
1
490
オーナーシップを持つ領域を明確にする
konifar
13
3.1k
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
42
12k
Atom: Resistance is Futile
akmur
259
25k
Designing for humans not robots
tammielis
248
25k
Producing Creativity
orderedlist
PRO
337
39k
Ruby is Unlike a Banana
tanoku
96
10k
Designing Experiences People Love
moore
136
23k
Being A Developer After 40
akosma
57
580k
YesSQL, Process and Tooling at Scale
rocio
164
13k
Fontdeck: Realign not Redesign
paulrobertlloyd
76
4.9k
Building Your Own Lightsaber
phodgson
99
5.7k
How to train your dragon (web standard)
notwaldorf
73
5.2k
The Mythical Team-Month
searls
216
42k
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
ありがとうございました。