micro.py is a tiny python module that captures microphone input and makes the raw data available by a
read function. It makes use of python-gstreamer.
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law. There is no warranty.
example.py records one second, unpacks the data and prints the values
#!/usr/bin/env python import micro, time, struct start=time.time() micro.record() while time.time()<start+1.0: data = micro.read(1000,1) for i in struct.unpack( '500h' , data): print i micro.stop() micro.loop.quit()
nn is negative or non-existent, read whole buffer. You can also specify a timeout.
gobject.MainLoop()that is required for using gstreamer. As the mainloop is running in a separate thread, you need to stop this thread by executing
loop.quit()in order to make your program terminate - otherwise it will wait for this thread forever.