Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Last active May 17, 2023 06:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-mapper/5c291056dce51877a9c01a92756139d8 to your computer and use it in GitHub Desktop.
Save max-mapper/5c291056dce51877a9c01a92756139d8 to your computer and use it in GitHub Desktop.
birdnet laptop mode
#!/bin/bash
TIMEFORMAT='Elapsed Time: %0R seconds.'
time {
export YEAR=`date '+%Y'`
export MONTH=`date '+%m'`
export DAY=`date '+%d'`
export WEEK=`date '+%U'`
# kill `cat /home/max/tweet/recording.pid`
for f in `ls /home/max/tweet/samples/${YEAR}/${MONTH}/${DAY}/*.wav`
do
if [ ! -f "${f%.wav}.csv" ]; then
python3 /home/max/src/BirdNET-Analyzer/analyze.py --i ${f} --o ${f%.wav}.csv --rtype csv --min_conf 0.6 --threads 3 --lat 34.203804 --lon -118.129816 --week ${WEEK} >> /home/max/tweet/${YEAR}-${MONTH}-${DAY}.out 2>> /home/max/tweet/${YEAR}-${MONTH}-${DAY}.err
t=$(basename ${f})
# add the file name (a timestamp) to the end of each file row
sed -i 's/$/,'"${t%.wav}"'/' ${f%.wav}.csv
sed -i 's/Confidence.*/Confidence,time/' ${f%.wav}.csv
fi
done
# cat /home/max/tweet/header.csv > ${YEAR}-${MONTH}-${DAY}.csv
# # strip the headers
# cat /home/max/tweet/samples/${YEAR}/${MONTH}/${DAY}/*.csv | grep -v Confidence >> /home/max/tweet/t1.csv
# # sort by common name and confidence
# sort -t "," -k3,3 -k5,5nr /home/max/tweet/t1.csv > /home/max/tweet/t2.csv
# # remove the first few columns
# cut -d ',' -f 4,5- t2.csv >> /home/max/tweet/${YEAR}-${MONTH}-${DAY}.csv
# # clean up
# rm /home/max/tweet/t*.csv
}
./stats.sh
name: birdnet
channels:
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=4.5=1_gnu
- ca-certificates=2022.3.29=h06a4308_1
- certifi=2021.10.8=py39h06a4308_2
- ld_impl_linux-64=2.35.1=h7274673_9
- libffi=3.3=he6710b0_2
- libgcc-ng=9.3.0=h5101ec6_17
- libgomp=9.3.0=h5101ec6_17
- libstdcxx-ng=9.3.0=hd4cf53a_17
- ncurses=6.3=h7f8727e_2
- openssl=1.1.1n=h7f8727e_0
- pip=21.2.4=py39h06a4308_0
- python=3.9.12=h12debd9_0
- readline=8.1.2=h7f8727e_1
- setuptools=61.2.0=py39h06a4308_0
- sqlite=3.38.2=hc218d9a_0
- tk=8.6.11=h1ccaba5_0
- tzdata=2022a=hda174b7_0
- wheel=0.37.1=pyhd3eb1b0_0
- xz=5.2.5=h7b6447c_0
- zlib=1.2.12=h7f8727e_2
- pip:
- appdirs==1.4.4
- audioread==2.1.9
- bottle==0.12.19
- cffi==1.15.0
- charset-normalizer==2.0.12
- decorator==5.1.1
- idna==3.3
- joblib==1.1.0
- librosa==0.9.1
- llvmlite==0.38.0
- numba==0.55.1
- numpy==1.21.6
- packaging==21.3
- pooch==1.6.0
- pycparser==2.21
- pyparsing==3.0.8
- requests==2.27.1
- resampy==0.2.2
- scikit-learn==1.0.2
- scipy==1.8.0
- six==1.16.0
- soundfile==0.10.3.post1
- tflite-runtime==2.8.0
- threadpoolctl==3.1.0
- urllib3==1.26.9
#!/bin/bash
export YEAR=`date '+%Y'`
export MONTH=`date '+%m'`
export DAY=`date '+%d'`
mkdir -p /home/max/tweet/samples/${YEAR}/${MONTH}/${DAY}/
arecord -D sysdefault:CARD=1 --quiet --max-file-time 60 -f S16_LE -r 48000 -t wav --use-strftime /home/max/tweet/samples/%Y/%m/%d/%H-%M-%S.wav
#!/bin/bash
find . -name "*.csv" -mtime -1 | sort | xargs -n 1 csv-parser | jsonfilter --match="this.Confidence > 0.8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment