在下面的代码中使用的是 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
有帮助吗?

解决方案

你可以看看 https://docs.python.org/library/audioop.html这是另一个处理音频的 python 模块,但该模块似乎有一种方法来获取音频级别( max(fragment, width) )。

其他提示

查看已执行的导入。你会发现 from someModule import getLevel, , 或者 from someModule import *.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top