mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Add count of audio labels to active count (#8310)
* Add count of audio labels to active count * Formatting
This commit is contained in:
parent
b9649de327
commit
1a9e00ee49
@ -205,14 +205,10 @@ class AudioEventMaintainer(threading.Thread):
|
|||||||
|
|
||||||
# only run audio detection when volume is above min_volume
|
# only run audio detection when volume is above min_volume
|
||||||
if rms >= self.config.audio.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
|
# create waveform relative to max range and look for detections
|
||||||
waveform = (audio / AUDIO_MAX_BIT_RANGE).astype(np.float32)
|
waveform = (audio / AUDIO_MAX_BIT_RANGE).astype(np.float32)
|
||||||
model_detections = self.detector.detect(waveform)
|
model_detections = self.detector.detect(waveform)
|
||||||
|
audio_detections = []
|
||||||
|
|
||||||
for label, score, _ in model_detections:
|
for label, score, _ in model_detections:
|
||||||
logger.debug(f"Heard {label} with a score of {score}")
|
logger.debug(f"Heard {label} with a score of {score}")
|
||||||
@ -224,6 +220,17 @@ class AudioEventMaintainer(threading.Thread):
|
|||||||
"threshold", 0.8
|
"threshold", 0.8
|
||||||
):
|
):
|
||||||
self.handle_detection(label, score)
|
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()
|
self.expire_detections()
|
||||||
|
|
||||||
|
@ -303,6 +303,10 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
if frame[0] < start_time.timestamp():
|
if frame[0] < start_time.timestamp():
|
||||||
continue
|
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])
|
audio_values.append(frame[1])
|
||||||
|
|
||||||
average_dBFS = 0 if not audio_values else np.average(audio_values)
|
average_dBFS = 0 if not audio_values else np.average(audio_values)
|
||||||
@ -461,6 +465,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
camera,
|
camera,
|
||||||
frame_time,
|
frame_time,
|
||||||
dBFS,
|
dBFS,
|
||||||
|
audio_detections,
|
||||||
) = self.audio_recordings_info_queue.get(True, timeout=0.01)
|
) = self.audio_recordings_info_queue.get(True, timeout=0.01)
|
||||||
|
|
||||||
if frame_time < run_start - stale_frame_count_threshold:
|
if frame_time < run_start - stale_frame_count_threshold:
|
||||||
@ -471,6 +476,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
(
|
(
|
||||||
frame_time,
|
frame_time,
|
||||||
dBFS,
|
dBFS,
|
||||||
|
audio_detections,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
|
Loading…
Reference in New Issue
Block a user