问题描述
我有一个使用Webkit语音识别API的电子应用程序.如果在浏览器中进行了测试,一切都会按预期运行,但是如果在电子环境中运行,则语音识别api将无法正常工作.
I have an electron app that uses the webkit speech recognition API. If tested in the browser, everything works as intended, but if run in the electron environment, the speech recognition api doesn't work.
我的意思是,当我按下开始录音的按钮时,录音不会在电子环境中开始.我相信这是因为与在浏览器中运行代码不同,我没有被要求,因此也没有被授予麦克风访问权限.因此,我的问题是,如何在电子应用程序中请求访问麦克风?预先感谢!
What I mean is that when I press the button that starts the recording, the recording won't start in the electron environment. I believe that is because unlike when running the code in the browser, I wasn't asked for and therefore not granted microphone access. So my question is then, how can I request access for the microphone in an electron app? Thanks in advance!
推荐答案
在电子文档中找到了这一点. https://electronjs.org/docs/api/system-preferences#systempreferencesaskformediaaccessmediatype-macos
Found this in the electron docs.https://electronjs.org/docs/api/system-preferences#systempreferencesaskformediaaccessmediatype-macos
如果您使用macOS来运行应用程序,请使用该方法请求权限.如果不是,则表明该应用似乎不需要使用麦克风或摄像头的权限.
If you're using macOS to run the app use that method to request permission. If not it doesn't look like the app requires permission to use the microphone or camera.
这篇关于申请电子版中的麦克风许可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!