fixed a weirdness in the birdnet_stats.sh script

This commit is contained in:
Patrick McGuire
2021-10-06 10:20:19 -04:00
parent d9573dbea1
commit 7cd299ebeb
3 changed files with 66 additions and 49 deletions
+7 -2
View File
@@ -116,8 +116,13 @@ stage_2() {
echo "Follow the instructions to fill out the LATITUDE and LONGITUDE variables echo "Follow the instructions to fill out the LATITUDE and LONGITUDE variables
and set the passwords for the live audio stream. Save the file after editing and set the passwords for the live audio stream. Save the file after editing
and then close the Mouse Pad editing window to continue." and then close the Mouse Pad editing window to continue."
mousepad ${my_dir}/Birders_Guide_Installer_Configuration.txt &> /dev/null if ( env | grep SSH_CONNECTION &> /dev/null );then
while pgrep mouse &> /dev/null;do editor=nano
else
editor=mousepad
fi
$editor ${my_dir}/Birders_Guide_Installer_Configuration.txt &> /dev/null
while pgrep $editor &> /dev/null;do
sleep 1 sleep 1
done done
source ${my_dir}/Birders_Guide_Installer_Configuration.txt || exit 1 source ${my_dir}/Birders_Guide_Installer_Configuration.txt || exit 1
+2
View File
@@ -150,6 +150,8 @@ run_birdnet() {
run_analysis "${1}" run_analysis "${1}"
} }
date
if [ $(find ${RECS_DIR} -maxdepth 1 -name '*wav' | wc -l) -gt 0 ];then if [ $(find ${RECS_DIR} -maxdepth 1 -name '*wav' | wc -l) -gt 0 ];then
run_birdnet "${RECS_DIR}" run_birdnet "${RECS_DIR}"
fi fi
+11 -1
View File
@@ -41,24 +41,34 @@ echo " -$SOFAR species identified so far"
echo echo
if [ ${a} -ge 1 ];then if [ ${a} -ge 1 ];then
while read -r line;do while read -r line;do
# Get species name
SPECIES="$(echo "${line}" | awk -F: '/Common Name/ {print $2}')" SPECIES="$(echo "${line}" | awk -F: '/Common Name/ {print $2}')"
SPECIES="${SPECIES// /_}" SPECIES="${SPECIES// /_}"
SPECIES="$(echo ${SPECIES/_} | tr -d "'")" SPECIES="$(echo ${SPECIES/_} | tr -d "'")"
[ -z ${SPECIES} ] && continue [ -z ${SPECIES} ] && continue
ALL_DETECTION_FILES="$(ls -1 ${EXTRACTED}/By_Date/*/${SPECIES})" # Get all detection files
ALL_DETECTION_FILES="$(find ${EXTRACTED}/By_Date/*/${SPECIES} -name '*.wav')"
ALL_DETECTION_FILES="$(echo ${ALL_DETECTION_FILES[@]} | tr ' ' '\n')" ALL_DETECTION_FILES="$(echo ${ALL_DETECTION_FILES[@]} | tr ' ' '\n')"
# Parse highest confidence score
MAX_SCORE="$(echo "${ALL_DETECTION_FILES}"| awk -F% '{print $1}')" MAX_SCORE="$(echo "${ALL_DETECTION_FILES}"| awk -F% '{print $1}')"
MAX_SCORE="$(echo "${MAX_SCORE[@]}" | rev |cut -d"-" -f1|rev | sort -r | head -n1)" MAX_SCORE="$(echo "${MAX_SCORE[@]}" | rev |cut -d"-" -f1|rev | sort -r | head -n1)"
# Set noun-plurality agreement for grammar
DETECTIONS="$(ls -1 ${EXTRACTED}/By_Date/*/${SPECIES} | wc -l)" DETECTIONS="$(ls -1 ${EXTRACTED}/By_Date/*/${SPECIES} | wc -l)"
if [ ${DETECTIONS} = 1 ];then if [ ${DETECTIONS} = 1 ];then
verbage=detection verbage=detection
else else
verbage=detections verbage=detections
fi fi
# Write results to temporary file
echo "${DETECTIONS} $verbage for ${SPECIES//_/ } | max conf ${MAX_SCORE}%" echo "${DETECTIONS} $verbage for ${SPECIES//_/ } | max conf ${MAX_SCORE}%"
done < "${IDFILE}" > ${TMP_FILE} done < "${IDFILE}" > ${TMP_FILE}
# Print temporary file sorted by # of detections
sort -rk1 -h "${TMP_FILE}" sort -rk1 -h "${TMP_FILE}"
fi fi
echo echo