Question

In the code below is using getLevel(). where can I 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
Was it helpful?

Solution

You could have a look at https://docs.python.org/library/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) ).

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top