added EXTRACTION_LENGTH for testing
This commit is contained in:
@@ -10,7 +10,7 @@ CUSTOM_LIST="/home/pi/BirdNET-Lite/custom_species_list.txt"
|
||||
get_files() {
|
||||
echo "get_files() for ${1:19}"
|
||||
files=($( find ${1} -maxdepth 1 -name '*wav' \
|
||||
| sort \
|
||||
| sort -r \
|
||||
| awk -F "/" '{print $NF}' ))
|
||||
[ -n "${files[1]}" ] && echo "Files loaded"
|
||||
}
|
||||
@@ -39,11 +39,16 @@ move_analyzed() {
|
||||
# - {DIRECTORY}
|
||||
run_analysis() {
|
||||
echo "Starting run_analysis() for ${1:19}"
|
||||
WEEK=$(date --date="${2}" +"%U")
|
||||
WEEK=$(date +"%U")
|
||||
cd ${HOME}/BirdNET-Lite || exit 1
|
||||
for i in "${files[@]}";do
|
||||
if [ -f ${1}/${i} ] && [ ! -f ${CUSTOM_LIST} ];then
|
||||
FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 \
|
||||
| awk -F. '/Duration/ {print $1}' \
|
||||
| cut -d':' -f3-4)"
|
||||
set -x
|
||||
[ ${RECORDING_LENGTH} == 60 ] && RECORDING_LENGTH=01:00
|
||||
[ "${FILE_LENGTH}" == "${RECORDING_LENGTH}" ] || continue
|
||||
python3 analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
@@ -72,9 +77,8 @@ run_analysis() {
|
||||
}
|
||||
|
||||
# The three main functions
|
||||
# Requires 2 arguments:
|
||||
# Takes one argument:
|
||||
# - {DIRECTORY}
|
||||
# - {"today", "yesterday", "2 days ago",...}
|
||||
run_birdnet() {
|
||||
echo "Starting run_birdnet() for \"${1:19}\""
|
||||
get_files "${1}"
|
||||
|
||||
@@ -128,6 +128,16 @@ for h in "${SCAN_DIRS[@]}";do
|
||||
# structured by-species, symbolic links are made to populate the new
|
||||
# directory.
|
||||
|
||||
### TESTING longer extraction context
|
||||
set -x
|
||||
SPACER=$(echo "(${EXTRACTION_LENGTH} - 3 )/2" |bc -l)
|
||||
START=$(echo "${START} - ${SPACER}"|bc -l)
|
||||
END=$(echo "${END} + ${SPACER}"|bc -l)
|
||||
|
||||
if (( $(echo "${START} < 0" | bc -l) ));then START=0;fi
|
||||
if (( $(echo "${END} > ${RECORDING_LENGTH}" | bc -l) ));then END=${RECORDING_LENGTH};fi
|
||||
|
||||
set +x
|
||||
ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \
|
||||
-acodec copy -ss "${START}" -to "${END}"\
|
||||
"${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"
|
||||
|
||||
Reference in New Issue
Block a user