x-webkit-speech 语音输入功能

来源:互联网 发布:对外经贸大学 知乎 编辑:程序博客网 时间:2024/06/13 23:02

              今天无意中查看天猫审查元素发现的,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>
刚刚的那个网址对这个内容的解析更为详细,若有需要大家可以复制链接来看。

0 0
原创粉丝点击