only add to audio queue if we have data

This commit is contained in:
SevaSk 2023-05-09 13:52:37 -04:00
parent 8cb45bc023
commit aa9557e13b

View File

@ -1,3 +1,4 @@
import numpy as np
import soundcard as sc
from Microphone import Microphone
import pythoncom
@ -13,5 +14,6 @@ class AudioRecorder:
pythoncom.CoInitialize()
with sc.get_microphone(id=self.microphone.id, include_loopback=self.microphone.loop_back).recorder(samplerate=SAMPLE_RATE) as mic:
while True:
data = mic.record(numframes=SAMPLE_RATE*RECORDING_TIME) # data is a frames x channels Numpy array.
data = mic.record(numframes=SAMPLE_RATE*RECORDING_TIME)
if np.any(data):
audio_queue.put((source, data))