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
+35 -25
View File
@@ -7,7 +7,7 @@ setterm --cursor off
TMP_FILE="$(mktemp)" TMP_FILE="$(mktemp)"
while true;do while true;do
cat << "EOF" cat << "EOF"
.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+. .+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.
( _ ____ __ _ ) ( _ ____ __ _ )
) |_)o.__||\ ||_ |__(_ __|_ _ ._ _ |_) _ ._ _ .__|_ ( ) |_)o.__||\ ||_ |__(_ __|_ _ ._ _ |_) _ ._ _ .__|_ (
@@ -15,54 +15,64 @@ cat << "EOF"
) / | ( ) / | (
"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+" "+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"
EOF EOF
if [ "$(find ${EXTRACTED} -name '*.wav' | wc -l)" -ge 1 ];then if [ "$(find ${EXTRACTED} -name '*.wav' | wc -l)" -ge 1 ];then
a=$( find "${EXTRACTED}" -name '*.wav' \ a=$( find "${EXTRACTED}" -name '*.wav' \
| awk -F "/" '{print $NF}' \ | awk -F "/" '{print $NF}' \
| cut -d'-' -f1 \ | cut -d'-' -f1 \
| sort -n \ | sort -n \
| tail -n1 ) | tail -n1 )
else else
a=0 a=0
fi fi
echo echo
if [ "${a}" -ge "1" ];then if [ "${a}" -ge "1" ];then
SOFAR=$(($(wc -l ${IDFILE}| cut -d' ' -f1)/2)) SOFAR=$(($(wc -l ${IDFILE}| cut -d' ' -f1)/2))
else else
SOFAR=0 SOFAR=0
fi fi
if [ $SOFAR = 1 ];then if [ $SOFAR = 1 ];then
verbage=detection verbage=detection
else else
verbage=detections verbage=detections
fi fi
echo " -$a $verbage so far" echo " -$a $verbage so far"
echo echo
echo " -$SOFAR species identified so far" 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}
sort -rk1 -h "${TMP_FILE}"
fi # Print temporary file sorted by # of detections
echo sort -rk1 -h "${TMP_FILE}"
echo -n "Listening since "${INSTALL_DATE}"" fi
sleep 20 echo
clear echo -n "Listening since "${INSTALL_DATE}""
sleep 20
clear
done done