Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Making a self Alexa client Ver.TOKYO

haruharuharuby
September 14, 2016

Making a self Alexa client Ver.TOKYO

2016.09.14(Wed) JAWS-UG IoT Salon with Alexa meetup #02.
Collaborate JAWS-UG IoT dedicated branch with JAWS-UG-KOBE

How to make Alexa self client basics

haruharuharuby

September 14, 2016
Tweet

More Decks by haruharuharuby

Other Decks in Technology

Transcript

  1. Making a self Alexa client 2016.09.14 JAWS-UG IoT専門支部 with JAWS-UG-KOBE

    IoTサロン 2016-09 feat. Alexa meetup #02. Ver. TOKYO
  2. 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_s ecret=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" }
  3. 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.b91a4d2fd2 f6&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" }
  4. Connection :method = GET :scheme = https :path = /v20160207/directives

    authorization = Bearer {{YOUR_ACCESS_TOKEN}}
  5. Synchronization :method = POST :scheme = https :path = /v20160207/events

    authorization = Bearer {{YOUR_ACCESS_TOKEN}} content-type = multipart/form-data; boundary={{BOUNDARY_TERM_HERE}}
  6. Synchronization(つづき) --{{BOUNDARY_TERM_HERE}} Content-Disposition: form-data; name="metadata" Content-Type: application/json; charset=UTF-8 { "context":

    [], "event": { "header": { "namespace": "System", "name": "SynchronizeState", "messageId": "{{STRING}}" }, "payload": { } } } --{{BOUNDARY_TERM_HERE}}--
  7. { "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}}
  8. { "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}}
  9. 宣伝1:JAWS-UG-KOBE • Atsushi Ando • Kazuto Takeshita • Tomoharu Ito

    https://www.facebook.com/groups/450069605016080/ https://jaws-ug-kobe.doorkeeper.jp/
  10. https://github.com/jaws-ug-kobe/ AlexaPi.git Alexa Client for Raspberry PI coded by python

    旧API(=v1)でAVSと接続しています。(2016/09/11時点) 宣伝2