
知识补充:
什么是 AWS Lambda?
AWS Lambda 在可用性高的计算基础设施上运行您的代码,执行计算资源的所有管理工作,其中包括服务器和操作系统维护、容量预置和自动扩展、代码监控和记录,只在需要时执行您的代码并自动缩放,从每天几个请求到每秒数千个请求,其提供了 AWS 基础设施的高可用性,高安全性,高功能性和高可扩展性。

具体可参考:
https://docs.aws.amazon.com/zh_cn/lambda/latest/dg/welcome.html
什么是 Alexa Skills Kit?

Alexa 是 Echo 内置的语音助手,通过它能够唤醒 Echo。Alexa 的优点在于,它基于云端,因此我们可以随时对其进行改进。Alexa Skills Kit (ASK)是一个由自服务 API、工具、文件和实例代码的集合,可轻松构建你自定义的 Alexa skills,然后发布。
具体可参考:
https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit
打开链接https://aws.amazon.com/,申请亚马逊AWS账号。登录控制台,选择AWS Lambda服务,创建Lambda Function。

选择Alexa Skills Kit

下载需要用到的代码,解压,打开index.js文件,修改文件中的开发者账号ID,如下:
https://s3.cn-north-1.amazonaws.com.cn/bjsdemo/LambdaAlexaSkillsKit/RecipeTemplate.zip

修改完成之后,然后打成 Zip 包上传(注意,这里的打包不需要文件夹,直接把.js 文件打包成 RecipeTemplate.zip)


接着点击“Create function”

到这里,Lambda 创建成功。

进入https://developer.amazon.com/,创建Alexa Skills Kit。

选择 ALEXA

选择“Alexa Skills Kit”

点击“Add a new Skill”

填写Name: Solution Helper,Invocation Name: solution helper

填写Intent Schema,样例代码下载:
https://s3.cn-north-1.amazonaws.com.cn/bjsdemo/LambdaAlexaSkillsKit/IntentSchema.json

填写Sample Utterances,样例代码下载:
https://s3.cn-north-1.amazonaws.com.cn/bjsdemo/LambdaAlexaSkillsKit/SampleUtterances.txt

点击“Save”后会报错,这个时候点击“Add Slot Type”添加。样例代码下载
https://s3.cn-north-1.amazonaws.com.cn/bjsdemo/LambdaAlexaSkillsKit/LIST_OF_ITEMS

然后再点击“保存”,这个时候看到Successfully updated the interaction model

此时,点击“Next”,选择Lambda的ARN地址,例如:
arn:aws:lambda:us-east-1:556776719183:function:LambdaAlexaSkillsKit

复制 Lambda ARN 地址

点击“Next”,即将进入到Test阶段,如下图所示。

然后在Enter Utterance中输入“How can I build a map”,点击“Ask Minecraft Helper”,能看到Lambda Response的结果。

15.(选做)如果是测试用的话这步可以不进行。

接下去会上传两张图片,这两张图片是特定尺寸的,而且是必须要上传的,你可以自定义。或者用两张我已经做好的图片:
https://s3.cn-north-1.amazonaws.com.cn/bjsdemo/LambdaAlexaSkillsKit/AWS+Logo+108.png
https://s3.cn-north-1.amazonaws.com.cn/bjsdemo/LambdaAlexaSkillsKit/AWS+Logo+512.png

16.(选做)如果是测试用的话这步可以不进行。

使用Web版Alexa Skill Testing Tool进行测试 https://echosim.io/,注意,这里需要用之前的Amazon账号登录。用鼠标点击进行语音。

当输入语音之后,打开Alexa的测试页面,点击Home,可以看到录音识别的效果。http://alexa.amazon.com/spa/index.html#cards
比如我语音输入:
Alexa, Ask solution helper how can build a map
Echo 回答:
A map can be crafted by placing a compass in the middle square and eight pieces of paper surrounding it.
也可以进行自定义语音设置,比如我语音输入:
Alexa, Ask solution helper how can I get summit ticket
Echo 回答:
Hello, if you want to attend beijing summit, please connect to aws china inside sales team.

搞定,完成!
作者介绍:
毛郸榕

亚马逊 AWS 中国助理解决方案架构师,负责基于 AWS 的云计算方案架构的咨询和设计,同时致力于 AWS 云服务在国内的应用和推广,毕业于北京航空航天大学云计算专业,硕士,毕业后直接加入亚马逊 AWS 中国。在大规模后台架构、企业混合 IT 和自动化运维等方面有着丰富的实践经验。目前在集中精力学习新一代无服务器架构设计。
本文转载自 AWS 技术博客。
原文链接:
https://amazonaws-china.com/cn/blogs/china/lambda-alexa-echo/
评论