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
and set the passwords for the live audio stream. Save the file after editing
and then close the Mouse Pad editing window to continue."
mousepad ${my_dir}/Birders_Guide_Installer_Configuration.txt &> /dev/null
while pgrep mouse &> /dev/null;do
if ( env | grep SSH_CONNECTION &> /dev/null );then
editor=nano
else
editor=mousepad
fi
$editor ${my_dir}/Birders_Guide_Installer_Configuration.txt &> /dev/null
while pgrep $editor &> /dev/null;do
sleep 1
done
source ${my_dir}/Birders_Guide_Installer_Configuration.txt || exit 1
+2
View File
@@ -150,6 +150,8 @@ run_birdnet() {
run_analysis "${1}"
}
date
if [ $(find ${RECS_DIR} -maxdepth 1 -name '*wav' | wc -l) -gt 0 ];then
run_birdnet "${RECS_DIR}"
fi
+35 -25
View File
@@ -7,7 +7,7 @@ setterm --cursor off
TMP_FILE="$(mktemp)"
while true;do
cat << "EOF"
cat << "EOF"
.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.
( _ ____ __ _ )
) |_)o.__||\ ||_ |__(_ __|_ _ ._ _ |_) _ ._ _ .__|_ (
@@ -15,54 +15,64 @@ cat << "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' \
| awk -F "/" '{print $NF}' \
| cut -d'-' -f1 \
| sort -n \
| tail -n1 )
else
else
a=0
fi
echo
if [ "${a}" -ge "1" ];then
fi
echo
if [ "${a}" -ge "1" ];then
SOFAR=$(($(wc -l ${IDFILE}| cut -d' ' -f1)/2))
else
else
SOFAR=0
fi
if [ $SOFAR = 1 ];then
fi
if [ $SOFAR = 1 ];then
verbage=detection
else
else
verbage=detections
fi
echo " -$a $verbage so far"
echo
echo " -$SOFAR species identified so far"
echo
if [ ${a} -ge 1 ];then
while read -r line;do
fi
echo " -$a $verbage so far"
echo
echo " -$SOFAR species identified so far"
echo
if [ ${a} -ge 1 ];then
while read -r line;do
# Get species name
SPECIES="$(echo "${line}" | awk -F: '/Common Name/ {print $2}')"
SPECIES="${SPECIES// /_}"
SPECIES="$(echo ${SPECIES/_} | tr -d "'")"
[ -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')"
# Parse highest confidence score
MAX_SCORE="$(echo "${ALL_DETECTION_FILES}"| awk -F% '{print $1}')"
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)"
if [ ${DETECTIONS} = 1 ];then
verbage=detection
else
verbage=detections
fi
# Write results to temporary file
echo "${DETECTIONS} $verbage for ${SPECIES//_/ } | max conf ${MAX_SCORE}%"
done < "${IDFILE}" > ${TMP_FILE}
sort -rk1 -h "${TMP_FILE}"
fi
echo
echo -n "Listening since "${INSTALL_DATE}""
sleep 20
clear
done < "${IDFILE}" > ${TMP_FILE}
# Print temporary file sorted by # of detections
sort -rk1 -h "${TMP_FILE}"
fi
echo
echo -n "Listening since "${INSTALL_DATE}""
sleep 20
clear
done