Speech模块管理语音输入功能,提供语音识别功能,可支持用户通过麦克风设备进行语音输入内容。通过plus.speech可获取语音输入管理对象。

 

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>心得</title>
<script type="text/javascript">
var text;
function one(){
//只要是语音识别统一用{engine:'iFly'}就行了
plus.speech.startRecognize({engine:'iFly'},function(str){
//text = str;
document.getElementById("imglist").innerHTML = "<li style='color:red'>刚才识别到的语音内容是:"+str+"</li>";
},function(e){
alert('语音识别失败:'+e.message);
});
}
function two(){
plus.speech.stopRecognize();
}
function three(){
alert(text);
}
</script>
</head>
<style>
li{line-height: 40px; height: 40px; border-bottom: #ccc dashed 1px;}
</style>
<body>
<ul id="imglist"></ul>
<ul>
<li οnclick="one()">启动语音识别</li>
<li οnclick="two()">停止语音识别(几乎不用)</li>
<li οnclick="three()">查看语音信息(几乎不用)</li>
</ul>
</body>
</html>

 

转载于:https://www.cnblogs.com/xhrs/p/9332196.html

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐