added birdnet.conf changes check -- needs more testing, but seems
to work well
This commit is contained in:
@@ -415,6 +415,8 @@ RECORDING_LENGTH=
|
|||||||
|
|
||||||
EXTRACTION_LENGTH=
|
EXTRACTION_LENGTH=
|
||||||
|
|
||||||
|
LAST_RUN=
|
||||||
|
THIS_RUN=
|
||||||
EOF
|
EOF
|
||||||
[ -d /etc/birdnet ] || sudo mkdir /etc/birdnet
|
[ -d /etc/birdnet ] || sudo mkdir /etc/birdnet
|
||||||
sudo ln -sf ${my_dir}/birdnet.conf /etc/birdnet/birdnet.conf
|
sudo ln -sf ${my_dir}/birdnet.conf /etc/birdnet/birdnet.conf
|
||||||
|
|||||||
@@ -251,3 +251,5 @@ VENV=$(dirname ${my_dir})/miniforge/envs/birdnet
|
|||||||
RECORDING_LENGTH=
|
RECORDING_LENGTH=
|
||||||
|
|
||||||
EXTRACTION_LENGTH=
|
EXTRACTION_LENGTH=
|
||||||
|
|
||||||
|
LAST_RUN=
|
||||||
|
|||||||
@@ -2,6 +2,25 @@
|
|||||||
# Runs BirdNET-Lite
|
# Runs BirdNET-Lite
|
||||||
#set -x
|
#set -x
|
||||||
source /etc/birdnet/birdnet.conf
|
source /etc/birdnet/birdnet.conf
|
||||||
|
# Document this run's birdnet.conf settings
|
||||||
|
# Make a temporary file to compare the current birdnet.conf with
|
||||||
|
# the birdnet.conf as it was the last time this script was called
|
||||||
|
make_thisrun() {
|
||||||
|
sleep .4
|
||||||
|
awk '!/#/ && !/^$/ {print}' /etc/birdnet/birdnet.conf \
|
||||||
|
> >(tee "${THIS_RUN}")
|
||||||
|
sleep .5
|
||||||
|
}
|
||||||
|
make_thisrun &> /dev/null
|
||||||
|
if ! diff ${LAST_RUN} ${THIS_RUN};then
|
||||||
|
echo "The birdnet.conf file has changed"
|
||||||
|
echo "Reloading services"
|
||||||
|
cat ${THIS_RUN} > ${LAST_RUN}
|
||||||
|
until restart_birdnet.sh;do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
CUSTOM_LIST="/home/pi/BirdNET-Lite/custom_species_list.txt"
|
CUSTOM_LIST="/home/pi/BirdNET-Lite/custom_species_list.txt"
|
||||||
|
|
||||||
# Create an array of the audio files
|
# Create an array of the audio files
|
||||||
@@ -38,6 +57,7 @@ move_analyzed() {
|
|||||||
# Uses one argument:
|
# Uses one argument:
|
||||||
# - {DIRECTORY}
|
# - {DIRECTORY}
|
||||||
run_analysis() {
|
run_analysis() {
|
||||||
|
sleep .5
|
||||||
echo "Starting run_analysis() for ${1:19}"
|
echo "Starting run_analysis() for ${1:19}"
|
||||||
|
|
||||||
|
|
||||||
@@ -58,7 +78,6 @@ run_analysis() {
|
|||||||
cd ${HOME}/BirdNET-Lite || exit 1
|
cd ${HOME}/BirdNET-Lite || exit 1
|
||||||
for i in "${files[@]}";do
|
for i in "${files[@]}";do
|
||||||
|
|
||||||
set -x
|
|
||||||
FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 \
|
FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 \
|
||||||
| awk -F. '/Duration/ {print $1}' \
|
| awk -F. '/Duration/ {print $1}' \
|
||||||
| cut -d':' -f3-4)"
|
| cut -d':' -f3-4)"
|
||||||
@@ -71,6 +90,7 @@ run_analysis() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ${1}/${i} ] && [ ! -f ${CUSTOM_LIST} ];then
|
if [ -f ${1}/${i} ] && [ ! -f ${CUSTOM_LIST} ];then
|
||||||
|
set -x
|
||||||
python3 analyze.py \
|
python3 analyze.py \
|
||||||
--i "${1}/${i}" \
|
--i "${1}/${i}" \
|
||||||
--o "${1}/${i}.csv" \
|
--o "${1}/${i}.csv" \
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
|
|||||||
trap 'echo "\"${last_command}\" command exited with code $?."' EXIT
|
trap 'echo "\"${last_command}\" command exited with code $?."' EXIT
|
||||||
# Remove temporary file
|
# Remove temporary file
|
||||||
trap 'rm -f $TMPFILE' EXIT
|
trap 'rm -f $TMPFILE' EXIT
|
||||||
|
|
||||||
source /etc/birdnet/birdnet.conf
|
source /etc/birdnet/birdnet.conf
|
||||||
|
|
||||||
# Set Variables
|
# Set Variables
|
||||||
|
|||||||
@@ -437,6 +437,8 @@ RECORDING_LENGTH=
|
|||||||
|
|
||||||
EXTRACTION_LENGTH=
|
EXTRACTION_LENGTH=
|
||||||
|
|
||||||
|
LAST_RUN=$(dirname ${my_dir})/lastrun.txt
|
||||||
|
THIS_RUN=$(dirname ${my_dir})/thisrun.txt
|
||||||
EOF
|
EOF
|
||||||
[ -d /etc/birdnet ] || sudo mkdir /etc/birdnet
|
[ -d /etc/birdnet ] || sudo mkdir /etc/birdnet
|
||||||
sudo ln -sf $(dirname ${my_dir})/birdnet.conf /etc/birdnet/birdnet.conf
|
sudo ln -sf $(dirname ${my_dir})/birdnet.conf /etc/birdnet/birdnet.conf
|
||||||
|
|||||||
Reference in New Issue
Block a user