简体   繁体   English

如何在Chrome扩展程序弹出窗口中读取语音输入?

[英]How to read voice input in a chrome extension popup?

So I need to use the webkitSpeechRecognition() api to read voice input from the user and then fill a text area with whatever value is returned for webSpeechRecognition . 因此,我需要使用webkitSpeechRecognition() api读取用户的语音输入,然后使用为webSpeechRecognition返回的任何值填充text area Now the problem is when I do that from a popup page in chrome extension, it does not asks for microphone access. 现在的问题是,当我从chrome扩展程序的popup page中执行此操作时,它不要求访问麦克风。 How can I solve it ? 我该如何解决? I have read this answer https://stackoverflow.com/a/29183128/5143144 but I am unable to make anything of it. 我已经阅读了这个答案https://stackoverflow.com/a/29183128/5143144,但是我什么也做不了。 Another issue is, even if I am able to get microphone access, is it possible to use it to do webkitSpeechRecognition in the popup of the chrome extension. 另一个问题是,即使我能够访问麦克风,也可以使用它在chrome扩展程序的弹出窗口中执行webkitSpeechRecognition Please help. 请帮忙。 Thanks. 谢谢。

I solved this after searching a lot and getting a reference from one of the stack overflow answers and chrome forums. 经过大量搜索并从堆栈溢出答案和chrome论坛之一获得参考后,我解决了此问题。 Just leaving this here in case you find it useful. 如果您觉得有用,就把它留在这里。

So all you have to do is ask for the permissions on a different page which has the extension url . 因此,您要做的就是ask for the permissions on a different page which has the extension url Once a user allows permission to microphone there, your browser extension will be able to access microphone. 一旦用户允许在那里使用麦克风的权限,您的浏览器扩展程序将能够访问麦克风。

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

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