Input audio from microphone

Today I learnt how to input audio directly from the microphone
It requires two packages alsaaudio and audioop if its not already present .

import alsaaudio, time, audioop
inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE,alsaaudio.PCM_NONBLOCK)

# Set attributes: Mono, 8000 Hz, 16 bit little endian samples


while True:
	# Read data from device
	l,data =
	if l:
		print audioop.max(data, 2)

The code will print the audio as data on the screen . Try shouting and you will find the difference. You can probably store it in a .wav file .


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s