Pergunta

I'm trying to collect data from a Geiger counter using the microphone and process it using Python. However, I'm using a university computer so I'm not allowed to install the PyAudio module which seems necessary for this job (Python read microphone). Are there any equivalent functions in numpy, matplotlib or scipy?

Foi útil?

Solução

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.

Outras dicas

I know the question go answered and accepted, but I'd like to offer 2 other options:

  • python virtualenv would work around the "not allowed to install anything on the computer" which I guess is more imposed by local IT than dept policy

  • use ffmpeg in a wrapper. Drop the statically compiled executable in a known and acceptable location. use subprocess to start it with appropriate command line switches to output the captured audio to stdout (read as a file-like object on python's side)

both these options are free as in free beer and add a straightforward to simple cross platform support.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top