Don't fail on 0 rms (#8447)

This commit is contained in:
Nicolas Mowen 2023-11-03 20:18:23 -06:00 committed by GitHub
parent b54aaad382
commit 7270eef6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -240,7 +240,10 @@ class AudioEventMaintainer(threading.Thread):
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))