Skip to content

Commit

Permalink
Don't fail on 0 rms (blakeblackshear#8447)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Nov 4, 2023
1 parent b54aaad commit 7270eef
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frigate/events/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ def calculate_audio_levels(self, audio_as_float: np.float32) -> Tuple[float, flo
rms = np.sqrt(np.mean(np.absolute(np.square(audio_as_float))))

# Transform RMS to dBFS (decibels relative to full scale)
dBFS = 20 * np.log10(np.abs(rms) / AUDIO_MAX_BIT_RANGE)
if rms > 0:
dBFS = 20 * np.log10(np.abs(rms) / AUDIO_MAX_BIT_RANGE)
else:
dBFS = 0

self.inter_process_communicator.queue.put(
(f"{self.config.name}/audio/dBFS", float(dBFS))
Expand Down

0 comments on commit 7270eef

Please sign in to comment.