Adding support to create minimalist raw spectrogram images
This commit is contained in:
@@ -195,6 +195,11 @@ DATABASE_LANG=en
|
|||||||
|
|
||||||
SILENCE_UPDATE_INDICATOR=0
|
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
|
||||||
|
|
||||||
## HEARTBEAT_URL is a location to ping every time some analysis is done
|
## 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
|
## no information is sent to the the URL, it is a heart beat to show that the
|
||||||
## analysis is continuing
|
## analysis is continuing
|
||||||
|
|||||||
@@ -200,6 +200,17 @@ if(isset($_GET['submit'])) {
|
|||||||
$contents2 = preg_replace("/SILENCE_UPDATE_INDICATOR=.*/", "SILENCE_UPDATE_INDICATOR=0", $contents2);
|
$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");
|
$fh = fopen('/etc/birdnet/birdnet.conf', "w");
|
||||||
$fh2 = fopen("./scripts/thisrun.txt", "w");
|
$fh2 = fopen("./scripts/thisrun.txt", "w");
|
||||||
fwrite($fh, $contents);
|
fwrite($fh, $contents);
|
||||||
@@ -287,6 +298,9 @@ foreach($formats as $format){
|
|||||||
<label for="silence_update_indicator">Silence Update Indicator: </label>
|
<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>
|
<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>
|
<h3>BirdNET-Lite Settings</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -118,11 +118,22 @@ for h in "${SCAN_DIRS[@]}";do
|
|||||||
sox -V1 "${h}/${OLDFILE}" "${NEWSPECIES_BYDATE}/${NEWFILE}" \
|
sox -V1 "${h}/${OLDFILE}" "${NEWSPECIES_BYDATE}/${NEWFILE}" \
|
||||||
trim ="${START}" ="${END}"
|
trim ="${START}" ="${END}"
|
||||||
|
|
||||||
# Create spectrogram for extraction
|
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 \
|
sox -V1 "${NEWSPECIES_BYDATE}/${NEWFILE}" -n remix 1 rate 24k spectrogram \
|
||||||
-t "${COMMON_NAME}" \
|
-t "${COMMON_NAME}" \
|
||||||
-c "${NEWSPECIES_BYDATE//$HOME\/}/${NEWFILE}" \
|
-c "${NEWSPECIES_BYDATE//$HOME\/}/${NEWFILE}" \
|
||||||
-o "${NEWSPECIES_BYDATE}/${NEWFILE}.png"
|
-o "${NEWSPECIES_BYDATE}/${NEWFILE}.png"
|
||||||
|
fi
|
||||||
|
|
||||||
done < "${TMPFILE}"
|
done < "${TMPFILE}"
|
||||||
|
|
||||||
|
|||||||
@@ -228,6 +228,11 @@ HEARTBEAT_URL=
|
|||||||
|
|
||||||
SILENCE_UPDATE_INDICATOR=0
|
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 debugging
|
## These are just for debugging
|
||||||
LAST_RUN=
|
LAST_RUN=
|
||||||
THIS_RUN=
|
THIS_RUN=
|
||||||
|
|||||||
@@ -168,5 +168,9 @@ if ! grep -q 'RuntimeMaxSec=' "$HOME/BirdNET-Pi/templates/birdnet_analysis.servi
|
|||||||
sudo systemctl daemon-reload && restart_services.sh
|
sudo systemctl daemon-reload && restart_services.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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-reload
|
sudo systemctl daemon-reload
|
||||||
restart_services.sh
|
restart_services.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user