Here's an outline an approach that I think might work:
The hardest part of this is getting data from the microphone, and you'll need a tool that's built for this. Since you're on Windows, you could look for a prebuilt tool to do this. You could try to run something as a subprocess, but probably better is to use ctypes
and windll.kernel32
to call a Windows recording API. Googling "windll.kernel32 recording" produces some reasonable hits, like this.
If you do go the subprocess route, you'll probably end up calling something that first writes the output to a .wav file. If that's the case, you could then read the file using either the Python wave module
, or scipy.io.wavefile.read
. (Note wave files can be more complex than these modules can read, so when you set the parameters, don't go crazy.)
Finally, this idea of getting the data into the computer by recording the audio from the device is quite problematic, and will lead to problems as external audio noises will need to be sorted out. It would be much better to find a way to get the data into the computer without the intervening audio.