tags:

views:

31

answers:

2

In the code below is using 'getLevel()'. where I can find it (it is about sound, and it run with pyaudio library)

# this is the threshold that determines whether or not sound is detected
THRESHOLD = 0

#open your audio stream    

# wait until the sound data breaks some level threshold
while True:
    data = stream.read(chunk)
    # check level against threshold, you'll have to write getLevel()
    if getLevel(data) > THRESHOLD:
        break

# record for however long you want
# close the stream
A: 

Look at the imports that have been executed. You'll either find from someModule import getLevel, or from someModule import *.

Ignacio Vazquez-Abrams
But in the module pyaudio I can't find this function. I don't know in which module I can find it
Carolus89
No one told you to look in pyaudio. Look in the code you have in front of you.
Ignacio Vazquez-Abrams
+1  A: 

You could have a look at http://docs.python.org/release/2.5.2/lib/module-audioop.html This is another python module to handle audio, but that one does seem to have a method to get the audio level ( max(fragment, width) ).

balachmar