Pro Yearly is on sale from $80 to $50! »

Alexa Skills kit SDK for Python
を使ってみた

A73ed5cefbbd84abd2c5e14a5eb4a339?s=47 Ippei Sumida
September 03, 2018

Alexa Skills kit SDK for Python
を使ってみた

AAJUG Vol.2でLTしたスライドです。 #aajug

A73ed5cefbbd84abd2c5e14a5eb4a339?s=128

Ippei Sumida

September 03, 2018
Tweet

Transcript

  1. Alexa Skills kit SDK for Python
 Λ࢖ͬͯΈͨ 2018.09.03 AAJUG #2

  2. # whoami - ֯ాɹҰฏʢ͢Έͩɹ͍ͬ΃͍ʣ - ϑϦʔϥϯε - PHPͱ͔ - CoderDojoຕํ΍ͬͯ·͢

    - Alexa Skill Contest
 Լ͔Β਺͑ͯ2Ґ
  3. ※࢖ͬͯΈͨϨϕϧͰ͢ɻ
 ʢ·ͩεΩϧ࡞ͬͯΔ్தʣ

  4. None
  5. None
  6. ͍ͭ࠷ۙެ͔ࣜΒ
 Python༻ͷSDK͕ൃදʂ

  7. Requirement • Python 2.7, Python 3.6Ҏ্ • VirtualenvʢԾ૝؀ڥߏஙπʔϧʣ • Lambda͕࢖͑Δ

  8. What’s Python ?

  9. Python • ίʔυ͕γϯϓϧ • ίʔυྔ͕গͳ͍ • Մಡੑ͕ߴ͍

  10. ࢖ͬͯΈͨ

  11. Πϯετʔϧ virtualenv skill source skill/bin/activate pip install ask-sdk

  12. from ask_sdk_core.skill_builder import SkillBuilder from ask_sdk_core.dispatch_components import AbstractRequestHandler from ask_sdk_model.ui

    import SimpleCard from ask_sdk_core.utils import is_intent_name, is_request_type class HelloWorldIntentHandler(AbstractRequestHandler): def can_handle(self, handler_input): return is_request_type("IntentRequest") and is_intent_name("HelloWorldIntent") def handle(self, handler_input): speech_text = "Hello World"; return handler_input.response_builder.speak(speech_text).set_card( SimpleCard("Hello World", speech_text)).response sb = SkillBuilder() sb.request_handlers.extend([ HelloWorldIntentHandler() ]) handler = sb.lambda_handler() Ϋϥεόʔδϣϯ
  13. from ask_sdk_core.skill_builder import SkillBuilder from ask_sdk_core.utils import is_intent_name from ask_sdk_model.ui

    import SimpleCard sb = SkillBuilder() @sb.request_handler(can_handle_func=is_intent_name("HelloWorldIntent")) def hello_world_intent_handler(handler_input): speech_text = "Hello World!" return handler_input.response_builder.speak(speech_text).set_card( SimpleCard("Hello World", speech_text)).response handler = sb.lambda_handler() σίϨʔλʔόʔδϣϯ
  14. ʢݸਓతʹʣ ݟ௨͕͠ྑ͍ʂ

  15. ख์͠Ͱ͸ت΂ͳ͍

  16. lambda΁ͷΞοϓϩʔυ
 ϑΝΠϧ࡞੒

  17. node.jsͷ৔߹

  18. cd /path/to/project zip project.zip .

  19. 6.5MB

  20. Pythonͷ৔߹

  21. cd /path/to/project zip project.zip project.py cd venv/lib/python3.6/site-packages zip -r9g /path/to/project/project.zip

    .
  22. 12.2MB

  23. Node.js > Python खؒతʹ

  24. Node.js < Python ݸਓతʹ