问题
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