简体   繁体   English

webkitspeechrecognition不再提示许可

[英]webkitspeechrecognition no longer prompts for permission

I've been prototyping a few pages that use webkitspeechrecognition. 我一直在制作一些使用webkitspeechrecognition的页面的原型。 I learned quickly that you cannot load these from a file, you have to serve them from a webserver. 我很快了解到,您无法从文件中加载这些文件,而必须从Web服务器提供它们。 I'm using osx so I just moved my files to the local apache that was already running and enabled. 我使用的是osx,因此我只是将文件移到了已经运行并启用的本地apache中。 This worked fine for quite a while. 这工作了好一阵子。

For some reason, none of my pages that were working fine will prompt me to deny/allow the microphone usage. 由于某些原因,我的所有页面都无法正常工作,不会提示我拒绝/允许使用麦克风。 I even copied an existing working page from another webserver and if I load it from http://localhost/speech.html it will not prompt. 我什至从另一个Web服务器复制了一个现有的工作页面,如果我从http://localhost/speech.html加载它,将不会提示。 It skips the prompt and goes to my recognition.onerror handler and logs "not-allowed" 它跳过提示,转到我的ognition.onerror处理程序,并记录“不允许”

However, if I load the same page (or any of my other prototypes) from http://127.0.0.1/speech.html it works fine. 但是,如果我从http://127.0.0.1/speech.html加载同一页面(或其他任何原型),则效果很好。 This made me think I had accidentally cached a response like "always deny" or something. 这使我认为我不小心缓存了诸如“始终拒绝”之类的响应。 I think I cleared/reset all my chrome settings but I'm still getting the same behavior. 我想我清除/重置了所有镶边设置,但仍然出现了相同的行为。 127.0.0.1 will properly prompt, but localhost will not prompt at all. 127.0.0.1将正确提示,但是localhost将完全不提示。

Where might chrome be storing some additional settings that I need to clear? chrome可能在哪里存储我需要清除的一些其他设置?

Your microphone settings might be stored at chrome://settings/contentExceptions#media-stream-mic . 您的麦克风设置可能存储在chrome://settings/contentExceptions#media-stream-mic You can view the websites that have permissions saved there. 您可以查看已在其中保存权限的网站。

getUserMedia permissions requesting in chrome currently works something like: chrome中的getUserMedia权限请求当前类似于:

  • If you have a request by http, getUserMedia will only remember the permissions for that session. 如果您有http的请求,则getUserMedia将仅记住该会话的权限。 If you go back to the same page. 如果您返回同一页面。 it asks again. 它再次询问。
  • If you do the same request by https, once you set the permissions, you always have permissions. 如果您通过https进行相同的请求,则设置权限后,您将始终具有权限。
  • My memory is that an exception is granted for http://localhost/ ... for debugging purposes. 我的记忆是,出于调试目的,为http:// localhost / ...授予了一个例外。 In this case, you don't need to repeatedly grant permissions. 在这种情况下,您无需重复授予权限。
  • If you use http and 127.0.0.1/, I think no exception is made. 如果您使用http和127.0.0.1/,我认为没有例外。

http://www.html5rocks.com/en/tutorials/getusermedia/intro/ http://www.html5rocks.com/en/tutorials/getusermedia/intro/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM