Javascript 麦克风在我的html页面上不工作
我使用webkitspeechrecognition进行语音识别,当我在控制台中编写脚本时,这一点很有效,但当我将其与html页面集成时,它显示此页面不允许使用麦克风,我的代码有任何问题吗? 我的密码在这里Javascript 麦克风在我的html页面上不工作,javascript,html,Javascript,Html,我使用webkitspeechrecognition进行语音识别,当我在控制台中编写脚本时,这一点很有效,但当我将其与html页面集成时,它显示此页面不允许使用麦克风,我的代码有任何问题吗? 我的密码在这里 <html> <head> </head> <body> <button id="start" onclick="recognize()">Start</button> <script type="
<html>
<head>
</head>
<body>
<button id="start" onclick="recognize()">Start</button>
<script type="text/javascript">
function recognize(){
console.log("recognize")
var sr=new webkitSpeechRecognition();
sr.start();
sr.onresult=function(event){
console.log(event.results[0][0].transcript)
}
}
</script>
</body>
</html>
开始
函数识别(){
console.log(“识别”)
var sr=新的webkitSpeechRecognition();
sr.start();
sr.onresult=函数(事件){
console.log(event.results[0][0]。记录本)
}
}
您是以localhost/webserver的身份运行html文件还是通过文件://?是的,我是以localhost的身份运行此文件的。请尝试清除缓存。我也在清除缓存后尝试过,但仍然不起作用。您是以localhost/webserver身份运行html文件还是通过文件://?是的,我以localhost身份运行此文件确实有帮助?请尝试清除缓存。我也在清除缓存后尝试过,但仍然不起作用。