A live bird collage card for your Home Assistant dashboard.
Adding support to create minimalist raw spectrogram images
ehpersonal38adefbadb5fb7
diff --git a/birdnet.conf-defaults b/birdnet.conf-defaultsindex e9cbbfb6..43215e58 100644--- a/birdnet.conf-defaults+++ b/birdnet.conf-defaults@@ -195,6 +195,11 @@ DATABASE_LANG=enSILENCE_UPDATE_INDICATOR=0+## RAW_SPECTROGRAM is for removing the axes and labels of the spectrograms+## that are generated by Sox for each detection for a cleaner appearance.++RAW_SPECTROGRAM=0+## HEARTBEAT_URL is a location to ping every time some analysis is done## no information is sent to the the URL, it is a heart beat to show that the## analysis is continuingdiff --git a/scripts/advanced.php b/scripts/advanced.phpindex 2e09f060..f91a282a 100644--- a/scripts/advanced.php+++ b/scripts/advanced.php@@ -200,6 +200,17 @@ if(isset($_GET['submit'])) {$contents2 = preg_replace("/SILENCE_UPDATE_INDICATOR=.*/", "SILENCE_UPDATE_INDICATOR=0", $contents2);}+ if(isset($_GET["raw_spectrogram"])) {+ $raw_spectrogram = 1;+ if(strcmp($RAW_SPECTROGRAM,$config['RAW_SPECTROGRAM']) !== 0) {+ $contents = preg_replace("/RAW_SPECTROGRAM=.*/", "RAW_SPECTROGRAM=$raw_spectrogram", $contents);+ $contents2 = preg_replace("/RAW_SPECTROGRAM=.*/", "RAW_SPECTROGRAM=$raw_spectrogram", $contents2);+ }+ } else {+ $contents = preg_replace("/RAW_SPECTROGRAM=.*/", "RAW_SPECTROGRAM=0", $contents);+ $contents2 = preg_replace("/RAW_SPECTROGRAM=.*/", "RAW_SPECTROGRAM=0", $contents2);+ }+$fh = fopen('/etc/birdnet/birdnet.conf', "w");$fh2 = fopen("./scripts/thisrun.txt", "w");fwrite($fh, $contents);@@ -287,6 +298,9 @@ foreach($formats as $format){<label for="silence_update_indicator">Silence Update Indicator: </label><input type="checkbox" name="silence_update_indicator" <?php if($newconfig['SILENCE_UPDATE_INDICATOR'] == 1) { echo "checked"; };?> ><br>+ <label for="raw_spectrogram">Silence Update Indicator: </label>+ <input type="checkbox" name="raw_spectrogram" <?php if($newconfig['RAW_SPECTROGRAM'] == 1) { echo "checked"; };?> ><br>+<h3>BirdNET-Lite Settings</h3><p>diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.shindex 297c48d1..60b9bb34 100755--- a/scripts/extract_new_birdsounds.sh+++ b/scripts/extract_new_birdsounds.sh@@ -118,11 +118,22 @@ for h in "${SCAN_DIRS[@]}";dosox -V1 "${h}/${OLDFILE}" "${NEWSPECIES_BYDATE}/${NEWFILE}" \trim ="${START}" ="${END}"- # Create spectrogram for extraction- sox -V1 "${NEWSPECIES_BYDATE}/${NEWFILE}" -n remix 1 rate 24k spectrogram \- -t "${COMMON_NAME}" \- -c "${NEWSPECIES_BYDATE//$HOME\/}/${NEWFILE}" \- -o "${NEWSPECIES_BYDATE}/${NEWFILE}.png"+ RAW_SPECTROGRAM=${RAW_SPECTROGRAM}+ # Check if RAW_SPECTROGRAM is 1+ if [ "$RAW_SPECTROGRAM" == "1" ]; then+ # If it is, add "-r" as an argument to the SOX command+ sox -V1 "${NEWSPECIES_BYDATE}/${NEWFILE}" -n remix 1 rate 24k spectrogram \+ -t "${COMMON_NAME}" \+ -c "${NEWSPECIES_BYDATE//$HOME\/}/${NEWFILE}" \+ -o "${NEWSPECIES_BYDATE}/${NEWFILE}.png" \+ -r+ else+ # If it's not, run the SOX command without the "-r" argument+ sox -V1 "${NEWSPECIES_BYDATE}/${NEWFILE}" -n remix 1 rate 24k spectrogram \+ -t "${COMMON_NAME}" \+ -c "${NEWSPECIES_BYDATE//$HOME\/}/${NEWFILE}" \+ -o "${NEWSPECIES_BYDATE}/${NEWFILE}.png"+ fidone < "${TMPFILE}"diff --git a/scripts/install_config.sh b/scripts/install_config.shindex 162b16dd..f5e36982 100755--- a/scripts/install_config.sh+++ b/scripts/install_config.sh@@ -228,6 +228,11 @@ HEARTBEAT_URL=SILENCE_UPDATE_INDICATOR=0+## RAW_SPECTROGRAM is for removing the axes and labels of the spectrograms+## that are generated by Sox for each detection for a cleaner appearance.++RAW_SPECTROGRAM=0+## These are just for debuggingLAST_RUN=THIS_RUN=diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.shindex 281e889b..65c24f12 100755--- a/scripts/update_birdnet_snippets.sh+++ b/scripts/update_birdnet_snippets.sh@@ -168,5 +168,9 @@ if ! grep -q 'RuntimeMaxSec=' "$HOME/BirdNET-Pi/templates/birdnet_analysis.servisudo systemctl daemon-reload && restart_services.shfi+if ! grep RAW_SPECTROGRAM /etc/birdnet/birdnet.conf &>/dev/null;then+ sudo -u$USER echo "RAW_SPECTROGRAM=0" >> /etc/birdnet/birdnet.conf+fi+sudo systemctl daemon-reloadrestart_services.sh