One python thread is taksed with adding audio into a queue for processing.
while True:
if not audio_queue.empty():
audio_chunk = audio_queue.get()
vad_process(audio_chunk)
else:
time.sleep(0.01)
The above is obviously inefficient in resource usage to be constantly checking the queue in realtime.
try:
audio_chunk = audio_queue.get(timeout=1)
custom_vad(audio_chunk)
except queue.Empty:
continue
Is this may be more efficient, but it doesnt seem like the most elegant way to handle waiting for a queue.
Suggestions for a recommended way of handling this?