【问题标题】:Stop recording once volume is below threshold with python-sounddevice一旦音量低于 python-sounddevice 的阈值就停止录制
【发布时间】:2018-11-29 08:10:06
【问题描述】:

我目前有一些 python 代码不断记录 4 秒的音频块:

#!/usr/bin/env python3
import sounddevice as sd

fs = 16000

while True:
    print('Started listening')
    myrecording = sd.rec(int(4 * fs), dtype='int16', channels=1, blocking=True)

但是,我希望sounddevice 录制直到音量低于音频阈值(即,当拿着麦克风的人停止说话时),而不是固定的 4 秒块,然后重新开始听。

基本上,我想模仿像soxrec recording.wav silence 1 0.1 3% 1 3.0 3% 这样的命令的行为,它就是这样做的。

有没有一种简单的方法可以用sounddevice 做到这一点?

【问题讨论】:

  • sounddevice 模块无法帮助您进行信号分析,它的工作只是提供信号。但是您可以编写自己的手写回调函数来进行分析并在sounddevice.InputStream 中使用它。

标签: python audio sox python-sounddevice


【解决方案1】:

执行此操作的库似乎称为 VAD(语音音频检测)。对于python来说,一个好的似乎是py-webrtcvad

【讨论】:

    猜你喜欢
    • 2012-10-18
    • 2022-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多