From cb102044e64aa48b1563324965ca1715546e284a Mon Sep 17 00:00:00 2001 From: Patrick McGuire Date: Fri, 1 Oct 2021 19:35:11 -0400 Subject: [PATCH] adding RECORDING_LENGTH and EXTRACTION_LENGTH --- scripts/birdnet_analysis.sh | 15 +++++++++------ scripts/birdnet_recording.sh | 2 ++ scripts/extract_new_birdsounds.sh | 1 + scripts/install_config.sh | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/birdnet_analysis.sh b/scripts/birdnet_analysis.sh index dd91ad2..ef1fc48 100755 --- a/scripts/birdnet_analysis.sh +++ b/scripts/birdnet_analysis.sh @@ -42,13 +42,16 @@ run_analysis() { WEEK=$(date +"%U") cd ${HOME}/BirdNET-Lite || exit 1 for i in "${files[@]}";do + + set -x + FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 \ + | awk -F. '/Duration/ {print $1}' \ + | cut -d':' -f3-4)" + [ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=9 + [ ${RECORDING_LENGTH} == "60" ] && RECORDING_LENGTH=01:00 + [ "${FILE_LENGTH}" == "00:${RECORDING_LENGTH}" ] || continue + 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" \ diff --git a/scripts/birdnet_recording.sh b/scripts/birdnet_recording.sh index 33ccd70..8a2c3a3 100755 --- a/scripts/birdnet_recording.sh +++ b/scripts/birdnet_recording.sh @@ -8,6 +8,8 @@ else STAMP="%H:%M:%S" fi +[ -z RECORDING_LENGTH ] || RECORDING_LENGTH=9 + if pgrep arecord &> /dev/null ;then echo "Recording" else diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh index f3561d8..e1a155b 100755 --- a/scripts/extract_new_birdsounds.sh +++ b/scripts/extract_new_birdsounds.sh @@ -130,6 +130,7 @@ for h in "${SCAN_DIRS[@]}";do ### TESTING longer extraction context set -x + [ -z ${EXTRACTION_LENGTH} ] || EXTRACTION_LENGTH=6 SPACER=$(echo "(${EXTRACTION_LENGTH} - 3 )/2" |bc -l) START=$(echo "${START} - ${SPACER}"|bc -l) END=$(echo "${END} + ${SPACER}"|bc -l) diff --git a/scripts/install_config.sh b/scripts/install_config.sh index 839a937..fc49a77 100755 --- a/scripts/install_config.sh +++ b/scripts/install_config.sh @@ -169,8 +169,8 @@ get_CHANNELS() { | uniq)" script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a "${SOUND_PARAMS}" &> /dev/null CHANNELS=$(awk '/CHANN/ { print $2 }' "${SOUND_PARAMS}" | sed 's/\r$//') - [ -z REC_CARD ] || REC_CARD=default - [ -z CHANNELS ] || CHANNELS=2 + [ -z REC_CARD ] && REC_CARD=default + [ -z CHANNELS ] && CHANNELS=2 echo "REC_CARD variable set to ${REC_CARD}" echo "Number of channels available: ${CHANNELS}" }