代码之家  ›  专栏  ›  技术社区  ›  CarolusPl

在哪里可以找到getLevel()?

  •  0
  • CarolusPl  · 技术社区  · 16 年前

    在下面的代码中使用 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
    
    2 回复  |  直到 8 年前
        1
  •  2
  •   twasbrillig    11 年前

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

        2
  •  0
  •   Ignacio Vazquez-Abrams    16 年前

    查看已执行的导入。你要么找到 from someModule import getLevel from someModule import * .