forked from HenryWConklin/barkdetect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.sh
executable file
·42 lines (33 loc) · 1.36 KB
/
process.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Filters sounds and schedules posts
# Project home directory
homedir=/home/pi/barkdetect/
# Classify sounds, writes class to ${homedir}classification.txt
python $homedir/pyAudioAnalysis/audioAnalysis.py classifyFolder -i ${homedir}samples --model knn --classifier ${homedir}knnBarkDetect --details > ${homedir}classification.txt
#Check to see if classification ran correctly
if [[ $? == 0 ]]; then
# Iterate over unfiltered samples
for filename in ${homedir}samples/snd*.wav
do
# Find the classification of the current file
res=`grep $filename < ${homedir}classification.txt`
# Filter into appropriate file
if [[ $res == *"barks"* ]]; then
mv $filename ${homedir}samples/barks
elif [[ $res == *"junk"* ]]; then
mv $filename ${homedir}samples/junk
fi
done
# Check that unprocessed barks directory is not empty to avoid pointless error message
if [[ `ls -p ${homedir}samples/barks | grep -v /` ]]; then
# Schedule a twitter post for each filtered bark,
# delayed 10 minutes from original recording
for file in ${homedir}samples/barks/snd*.wav; do
at -f ${homedir}atjob.txt `${homedir}getTimeFromFilename.py $file`
mv $file ${homedir}samples/barks/processed
done
fi
# if classification did not complete correctly, clear the unprocessed samples, probably a corrupted file.
else
rm ${homedir}samples/snd*.wav
fi