spectrum: rate limit generating spectrum

This commit is contained in:
frederik
2024-01-18 15:08:55 +01:00
parent 387d7fa700
commit 7d416992a5
+11 -4
View File
@@ -12,13 +12,20 @@ if [ "$LOGGING_LEVEL" == "info" ] || [ "$LOGGING_LEVEL" == "debug" ];then
set -x
fi
next=0
looptime=$(( RECORDING_LENGTH * 2 / 3 ))
# Continuously loop generating a spectrogram
inotifywait -m -e close_write "$HOME/BirdNET-Pi/analyzing_now.txt" |
while read; do
analyzing_now="$(<$HOME/BirdNET-Pi/analyzing_now.txt)"
now=$(date +%s)
if (( now > next )); then
analyzing_now="$(<$HOME/BirdNET-Pi/analyzing_now.txt)"
if [ -n "${analyzing_now}" ] && [ -f "${analyzing_now}" ]; then
spectrogram_png=${EXTRACTED}/spectrogram.png
sox -V1 "${analyzing_now}" -n remix 1 rate 24k spectrogram -c "${analyzing_now//$HOME\//}" -o "${spectrogram_png}"
if [ -n "${analyzing_now}" ] && [ -f "${analyzing_now}" ]; then
spectrogram_png=${EXTRACTED}/spectrogram.png
sox -V1 "${analyzing_now}" -n remix 1 rate 24k spectrogram -c "${analyzing_now//$HOME\//}" -o "${spectrogram_png}"
fi
next=$(( now + looptime ))
fi
done