Web也来玩语音


还在羡慕移动设备上的语音输入吗?ok让我们在Web上也来试一下吧。

HTML5标签Input新提供了x-webkit-speech语法。能让我们将语音输入的功能很简单的带到我们的网站中,虽然它还不完美。(一目了然目前只有webkit核心的可以使用。例:Chrome只能在11以后的版本)

第一个例子:

<inputx-webkit-speech/>

第二个例子:

<inputtype="text"x-webkit-speechlang="zh-CN"/>

 

通过lang指定语音输入的语系,例如像lang= "zh-CN"的话,语音输入所识别出来的文字就是简体字。

第三个例子:

<inputtype="text"x-webkit-speechx-webkit-grammar="builtin:translate">

以下JS用来检测是否启用语音输入:

if(document.createElement("input").webkitSpeech ===undefined){

alert("Speech input is not supported in your browser.");

}

看看实例:

enter image description here

enter image description here

相关资料:

http://www.sitepoint.com/html5-speech-input-fields/#fbid=AFbsl161lkU

http://webdesign.about.com/od/html5tutorials/qt/Collect-Speech-Input-With-Html5-On-Google-Chrome.htm

http://www.w3.org/TR/capture-api/

http://www.w3.org/TR/xhtml+voice/

http://www.w3.org/2005/Incubator/htmlspeech/2010/10/google-api-draft.html

 

posted @ 2015-05-12 18:26  papahot  阅读(145)  评论(0编辑  收藏  举报