您的位置:首页 > 其它

x-webkit-speech 语音输入功能

2015-06-27 23:29 344 查看
今天无意中查看天猫审查元素发现的,The HTML Speech Input API aims to provide web developers with features that are typically not available when using standard speech recognition software to replace keyboard
input in a web browser

这是摘自http://lists.w3.org/Archives/Public/public-xg-htmlspeech/2011Feb/att-0020/api-draft.html的一句,从中我们可以知道这是一个可以实现语音识别来替代键盘输入的功能。

其实现较为简单,仅在input标签后加x-webkit-speech即可,为<input type="text" x-webkit-speech/>.

若需要根据发声语音改变事件,则可以使用onspeechchange触发事件。

<script type="text/javascript">
function startSearch(event) {
event.target.form.submit();
}
</script>

<form action="http://www.google.com/search">
<input type="search" name="q" speech required onspeechchange="startSearch">
</form>

刚刚的那个网址对这个内容的解析更为详细,若有需要大家可以复制链接来看。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: