我想连续录音和录音。这很容易使用 python 的 sounddevice 模块完成。但是,当音频超过 20 帧时,我还想开始将块发送到在后台工作的线程。当我这样做时,声音设备的输入溢出,你能帮我解决这个问题,还是找到其他解决方案?
def callbackAmbient(indata, frames, time, status):
if (status):
print(status)
VadFrames.append(indata)
if (len(VadFrames) > 19):
Process(target = start_vad, args = (numpy.array(numpy.multiply(VadFrames, 0.5)), numpy.array(VadFrames), RATE, RATE)).start()
VadFrames.pop(0)
print("System Recording...")
try:
with sd.InputStream(samplerate=192000, blocksize=6144, channels=1, device=sd.query_devices(kind='input')['name'], callback=callbackAmbient):
while True:
pass
except KeyboardInterrupt:
print("System stopped...")
sys.exit()