comparison testdata/evaluation/run.sh @ 198:28cbc7eaf415 noteagent

Merge from the default branch
author Chris Cannam
date Wed, 04 Jun 2014 11:46:01 +0100
parents ad706e771398
children 607c3c92822f
comparison
equal deleted inserted replaced
190:c02db1f4680a 198:28cbc7eaf415
1 #!/bin/sh
2
3 trios_path="/home/cannam/Music/TRIOS_dataset"
4 yc="/home/cannam/code/may/bin/yc"
5
6 if [ ! -d "$trios_path" ]; then
7 echo "TRIOS dataset directory $trios_path not found, giving up"
8 exit 1
9 fi
10
11 if ! "$yc" -v ; then
12 echo "Failed to run Yeti compiler yc at $yc_path, giving up";
13 fi
14
15 if ! sonic-annotator -v ; then
16 echo "Failed to run sonic-annotator (not in PATH?), giving up"
17 exit 1
18 fi
19
20 rdffile="../../silvet.n3"
21 if [ ! -f "$rdffile" ] ; then
22 echo "Failed to find plugin RDF file at $rdffile, giving up"
23 exit 1
24 fi
25
26 case "$trios_path" in
27 *\ *) echo "TRIOS dataset path $trios_path has a space in it, this script won't handle that"; exit 1;;
28 esac
29
30 VAMP_PATH=../..
31 export VAMP_PATH
32
33 outfile="/tmp/$$"
34
35 tmpwav="/tmp/$$norm.wav"
36
37 instfile="/tmp/$$instruments.txt"
38
39 transfile="/tmp/$$transform.ttl"
40
41 trap 'rm -f "$outfile" "$tmpwav" "$instfile" "$transfile" "$outfile.lab"' 0
42
43 # Use the mix and single-instrument non-synthetic files for a (varied)
44 # subset of the TRIOS dataset. Omit percussion (but we still use the
45 # Take Five example, even though it's largely percussion, because it's
46 # a good test of how we do with other instruments in the presence of
47 # percussion).
48 infiles=`find "$trios_path" -name \*.wav -print | egrep '(mozart|lussier|take_five)' | grep -v _syn.wav | grep -v kick.wav | grep -v ride.wav | grep -v snare.wav`
49
50 grep Piano "$rdffile" | sed 's/^.*( *//' | sed 's/ *).*$//' | sed 's/ "/\n/g' | sed 's/"//g' | tr '[A-Z]' '[a-z]' | tail -n +2 | cat -n > "$instfile"
51
52 instrument_for() {
53 filename="$1"
54 base=`basename "$filename" .wav`
55 instrument_no=`grep "$base" "$instfile" | awk '{ print $1; }'`
56 if [ -z "$instrument_no" ] || [ -z "$base" ];
57 then echo 0
58 else echo "$instrument_no"
59 fi
60 }
61
62 echo
63 echo "Input files are:"
64 echo $infiles | fmt -1
65
66 time for infile in $infiles; do
67
68 echo
69 echo "Evaluating for file $infile..."
70
71 instrument=`instrument_for "$infile"`
72 case "$instrument" in
73 [0-9]*) ;;
74 *) echo "Instrument extraction failed for infile $infile -- not even default multi-instrument setting returned?"; exit 1;;
75 esac
76
77 piece=`basename \`dirname "$infile" \``
78 arrangement=`basename "$infile" .wav`
79
80 echo
81 echo "For piece $piece, arrangement $arrangement, using instrument $instrument..."
82
83 sox "$infile" "$tmpwav" gain -n -6.020599913279624
84
85 # generate the transform by interpolating the instrument parameter
86 cat transform.ttl | sed "s/INSTRUMENT_PARAMETER/$instrument/" > "$transfile"
87
88 sonic-annotator \
89 --writer csv \
90 --csv-one-file "$outfile" \
91 --csv-force \
92 --transform "$transfile" \
93 "$tmpwav"
94
95 cat "$outfile" | \
96 sed 's/^[^,]*,//' | \
97 while IFS=, read start duration frequency level label; do
98 end=`echo "$start $duration + p" | dc`
99 echo -e "$start\t$end\t$frequency"
100 done > "$outfile.lab"
101
102 for ms in 50 100; do
103 mark=""
104 if [ "$ms" = "50" ]; then mark=" <-- main measure"; fi;
105 echo
106 echo "Validating against ground truth at $ms ms:"
107 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "$outfile.lab" | sed 's/$/'"$mark"'/'
108 echo
109 echo "Validating against MIREX submission at $ms ms:"
110 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab" "$outfile.lab"
111 echo
112 echo "Validating MIREX against ground truth at $ms ms":
113 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab"
114 done;
115
116 echo
117 done