检测麦克风是否打开
有没有办法以编程方式检测 Windows 上的麦克风是否打开?
Is there a way to programmatically detect whether the microphone is on on Windows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有没有办法以编程方式检测 Windows 上的麦克风是否打开?
Is there a way to programmatically detect whether the microphone is on on Windows?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
不,麦克风不会告诉您它们是否“打开”,或者特定的声道是否已连接到麦克风设备。您能做的最好的事情就是从您怀疑是麦克风的输入通道(例如Windows默认输入设备/通道)读取音频数据,并查看其上是否有任何信号。
为此,您必须消除任何直流偏移并寻找高于合理本底噪声的任何信号。 (慷慨一点:许多便宜的音频输入设备即使在没有信号输入时也相当嘈杂。中频滤波器/FFT 也可用于仅检测语音中频范围内的信号,而不是低频嗡嗡声和短暂的点击声。)
No, microphones don't tell you whether they're ‘on’ or that a particular sound channel is connected to a microphone device. The best you can do is to read audio data from the input channel you suspect to be a microphone (eg. the Windows default input device/channel), and see if there's any signal on it.
To do that you'd have to remove any DC offset and look for any signal above a reasonable noise floor. (Be generous: many cheap audio input devices are quite noisy even when there is no signal coming in. A mid-band filter/FFT would also be useful to detect only signals in the mid-range of a voice and not low-frequency hum and transient clicks.)
这没有以任何方式进行测试,但我会尝试阅读一些样本,看看是否有任何变化。如果麦克风打开,那么您应该从环境声音中获得不同的值。如果麦克风关闭,你应该得到一个 0。这又是我想象的事情应该如何工作 - 我不知道它们是否真的那样工作。
This is not tested in any way, but I would try to read some samples and see if there is any variation. If the mike is on then you should get different values from the ambient sounds. If the mike is off you should get a 0. Again this is just how I imagine things should work - I don't know if they actually work that way.
由于一次愉快的意外,我可能发现有一种方法可以检测已连接麦克风的存在。
如果您的 Windows“录音设备”显示“无麦克风”,则此方法(使用 Microsoft Speech API)将起作用并确认您没有麦克风。但是,如果 Windows 认为您有麦克风,这不会反对。
更具体地说,hr 将返回以下结果:
Due to a happy accident, I may have discovered that yes there is a way to detect the presence of a connected microphone.
If your windows "recording devices" shows "no microphone", then this approach (using the Microsoft Speech API) will work and confirm you have no mic. If windows however thinks you have a mic, this won't disagree.
more specifically, hr will return this result: