How to make python detect audio from an application?

☆樱花仙子☆ 提交于 2021-02-07 04:40:25

问题


I'm trying to make something that runs when audio is detected from a windows application. Is there any way to do this using python.

I'm running on python 2.7.12 but I'm willing to update if necessary. I'm also fine with detecting any sound at all coming from the computer.

Thanks a lot.


回答1:


take a look at http://python-sounddevice.readthedocs.io/en/0.3.4/#sounddevice.RawInputStream You could use this to detect audio to and from the sound card of the computer.

The particular class is one way to get sound from a mic.

from sounddevice library

class sounddevice.RawInputStream(samplerate=None, blocksize=None, device=None, channels=None, dtype=None, latency=None, callback=None, finished_callback=None, clip_off=None, dither_off=None, never_drop_input=None, prime_output_buffers_using_stream_callback=None)

or you could filter the output of the sound card to know when audio signal is being sent.

class sounddevice.OutputStream(samplerate=None, blocksize=None, device=None, channels=None, dtype=None, latency=None, callback=None, finished_callback=None, clip_off=None, dither_off=None, never_drop_input=None, prime_output_buffers_using_stream_callback=None)



来源:https://stackoverflow.com/questions/39056494/how-to-make-python-detect-audio-from-an-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!