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
39
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
「Chatwork」のEKS環境を支えるhelmfileを使用したマニフェスト管理術
hanayo04
1
400
ClaudeCode_vs_GeminiCLI_Terraformで比較してみた
tkikuchi
1
1k
20250708オープンエンドな探索と知識発見
sakana_ai
PRO
4
1k
Amplify Gen2から知るAWS CDK Toolkit Libraryの使い方/How to use the AWS CDK Toolkit Library as known from Amplify Gen2
fossamagna
1
350
OpenTelemetryセマンティック規約の恩恵とMackerel APMにおける活用例 / SRE NEXT 2025
mackerelio
3
2k
衛星運用をソフトウェアエンジニアに依頼したときにできあがるもの
sankichi92
1
1k
ゼロから始めるSREの事業貢献 - 生成AI時代のSRE成長戦略と実践 / Starting SRE from Day One
shinyorke
PRO
0
110
TLSから見るSREの未来
atpons
2
310
ロールが細分化された組織でSREは何をするか?
tgidgd
1
420
データ戦略部門 紹介資料
sansan33
PRO
1
3.3k
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
18k
Delegating the chores of authenticating users to Keycloak
ahus1
0
190
Featured
See All Featured
Gamification - CAS2011
davidbonilla
81
5.4k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
The Cult of Friendly URLs
andyhume
79
6.5k
Being A Developer After 40
akosma
90
590k
KATA
mclloyd
30
14k
Side Projects
sachag
455
42k
Music & Morning Musume
bryan
46
6.7k
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
ありがとうございました。