码迷,mamicode.com
首页 > 其他好文 > 详细

MUI 语音搜索框

时间:2017-07-06 11:21:45      阅读:487      评论:0      收藏:0      [点我收藏+]

标签:put   width   sea   hold   func   highlight   isp   失败   function   

<div id="search-area">
<div class="mui-input-row mui-search mui-active" style="width: 85vw; display: inline-block;margin-left: 5px;">
<input id="search" type="search" class="mui-input-speech mui-input-clear" placeholder="" data-input-clear="2" data-input-speech="2" data-input-search="2">
<span class="mui-icon mui-icon-clear mui-hidden"></span>
<span class="mui-icon mui-icon-speech"></span>
<span class="mui-placeholder">
<span class="mui-icon mui-icon-search" id="search-btn"></span>
<span>带语音输入的搜索框</span>
</span>
</div>
<div id="search-text">搜索</div>
</div>

  技术分享

	//	语音输入
	var text = null;

	function startRecognize() {
		var options = {};
		options.engine = ‘iFly‘;
		options.punctuation = false; // 是否需要标点符号 
		text = "";
		console.log("开始语音识别:");
		plus.speech.startRecognize(options, function(s) {
			console.log(s);
			text += s;
			document.getElementById(‘search‘).value = text;
		}, function(e) {
			console.log("语音识别失败:" + e.message);
			alert("语音识别失败:" + e.message);
		});
		setTimeout(stopRecognize, 10000);
	}
//	停止语音输入
	function stopRecognize() {
		plus.speech.stopRecognize();
	}

  

 

MUI 语音搜索框

标签:put   width   sea   hold   func   highlight   isp   失败   function   

原文地址:http://www.cnblogs.com/RAINHAN/p/7125177.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!