0

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
ucMedia
  • 4,105
  • 4
  • 38
  • 46
CarolusPl
  • 639
  • 4
  • 9
  • 18

2 Answers2

2

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) ).

twasbrillig
  • 17,084
  • 9
  • 43
  • 67
wligtenberg
  • 7,695
  • 3
  • 22
  • 28
0

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

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358