inp.setformat(alsaaudio.PCM_FORMAT_S16_LE)
inp.setperiodsize(160)
while True:
    l, data = inp.read()
if l:
    print(audioop.max(data, 2))
time.sleep(0.001)
How get sound input from microphone in python, and process it on the fly?