如何在html页面中启用麦克风



我正在创建一个网站,有一个文本框,用户可以通过说它输入文本…在输入标签中,我使用x-webkit-speech。但是我想要的麦克风图标没有出现!

这是我使用的jQuery代码:

$(document).ready(function() { $("#voiceapi").bind('webkitspeechchange', function(e) {
    var val = $(this).val();
    if(val == "open face book") {window.location.replace("http://fb.com");      }
});});

顺便说一下,我正在创建一个chrome扩展的这个页面,虽然谷歌chrome浏览器支持语音识别,它仍然不工作!

由于一个允许恶意站点窥探您所说的任何内容的安全漏洞,对x-webkit-speech属性的支持已在Chrome v36中删除。

你应该使用Javascript API: http://updates.html5rocks.com/2013/01/Voice-Driven-Web-Apps-Introduction-to-the-Web-Speech-API

最新更新