Add count of audio labels to active count (#8310)

* Add count of audio labels to active count

* Formatting
This commit is contained in:
Nicolas Mowen
2023-10-24 19:26:46 -04:00
committed by GitHub
parent b9649de327
commit 1a9e00ee49
2 changed files with 18 additions and 5 deletions
+12 -5
View File
@@ -205,14 +205,10 @@ class AudioEventMaintainer(threading.Thread):
# only run audio detection when volume is above min_volume
if rms >= self.config.audio.min_volume:
# add audio info to recordings queue
self.recordings_info_queue.put(
(self.config.name, datetime.datetime.now().timestamp(), dBFS)
)
# create waveform relative to max range and look for detections
waveform = (audio / AUDIO_MAX_BIT_RANGE).astype(np.float32)
model_detections = self.detector.detect(waveform)
audio_detections = []
for label, score, _ in model_detections:
logger.debug(f"Heard {label} with a score of {score}")
@@ -224,6 +220,17 @@ class AudioEventMaintainer(threading.Thread):
"threshold", 0.8
):
self.handle_detection(label, score)
audio_detections.append(label)
# add audio info to recordings queue
self.recordings_info_queue.put(
(
self.config.name,
datetime.datetime.now().timestamp(),
dBFS,
audio_detections,
)
)
self.expire_detections()