2022-08-12 18:01:01 +02:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
2022-08-13 07:48:06 +02:00
|
|
|
record_chunk() {
|
2022-08-12 18:01:01 +02:00
|
|
|
DEVICE=$1
|
|
|
|
DURATION=$2
|
|
|
|
ffmpeg -f pulse -i ${DEVICE} -t ${DURATION} -vn -acodec pcm_s16le -ac 1 -ar 48000 file:${CHUNK_FOLDER}/in/birdnet_$(date "+%Y%m%d_%H%M%S").wav
|
|
|
|
}
|
|
|
|
|
|
|
|
config_filepath="./config/analyzer.conf"
|
|
|
|
|
|
|
|
if [ -f "$config_filepath" ]; then
|
|
|
|
source "$config_filepath"
|
|
|
|
else
|
|
|
|
echo "Config file not found: $config_filepath"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -z $RECORDING_DURATION ] && RECORDING_DURATION=15
|
|
|
|
|
|
|
|
if [[ -z $AUDIO_DEVICE ]]; then
|
|
|
|
echo "AUDIO_DEVICE is not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-08-13 07:48:06 +02:00
|
|
|
check_folder() {
|
|
|
|
if [[ ! -d "${CHUNK_FOLDER}" ]]; then
|
|
|
|
echo "CHUNK_FOLDER does not exist: ${CHUNK_FOLDER}"
|
|
|
|
echo "Creating recording dir"
|
|
|
|
mkdir -p "${CHUNK_FOLDER}/in"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_folder
|
|
|
|
|
2022-08-12 18:01:01 +02:00
|
|
|
while true; do
|
|
|
|
record_chunk $AUDIO_DEVICE $RECORDING_DURATION
|
2022-08-13 07:48:06 +02:00
|
|
|
done
|