【发布时间】: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 秒块,然后重新开始听。
基本上,我想模仿像sox 的rec recording.wav silence 1 0.1 3% 1 3.0 3% 这样的命令的行为,它就是这样做的。
有没有一种简单的方法可以用sounddevice 做到这一点?
【问题讨论】:
-
sounddevice模块无法帮助您进行信号分析,它的工作只是提供信号。但是您可以编写自己的手写回调函数来进行分析并在sounddevice.InputStream中使用它。
标签: python audio sox python-sounddevice