Rokid开发者社区skill之【历史上的今天】之简介+玩法+设计+实现+心得
{
"name": "month",
"type": "ROKID.NUMBER_ZH"
},
{
"name": "day",
"type": "ROKID.NUMBER_ZH"
}
{
"name": "oneday",
"type": "ROKID.DAY_ZH"
}
编写"HISTORY_DAY":function(){
try{
var res = "xxx"; // 需要若琪读出的文字内容
this.emit(":tts",{ tts: res }); // 正常完成意图函数时callback
this.callback(null);
}catch(e){
this.callback(e); // 报错时callback错误
}
}
"HISTORY_DAY":function(){
try{
var oneday = Rokid.param.request.content.slots.oneday;
var monthori = Rokid.param.request.content.slots.month;
var dayori = Rokid.param.request.content.slots.day;
var monthurl = '';
var dayurl = '';
if (oneday){
var dd = new Date();
dd.setDate(dd.getDate() + onedaydictText[oneday]);
monthori = dd.getMonth()+;
dayori = dd.getDate();
monthurl = formatMonth(monthori);
dayurl = formatDay(dayori);
} else{
monthurl = formatMonth(monthori);
dayurl = formatDay(dayori);
}
result = Rokid.sync_request('GET','https://baike.baidu.com/cms/home/eventsOnHistory/' + monthurl + '.json');
result = Rokid.resHandler(result);
var hdori = result[monthurl][monthurl+dayurl];
var hdorilen = hdori.length;
var res = '好的,为您播报' + monthori + '月' + dayori + '号' + '的历史。';
for (var index = hdorilen-; index >= ; index --){
var yearori = hdori[index].year;
var yearstr = '';
if (parseInt(yearori) >= ) {
yearstr = yearori + '年';
}else{
yearstr = '公元前' + Math.abs(yearori) + '年';
}
var title = hdori[index].title.replace(/<.*?>/ig,"").replace("\n","").replace("。","");
res += yearstr + title + '。';
}
res += monthori + '月' + dayori + '号' + '的历史已为您播报完毕,请问您还想了解几月几号的历史呢?';
this.emit(":tts",{ tts: res });
this.callback(null);
}catch(e){
this.callback(e);
}
}

Rokid开发者社区skill之【历史上的今天】之简介+玩法+设计+实现+心得的更多相关文章
- Rokid开发者社区skill之【历史上的今天】
技能名称:历史上的今天 入口词:打开历史上的今天 语音交互:(有些是先写上) { "intents": [ { "intent": "PAUSE_HI ...
- sae-v2ex 一个运行在SAE上的类似v2ex的轻型python论坛 - 技术讨论 - 云计算开发者社区 - Powered by Discuz!
sae-v2ex 一个运行在SAE上的类似v2ex的轻型python论坛 - 技术讨论 - 云计算开发者社区 - Powered by Discuz! sae-v2ex 一个运行在SAE上的类似v2e ...
- 为什么开发者热衷在Stack Overflow上查阅API文档?
摘要:一项新研究跟踪了Android开发者的访问历史,发现开发者多达二分之一的文档是从Stack Overflow上获取到的,而Stack Overflow上的示例也多于官方指南,开发者通过搜索更多时 ...
- 国内首个微信小程序开发者社区www.mntuku.cn
微信小程序开发者社区-微信小程序开发教程-微信小程序最新资讯 - www.mntuku.cn .本站作为专业的微信小程序开发者社区为大家提供:微信小程序开发者交流平台,微信小程序开发教程,微信小程序定 ...
- 移动端IM开发者必读(二):史上最全移动弱网络优化方法总结
1.前言 本文接上篇<移动端IM开发者必读(一):通俗易懂,理解移动网络的“弱”和“慢”>,关于移动网络的主要特性,在上篇中已进行过详细地阐述,本文将针对上篇中提到的特性,结合我们的实践经 ...
- go, iris , nuxt, 服务端渲染等技术在helloworld开发者社区中的应用与实践
大家好,helloworld.net 上线已经有近半年的时间了,转眼过的好快,在这半年的时间里,迭代了近10多个版本,优化了很多的体验,交互上的不足之处,同时也上线了我们的安卓 app, 苹果的因为还 ...
- Linux历史上线程的3种实现模型
一.概述 这里以Linux为例.Linux历史上,最开始使用的线程是LinuxThreads,但Li ...
- UWP Windows历史上最漂亮的UWP框架出炉!!!
UWP Windows历史上最漂亮的UWP框架出炉!!! 本框架基于微软的开源项目WTS开发,并在其基础上增加了FDS(流畅设计元素,高光.亚克力等).多语言系统.沉浸式体验(扩展内容到标题栏) 同时 ...
- 未来-IOT-Aliyun:阿里云 IOT - 开发者社区
ylbtech-未来-IOT-Aliyun:阿里云 IOT - 开发者社区 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 1. https://dev.iot. ...
随机推荐
- java stream collector
Java Stream API进阶篇 本文github地址 上一节介绍了部分Stream常见接口方法,理解起来并不困难,但Stream的用法不止于此,本节我们将仍然以Stream为例,介绍流的规约操作 ...
- Theano Logistic Regression
原理 逻辑回归的推理过程能够參考这篇文章:http://blog.csdn.net/zouxy09/article/details/20319673,当中包括了关于逻辑回归的推理,梯度下降以及pyth ...
- 简单四步開始树莓派上的Docker之旅
大概这篇博文发表之后,应该算是我个人的第一篇翻译作品了,翻译的可能不是非常到位,望各位看官大刀砍过来. 原文链接:http://resin.io/blog/docker-on-raspberry-pi ...
- POJ--2752--Seek the Name, Seek the Fame【KMP】
链接:http://poj.org/problem? id=2752 题意:对于一个字符串S,可能存在前n个字符等于后n个字符,从小到大输出这些n值. 思路:这道题加深了对next数组的理解.next ...
- Java中将InputStream读取为String, 各种方法的性能对比
如下, 一共存在11种实现方式及其对应的性能测试结果: 1. 使用IOUtils.toString (Apache Utils) String result = IOUtils.toString(in ...
- bootstrap之UpdateStrings
UpdateStrings package io.appium.android.bootstrap.handler; import io.appium.android.bootstrap.Androi ...
- HDUOJ---大菲波数
大菲波数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDUOJ ---1269迷宫城堡
http://acm.hdu.edu.cn/showproblem.php?pid=1269 迷宫城堡 Time Limit: 2000/1000 MS (Java/Others) Memory ...
- 【LeetCode】145. Binary Tree Postorder Traversal (3 solutions)
Binary Tree Postorder Traversal Given a binary tree, return the postorder traversal of its nodes' va ...
- 【LeetCode】104. Maximum Depth of Binary Tree (2 solutions)
Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the ...