annotate testdata/evaluation/run.sh @ 197:ad706e771398

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