一个用于构建alexa技能的python包。

skillful的Python项目详细描述


|PyPIVersion||BuildStatus||Coverage|

一个用于构建amazon-alexa技能的python包。

功能

  • custom skills
  • 的请求和响应对象
  • 每个请求类型的响应逻辑的简单定义
  • 内置的请求解析/验证、意图分派和响应 结构

安装

pip install skillful

示例

import skillful
from skillful.tests import data

application_id = 'amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe'
skill = skillful.Skill(application_id)

@skill.launch
def on_launch():
    print('Launched: {}'.format(skill.request.session.session_id))
    text = 'Welcome to skillful. Would you like to build an Alexa skill?'
    skill.response.set_speech_text(text)
    ssml = ('<speak>Please tell me if you would like to build an Alexa '
            'skill.</speak>')
    skill.response.set_reprompt_ssml(ssml)

@skill.intent('yes')
def on_intent_yes():
    text = ('Great! Building Alexa skills is easy with skillful. Open '
            'the Alexa app to see more information on skillful, a '
            'Python package for building Alexa skills.')
    skill.response.set_speech_text(text)
    title = 'skillful'
    content = ('A Python package for building Alexa skills.\n\n'
               'Visit: https://github.com/bmweiner/skillful')
    skill.response.set_card_simple(title, content)
    skill.terminate()

@skill.intent('no')
def on_intent_no():
    text = ('Well, if you change your mind, open the Alexa app to see '
            'more information on skillful, a Python package for '
            'building Alexa skills.')
    skill.response.set_speech_text(text)
    title = 'skillful'
    content = ('A Python package for building Alexa skills.\n\n'
               'Visit: https://github.com/bmweiner/skillful')
    skill.response.set_card_simple(title, content)
    skill.terminate()

@skill.session_ended
def on_session_ended():
    print('Ended: {}'.format(skill.request.session.session_id))
    skill.terminate()

# simulate request body
body = data.SAMPLE_LAUNCH_REQUEST
skill.process(body)

输出:

Launched: amzn1.echo-api.session.0000000-0000-0000-0000-00000000000

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "text": "Welcome to skillful. Would you like to build an Alexa skill?",
      "type": "PlainText"
    },
    "shouldEndSession": false,
    "reprompt": {
      "outputSpeech": {
        "ssml": "<speak>Please tell me if you would like to build an Alexa skill.</speak>",
        "type": "SSML"
      }
    }
  }
}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
mysql对象引用返回空Java   正则表达式在Java中查找包含3个字母的单词   java如何从单独的面板更改CardLayout面板?   java将目录和文件从res/raw文件夹复制到sd卡安卓   java将日期更改为日历   java让我找到了实现存储XML文件的文件I/O性能的最佳方法   java如何创建自定义JPanel扩展并从NetBeans调色板使用它?   java解析来自httpsampler 1的responsedata并在sampler 2中使用它。我没有使用JMeterUI   java为什么在使用简单json库后无法比较字符串?   java如何在没有firebase的情况下创建安卓聊天应用程序?   HibernateHQL:查询java的值。util。地图   在am图像java中填充数据等于0的点   使用C#/Java/Visual Basic填充Word 2007模板   java随机数,范围不包括零   java使用SOAPHandler在SOAPBody响应中创建父元素   java重写数组   使用jsp脚本中生成的索引访问javascript Arraylist   java如何从瞬间和时间字符串构造ZoneDateTime?   Java2D:如何绘制圆弧?   java用相应的getter/setter搜索/替换属性