added 12/24h timestamp formatting as birdnet.conf variable
defaults to 24h timestamps working on species_notifier.sh
This commit is contained in:
@@ -155,7 +155,7 @@ Good luck!"
|
|||||||
| uniq)"
|
| uniq)"
|
||||||
script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a ${SOUND_PARAMS} &> /dev/null
|
script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a ${SOUND_PARAMS} &> /dev/null
|
||||||
install_birdnet_config || exit 1
|
install_birdnet_config || exit 1
|
||||||
echo "Installing the BirdNET-Lite"
|
echo "Installing BirdNET-Lite"
|
||||||
if ${my_dir}/scripts/install_birdnet.sh << EOF ; then
|
if ${my_dir}/scripts/install_birdnet.sh << EOF ; then
|
||||||
|
|
||||||
n
|
n
|
||||||
@@ -211,14 +211,32 @@ DO_EXTRACTIONS=y
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------------- Recording Service ----------------------------#
|
#----------------------------- Recording Service ----------------------------#
|
||||||
|
#_______________The two variables below can be set to enable __________________#
|
||||||
|
#________________________the birdnet_recording.service ________________________#
|
||||||
|
|
||||||
# Keep this EMPTY if you do not want this device to perform the recording. #
|
# Keep this EMPTY if you do not want this device to perform the recording. #
|
||||||
|
|
||||||
## DO_RECORDING is simply a setting for enabling the 24/7 birdnet_recording.service.
|
## DO_RECORDING is simply a setting for enabling the 24/7
|
||||||
|
## birdnet_recording.service.
|
||||||
## Set this to Y or y to enable recording.
|
## Set this to Y or y to enable recording.
|
||||||
|
|
||||||
DO_RECORDING=y
|
DO_RECORDING=y
|
||||||
|
|
||||||
|
## TIMESTAMP_FORMAT is the format the recording service will use to name its
|
||||||
|
## files. Setting this variable to "12" will name the recorded (and extracted)
|
||||||
|
## files using the 12-hour AM/PM time format. Setting this variable to "24"
|
||||||
|
## will name the files using the 24-hour time format. See examples below:
|
||||||
|
#
|
||||||
|
## TIMESTAMP_FORMAT=12
|
||||||
|
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav
|
||||||
|
#
|
||||||
|
## TIMESTAMP_FORMAT=24
|
||||||
|
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav
|
||||||
|
|
||||||
|
|
||||||
|
TIMESTAMP_FORMAT=24
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------- Mounting a remote directory with systemd -----------------#
|
#----------------- Mounting a remote directory with systemd -----------------#
|
||||||
#_______________The four variables below can be set to enable a_______________#
|
#_______________The four variables below can be set to enable a_______________#
|
||||||
|
|||||||
+22
-7
@@ -28,6 +28,8 @@ LONGITUDE=
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#------------------------------ Extraction Service ---------------------------#
|
#------------------------------ Extraction Service ---------------------------#
|
||||||
|
#__________________The variable below can be set to enable the ________________#
|
||||||
|
#______________________________ extraction.service ____________________________#
|
||||||
|
|
||||||
# Keep this EMPTY if you do not want this device to perform the extractions #
|
# Keep this EMPTY if you do not want this device to perform the extractions #
|
||||||
|
|
||||||
@@ -38,17 +40,34 @@ DO_EXTRACTIONS=
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------------- Recording Service ----------------------------#
|
#----------------------------- Recording Service ----------------------------#
|
||||||
|
#_______________The two variables below can be set to enable __________________#
|
||||||
|
#________________________the birdnet_recording.service ________________________#
|
||||||
|
|
||||||
# Keep this EMPTY if you do not want this device to perform the recording. #
|
# Keep this EMPTY if you do not want this device to perform the recording. #
|
||||||
|
|
||||||
## DO_RECORDING is simply a setting for enabling the 24/7 birdnet_recording.service.
|
## DO_RECORDING is simply a setting for enabling the 24/7
|
||||||
|
## birdnet_recording.service.
|
||||||
## Set this to Y or y to enable recording.
|
## Set this to Y or y to enable recording.
|
||||||
|
|
||||||
DO_RECORDING=
|
DO_RECORDING=
|
||||||
|
|
||||||
|
## TIMESTAMP_FORMAT is the format the recording service will use to name its
|
||||||
|
## files. Setting this variable to "12" will name the recorded (and extracted)
|
||||||
|
## files using the 12-hour AM/PM time format. Setting this variable to "24"
|
||||||
|
## will name the files using the 24-hour time format. See examples below:
|
||||||
|
#
|
||||||
|
## TIMESTAMP_FORMAT=12
|
||||||
|
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav
|
||||||
|
#
|
||||||
|
## TIMESTAMP_FORMAT=24
|
||||||
|
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav
|
||||||
|
|
||||||
|
|
||||||
|
TIMESTAMP_FORMAT=
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------- Mounting a remote directory with systemd -----------------#
|
#----------------- Mounting a remote directory with systemd -----------------#
|
||||||
#_______________The four variables below can be set to enable a_______________#
|
#_______________The four variables below can be set to enable a________________#
|
||||||
#___________________systemd.mount for analysis, extraction,____________________#
|
#___________________systemd.mount for analysis, extraction,____________________#
|
||||||
#______________________________or file-serving_________________________________#
|
#______________________________or file-serving_________________________________#
|
||||||
|
|
||||||
@@ -155,11 +174,7 @@ INSTALL_NOMACHINE=
|
|||||||
## dsnoop device, you can set this explicitly from a list of the available
|
## dsnoop device, you can set this explicitly from a list of the available
|
||||||
## devices from the output of running 'aplay -L'
|
## devices from the output of running 'aplay -L'
|
||||||
|
|
||||||
REC_CARD="\$(sudo -u pi aplay -L \
|
REC_CARD=default
|
||||||
| grep dsnoop \
|
|
||||||
| cut -d, -f1 \
|
|
||||||
| grep -ve 'vc4' -e 'Head' -e 'PCH' \
|
|
||||||
| uniq)"
|
|
||||||
|
|
||||||
## PROCESSED is the directory where the formerly 'Analyzed' files are moved
|
## PROCESSED is the directory where the formerly 'Analyzed' files are moved
|
||||||
## after extractions have been made from them. This includes both WAVE and
|
## after extractions have been made from them. This includes both WAVE and
|
||||||
|
|||||||
@@ -2,15 +2,21 @@
|
|||||||
set -x
|
set -x
|
||||||
source /etc/birdnet/birdnet.conf
|
source /etc/birdnet/birdnet.conf
|
||||||
|
|
||||||
|
if [ "${TIMESTAMP_FORMAT}" == "12" ];then
|
||||||
|
STAMP="%I:%M:%S%P"
|
||||||
|
else
|
||||||
|
STAMP="%H:%M:%S"
|
||||||
|
fi
|
||||||
|
|
||||||
if pgrep arecord &> /dev/null ;then
|
if pgrep arecord &> /dev/null ;then
|
||||||
echo "Recording"
|
echo "Recording"
|
||||||
else
|
else
|
||||||
if [ -z ${REC_CARD} ];then
|
if [ -z ${REC_CARD} ];then
|
||||||
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time 9\
|
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time 9\
|
||||||
--use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%I:%M:%S%P.wav
|
--use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav
|
||||||
else
|
else
|
||||||
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time 9\
|
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time 9\
|
||||||
-D "${REC_CARD}" --use-strftime \
|
-D "${REC_CARD}" --use-strftime \
|
||||||
${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%I:%M:%S%P.wav
|
${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -31,6 +31,17 @@ get_DO_EXTRACTIONS() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_TIMESTAMP_FORMAT() {
|
||||||
|
read -n2 -p "Would you like recordings to be time stamped in 12-hour AM/PM
|
||||||
|
or 24-hour format? " TIMESTAMP_FORMAT
|
||||||
|
echo
|
||||||
|
case $TIMESTAMP_FORMAT in
|
||||||
|
12 ) ;;
|
||||||
|
24 ) ;;
|
||||||
|
* ) TIMESTAMP_FORMAT=24;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
get_DO_RECORDING() {
|
get_DO_RECORDING() {
|
||||||
while true; do
|
while true; do
|
||||||
read -n1 -p "Is this device also doing the recording? " DO_RECORDING
|
read -n1 -p "Is this device also doing the recording? " DO_RECORDING
|
||||||
@@ -144,7 +155,7 @@ get_INSTALL_NOMACHINE() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_CHANNELS() {
|
get_CHANNELS() {
|
||||||
REC_CARD="\$(sudo -u pi aplay -L \
|
REC_CARD="$(sudo -u pi aplay -L \
|
||||||
| grep dsnoop \
|
| grep dsnoop \
|
||||||
| cut -d, -f1 \
|
| cut -d, -f1 \
|
||||||
| grep -ve 'vc4' -e 'Head' -e 'PCH' \
|
| grep -ve 'vc4' -e 'Head' -e 'PCH' \
|
||||||
@@ -158,8 +169,8 @@ get_CHANNELS() {
|
|||||||
| uniq)"
|
| uniq)"
|
||||||
script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a "${SOUND_PARAMS}" &> /dev/null
|
script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a "${SOUND_PARAMS}" &> /dev/null
|
||||||
CHANNELS=$(awk '/CHANN/ { print $2 }' "${SOUND_PARAMS}" | sed 's/\r$//')
|
CHANNELS=$(awk '/CHANN/ { print $2 }' "${SOUND_PARAMS}" | sed 's/\r$//')
|
||||||
[ ! -z REC_CARD ] || REC_CARD=default
|
[ -z REC_CARD ] || REC_CARD=default
|
||||||
[ ! -z CHANNELS ] || CHANNELS=2
|
[ -z CHANNELS ] || CHANNELS=2
|
||||||
echo "REC_CARD variable set to ${REC_CARD}"
|
echo "REC_CARD variable set to ${REC_CARD}"
|
||||||
echo "Number of channels available: ${CHANNELS}"
|
echo "Number of channels available: ${CHANNELS}"
|
||||||
}
|
}
|
||||||
@@ -171,6 +182,7 @@ configure() {
|
|||||||
get_LONGITUDE
|
get_LONGITUDE
|
||||||
get_DO_EXTRACTIONS
|
get_DO_EXTRACTIONS
|
||||||
get_DO_RECORDING
|
get_DO_RECORDING
|
||||||
|
get_TIMESTAMP_FORMAT
|
||||||
get_REMOTE
|
get_REMOTE
|
||||||
get_EXTRACTIONS_URL
|
get_EXTRACTIONS_URL
|
||||||
get_PUSHED
|
get_PUSHED
|
||||||
@@ -220,14 +232,32 @@ DO_EXTRACTIONS=${DO_EXTRACTIONS}
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------------- Recording Service ----------------------------#
|
#----------------------------- Recording Service ----------------------------#
|
||||||
|
#_______________The two variables below can be set to enable __________________#
|
||||||
|
#________________________the birdnet_recording.service ________________________#
|
||||||
|
|
||||||
# Keep this EMPTY if you do not want this device to perform the recording. #
|
# Keep this EMPTY if you do not want this device to perform the recording. #
|
||||||
|
|
||||||
## DO_RECORDING is simply a setting for enabling the 24/7 birdnet_recording.service.
|
## DO_RECORDING is simply a setting for enabling the 24/7
|
||||||
|
## birdnet_recording.service.
|
||||||
## Set this to Y or y to enable recording.
|
## Set this to Y or y to enable recording.
|
||||||
|
|
||||||
DO_RECORDING=${DO_RECORDING}
|
DO_RECORDING=${DO_RECORDING}
|
||||||
|
|
||||||
|
## TIMESTAMP_FORMAT is the format the recording service will use to name its
|
||||||
|
## files. Setting this variable to "12" will name the recorded (and extracted)
|
||||||
|
## files using the 12-hour AM/PM time format. Setting this variable to "24"
|
||||||
|
## will name the files using the 24-hour time format. See examples below:
|
||||||
|
#
|
||||||
|
## TIMESTAMP_FORMAT=12
|
||||||
|
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav
|
||||||
|
#
|
||||||
|
## TIMESTAMP_FORMAT=24
|
||||||
|
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav
|
||||||
|
|
||||||
|
|
||||||
|
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT}
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------- Mounting a remote directory with systemd -----------------#
|
#----------------- Mounting a remote directory with systemd -----------------#
|
||||||
#_______________The four variables below can be set to enable a_______________#
|
#_______________The four variables below can be set to enable a_______________#
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ install_selected_services() {
|
|||||||
install_livestream_service
|
install_livestream_service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "${INSTALL_NOMACHINE}" ];then
|
if [[ "${INSTALL_NOMACHINE}" =~ [Yy] ]];then
|
||||||
install_nomachine
|
install_nomachine
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Sends a notification if a new species is detected
|
# Sends a notification if a new species is detected
|
||||||
# set -x
|
#set -x
|
||||||
trap 'rm -f $TMPFILE' SIGINT SIGHUP EXIT
|
trap 'rm -f $TMPFILE' SIGINT SIGHUP EXIT
|
||||||
|
|
||||||
source /etc/birdnet/birdnet.conf
|
source /etc/birdnet/birdnet.conf
|
||||||
@@ -12,11 +12,14 @@ cat "${IDFILE}" > "${TMPFILE}"
|
|||||||
|
|
||||||
/usr/local/bin/update_species.sh &> /dev/null
|
/usr/local/bin/update_species.sh &> /dev/null
|
||||||
|
|
||||||
if ! diff "${IDFILE}" "${TMPFILE}"; then
|
if ! diff "${IDFILE}" "${TMPFILE}" &> /dev/null; then
|
||||||
SPECIES=("$(diff "${IDFILE}" "${TMPFILE}" \
|
SPECIES=("$(diff "${IDFILE}" "${TMPFILE}" \
|
||||||
| awk '/</ {print $2" "$3}')")
|
| grep "Common Name" \
|
||||||
|
| sort \
|
||||||
NOTIFICATION="New Species Detected: ${SPECIES[@]}"
|
| awk '{for(i=4;i<=NF;++i)printf $i""FS ; print ""}')")
|
||||||
|
|
||||||
|
NOTIFICATION="New Species Detection: "${SPECIES[@]}""
|
||||||
|
echo "${NOTIFICATION}" && exit
|
||||||
|
|
||||||
sudo systemctl restart birdnet_analysis && sleep 30
|
sudo systemctl restart birdnet_analysis && sleep 30
|
||||||
sudo systemctl start extraction
|
sudo systemctl start extraction
|
||||||
|
|||||||
Reference in New Issue
Block a user