I would like to continuously record and audio. This is easily done using python's sounddevice module. However, I also wanted to start sending the chunks to a thread that works in the background when the audio gets more than 20 frames. The sounddevice's input overflows when I do this, can you help me fix this, or find another solution?
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()