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
?

- 1
- 1

- 3,771
- 8
- 36
- 75
-
1I sure hope not. Those packages are for math and plotting. Nothing to do with audio input. – cmd Feb 18 '14 at 19:47
-
@cmd .. I'm afraid that's all I have to work with. – Medulla Oblongata Feb 18 '14 at 19:58
-
1What platform are you on? – Joe Kington Feb 18 '14 at 20:11
-
Workarounds: Buy a Geiger counter with usb out (but then you need to solve how to read from usb). Use a digital voice recorder with removable media. Swap out memory and process at a remote location (obviously will not work if results needed real-time). – Steven Rumbalski Feb 18 '14 at 20:11
-
1get a raspberry pi and install whatever you want on it? – cmd Feb 18 '14 at 20:23
-
I'm on Windows 7 (32 bit) and I'm not allowed to spend any money. :( – Medulla Oblongata Feb 18 '14 at 21:21
-
3You 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. – tom10 Feb 18 '14 at 21:32
-
1As 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. – Dietrich Feb 18 '14 at 22:34
-
Would anyone like to post their answer below ... so that I can pick the best one? – Medulla Oblongata Feb 19 '14 at 01:25
2 Answers
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.

- 67,082
- 10
- 127
- 137
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.

- 26
- 1