diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index f23a32270..1f1d1b086 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -145,6 +145,12 @@ audio: enabled: False # Optional: Configure the amount of seconds without detected audio to end the event (default: shown below) max_not_heard: 30 + # Optional: Configure the min rms volume required to run audio detection (default: shown below) + # As a rule of thumb: + # - 200 - high sensitivity + # - 500 - medium sensitivity + # - 1000 - low sensitivity + min_volume: 500 # Optional: Types of audio to listen for (default: shown below) listen: - bark diff --git a/frigate/config.py b/frigate/config.py index 9399320fe..4f789c3eb 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -393,6 +393,9 @@ class AudioConfig(FrigateBaseModel): max_not_heard: int = Field( default=30, title="Seconds of not hearing the type of audio to end the event." ) + min_volume: int = Field( + default=500, title="Min volume required to run audio detection." + ) listen: List[str] = Field( default=DEFAULT_LISTEN_AUDIO, title="Audio to listen for." ) diff --git a/frigate/events/audio.py b/frigate/events/audio.py index de0f07e0c..898c4b893 100644 --- a/frigate/events/audio.py +++ b/frigate/events/audio.py @@ -169,14 +169,18 @@ class AudioEventMaintainer(threading.Thread): if not self.feature_metrics[self.config.name]["audio_enabled"].value: return - waveform = (audio / AUDIO_MAX_BIT_RANGE).astype(np.float32) - model_detections = self.detector.detect(waveform) + rms = np.sqrt(np.mean(np.absolute(audio.astype(np.float32)**2))) - for label, score, _ in model_detections: - if label not in self.config.audio.listen: - continue + # only run audio detection when volume is above min_volume + if rms >= self.config.audio.min_volume: + waveform = (audio / AUDIO_MAX_BIT_RANGE).astype(np.float32) + model_detections = self.detector.detect(waveform) - self.handle_detection(label, score) + for label, score, _ in model_detections: + if label not in self.config.audio.listen: + continue + + self.handle_detection(label, score) self.expire_detections()