1

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?

9
  • 1
    I sure hope not. Those packages are for math and plotting. Nothing to do with audio input. Commented Feb 18, 2014 at 19:47
  • 1
    What platform are you on? Commented Feb 18, 2014 at 20:11
  • 1
    get a raspberry pi and install whatever you want on it? Commented Feb 18, 2014 at 20:23
  • 3
    You could use ctypes and windll to get access to a Windows recording API. If you google "windll.kernel32 recorder" there are a number of hits which look like reasonable outlines for this approach. Commented Feb 18, 2014 at 21:32
  • 1
    As a workaround you could record your data as a WAV-File and use scipy.io.wavfile.read(). I know its not a nice solution, but you could get some work done until you can convince someone to install pyaudio for you. Commented Feb 18, 2014 at 22:34

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.