在下面的代码中使用getLevel()
。我在哪里可以找到它(它是关于声音,它与pyaudio库一起运行)
# 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
答案 0 :(得分:2)
你可以查看https://docs.python.org/library/audioop.html 这是另一个处理音频的python模块,但是它似乎有一个获取音频级别的方法(max(fragment,width))。
答案 1 :(得分:0)
查看已执行的导入。您会找到from someModule import getLevel
或from someModule import *
。