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
750
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
変化する開発、進化する体系時代に適応するソフトウェアエンジニアの知識と考え方(JaSST'25 Kansai)
mizunori
1
210
PostgreSQL 18 cancel request key長の変更とRailsへの関連
yahonda
0
120
VISITS_AIIoTビジネス共創ラボ登壇資料.pdf
iotcomjpadmin
0
160
急成長を支える基盤作り〜地道な改善からコツコツと〜 #cre_meetup
stefafafan
0
120
監視のこれまでとこれから/sakura monitoring seminar 2025
fujiwara3
11
3.9k
Witchcraft for Memory
pocke
1
310
ひとり情シスなCTOがLLMと始めるオペレーション最適化 / CTO's LLM-Powered Ops
yamitzky
0
430
250627 関西Ruby会議08 前夜祭 RejectKaigi「DJ on Ruby Ver.0.1」
msykd
PRO
2
270
「Chatwork」の認証基盤の移行とログ活用によるプロダクト改善
kubell_hr
1
150
Oracle Cloud Infrastructure:2025年6月度サービス・アップデート
oracle4engineer
PRO
2
240
AWS CDK 実践的アプローチ N選 / aws-cdk-practical-approaches
gotok365
6
740
Amazon ECS & AWS Fargate 運用アーキテクチャ2025 / Amazon ECS and AWS Fargate Ops Architecture 2025
iselegant
16
5.5k
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
How to train your dragon (web standard)
notwaldorf
93
6.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Embracing the Ebb and Flow
colly
86
4.7k
The Cost Of JavaScript in 2023
addyosmani
51
8.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Done Done
chrislema
184
16k
Balancing Empowerment & Direction
lara
1
370
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
ありがとうございました。