From 1a9e00ee496c949716676de24371e84c1535048d Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 24 Oct 2023 17:26:46 -0600 Subject: [PATCH] Add count of audio labels to active count (#8310) * Add count of audio labels to active count * Formatting --- frigate/events/audio.py | 17 ++++++++++++----- frigate/record/maintainer.py | 6 ++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/frigate/events/audio.py b/frigate/events/audio.py index b96e76af3..e8f4f6546 100644 --- a/frigate/events/audio.py +++ b/frigate/events/audio.py @@ -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() diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index 0370bbf3e..a5bc1b3e8 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -303,6 +303,10 @@ class RecordingMaintainer(threading.Thread): if frame[0] < start_time.timestamp(): continue + # add active audio label count to count of active objects + active_count += len(frame[2]) + + # add sound level to audio values audio_values.append(frame[1]) average_dBFS = 0 if not audio_values else np.average(audio_values) @@ -461,6 +465,7 @@ class RecordingMaintainer(threading.Thread): camera, frame_time, dBFS, + audio_detections, ) = self.audio_recordings_info_queue.get(True, timeout=0.01) if frame_time < run_start - stale_frame_count_threshold: @@ -471,6 +476,7 @@ class RecordingMaintainer(threading.Thread): ( frame_time, dBFS, + audio_detections, ) ) except queue.Empty: