<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
<title>Hello APP</title>
<link rel="stylesheet" type="text/css" href="../css/api.css" />
<link rel="stylesheet" type="text/css" href="../css/aui.css" />
<style>
/*button {
margin: 5px 10px;
padding: 5px;
}*/
.btn {
position: absolute;
bottom: 0;
width: 100%;
height: 50px;
background: #eee;
}
.btn input {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="btn">
<input type="button" name="" id="pressBtn" value="按住 说话">
</div>
<script id="contentTemplate" type="text/x-dot-template">
<div class="aui-chat-item aui-chat-right">
<div class="aui-chat-media">
<img src="../image/liulangnan.png" />
</div>
<div class="aui-chat-inner">
<div class="aui-chat-name">流浪男</div>
<div class="aui-chat-content">
<div class="aui-chat-arrow"></div>
{{=it.talktext}}
</div>
<div class="aui-chat-status">
<i class="aui-iconfont aui-icon-correct aui-text-success"></i>
</div>
</div>
</div>
</script>
<section id="cont" class="aui-chat">
</section>
<!-- <button type="button" onclick="fnrecord()" name="button">fnrecord</button>
<button type="button" onclick="fnstopRecord()" name="button">fnstopRecord</button>
<button type="button" onclick="fncancelRecord()" name="button">fncancelRecord</button>
<button type="button" onclick="fnaddRecordHUD()" name="button">fnaddRecordHUD</button>
<button type="button" onclick="fnshowRecordHUD()" name="button">fnshowRecordHUD</button>
<button type="button" onclick="fnhideRecordHUD()" name="button">fnhideRecordHUD</button>
<button type="button" onclick="fnread()" name="button">fnread</button>
<button type="button" onclick="fnstopRead()" name="button">fnstopRead</button>
<button type="button" onclick="fnpauseRead()" name="button">fnpauseRead</button>
<button type="button" onclick="fnresumeRead()" name="button">fnresumeRead</button> -->
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/dotmin.js"></script>
<script type="text/javascript">
var btnEle = document.getElementById("pressBtn");
var tStart = 0;
var tEnd = 0;
var tMove = 0;
apiready = function() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.createUtility({
ios_appid: '', // 填写讯飞平台上获得的appid
android_appid: '' // 填写讯飞平台上获得的appid
}, function(ret, err) {
if (ret.status) {
api.alert({
msg: '创建成功'
});
} else {
api.alert({
msg: "创建失败"
});
}
});
};
function fnrecord() {
var flag = true;
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.record({
vadbos: 5000,
vadeos: 5000,
rate: 16000,
asrptt: 1,
audioPath: 'fs://speechRecogniser/speech.pcm'
}, function(ret, err) {
if (ret.status) {
// api.alert({
// msg: ret.wordStr
// });
if (flag) {
wordStr = ret.wordStr;
fndoTempt();
flag = false;
}
} else {
api.alert({
msg: err.msg
});
}
});
}
function fnstopRecord() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.stopRecord();
}
function fncancelRecord() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.cancelRecord();
}
function fnaddRecordHUD() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.addRecordHUD({
centerX: 160,
centerY: 120,
radius: 80,
transparentR: 40,
bg: '#666',
fixedOn: api.frameName,
fixed: false
}, function(ret, err) {
var volume = ret.volume;
});
}
function fnshowRecordHUD() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.showRecordHUD();
}
function fnhideRecordHUD() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.hideRecordHUD();
}
function fnread() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.read({
readStr: '一行白鹭上青天,两只黄鹂鸣翠柳',
speed: 60,
volume: 60,
voice: 1,
rate: 16000,
audioPath: 'fs://speechRecogniser/read.mp3'
}, function(ret, err) {
if (ret.status) {
ret.speakProgress
} else {
api.alert({
msg: err.msg
});
}
});
}
function fnstopRead() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.stopRead();
}
function fnpauseRead() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.pauseRead();
}
function fnresumeRead() {
var iflyRecognition = api.require('iflyRecognition');
iflyRecognition.resumeRead();
}
function fninitEventListener() {
btnEle.addEventListener("touchstart", function(event) {
event.preventDefault();
tStart = 0;
tStart = event.touches[0].pageY;
btnEle.value = '松开 结束';
fnrecord();
});
btnEle.addEventListener("touchmove", function(event) {
event.preventDefault();
tMove = 0;
tMove = event.targetTouches[0].pageY;
if (tStart - tMove < 100) {
btnEle.value = '松开结束';
} else {
btnEle.value = '松开手指,取消发送';
}
});
btnEle.addEventListener("touchend", function(event) {
event.preventDefault();
tEnd = 0;
tEnd = event.changedTouches[0].pageY;
btnEle.value = '按住 说话';
if (tStart - tEnd < 100) {
}
});
};
fninitEventListener();
function fndoTempt() {
var data = {
"talktext": wordStr,
};
var conttemp = doT.template(document.getElementById('contentTemplate').innerHTML);
var ele = document.getElementById('cont');
$api.append(ele, conttemp(data));
api.parseTapmode();
}
</script>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
科大讯飞语音识别官方demo
共13个文件
css:3个
png:3个
js:2个
需积分: 2 0 下载量 19 浏览量
2024-08-14
15:22:50
上传
评论
收藏 80KB ZIP 举报
温馨提示
科大讯飞语音识别官方demo
资源推荐
资源详情
资源评论
收起资源包目录
iflyrecognitiondemo.zip (13个子文件)
iflyrecognitiondemo
feature
image
liulangnan.png 13KB
loading_more.gif 6KB
res
css
common.css 808B
aui-iconfont.ttf 36KB
aui.css 63KB
api.css 2KB
html
main.html 7KB
launch
launch1080x1920.png 45KB
index.html 3KB
icon
icon150x150.png 5KB
script
api.js 18KB
dotmin.js 3KB
config.xml 1KB
wgt
共 13 条
- 1
资源评论
吹个口哨写代码
- 粉丝: 84
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- ssm+mysql的网络安全与信息管理学院班级管理系统(源码+lw+ppt)
- java-ssm+jsp母婴用品网站实现源码(项目源码-说明文档)
- ssm+mysql的小说阅读网站书城(源码+lw+ppt)
- java-ssm+jsp面向java学生成绩分析系统实现源码(项目源码-说明文档)
- java-ssm+jsp美妆产品进销存管理系统实现源码(项目源码-说明文档)
- ssm+mysql的小型超市仓库管理系统(源码+lw+ppt)
- jnzysx.apk.1
- java-ssm+jsp美食推荐管理系统实现源码(项目源码-说明文档)
- ssm+mysql的小学数学在线测试系统(源码+lw+ppt)
- java-ssm+jsp美容院管理系统实现源码(项目源码-说明文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功