tomwalters@54
|
1 #!/bin/bash
|
tomwalters@54
|
2 # Copyright 2010 Thomas Walters <tom@acousticscale.org>
|
tomwalters@54
|
3 #
|
tomwalters@54
|
4 # Run a series of experiments which compare MFCC features generated by HTK to
|
tomwalters@54
|
5 # AIM features generated using AIM-C using a series of syllable recogntiton
|
tomwalters@54
|
6 # tasks.
|
tomwalters@201
|
7 # This script expects to be run from within the AIM-C source tree.
|
tomwalters@201
|
8 # It builds the HTK binaries and AIM-C AIMCopy binary if they're not
|
tomwalters@201
|
9 # present.
|
tomwalters@201
|
10 # The following environment varaibles should be set before this script is run:
|
tomwalters@201
|
11 # SYLLABLES_DATABASE_URL - URL of a tar file containing the CNBH syllables
|
tomwalters@201
|
12 # database in FLAC format
|
tomwalters@201
|
13 # HTK_USERNAME and HTK_PASSWORD - username and password for the site at
|
tomwalters@201
|
14 # http://htk.eng.cam.ac.uk/
|
tomwalters@209
|
15 # NUMBER_OF_CORES - total number of machine cores
|
tomwalters@201
|
16
|
tomwalters@54
|
17 # Set these to be the location of your input database, and desired output
|
tomwalters@165
|
18 # locations.
|
tomwalters@178
|
19 SYLLABLES_DATABASE_TAR=/mnt/sounds/cnbh-syllables.tar
|
tomwalters@165
|
20 SOUNDS_ROOT=/mnt/experiments/sounds/
|
tomwalters@165
|
21 FEATURES_ROOT=/mnt/experiments/features/
|
tomwalters@165
|
22 HMMS_ROOT=/mnt/experiments/hmms/
|
tomwalters@128
|
23
|
tomwalters@54
|
24 # Number of cores on the experimental machine. Various scripts will try to use
|
tomwalters@54
|
25 # this if it's set.
|
tomwalters@209
|
26 # NUMBER_OF_CORES=8
|
tomwalters@54
|
27
|
tomwalters@54
|
28 # Fail if any command fails
|
tomwalters@54
|
29 set -e
|
tomwalters@54
|
30
|
tomwalters@54
|
31 # Fail if any variable is unset
|
tomwalters@54
|
32 set -u
|
tomwalters@54
|
33
|
tomwalters@178
|
34 if [ ! -e $SYLLABLES_DATABASE_TAR ]; then
|
tomwalters@178
|
35 sudo mkdir -p `dirname $SYLLABLES_DATABASE_TAR`
|
tomwalters@178
|
36 sudo chown ubuntu `dirname $SYLLABLES_DATABASE_TAR`
|
tomwalters@178
|
37 wget -O $SYLLABLES_DATABASE_TAR $SYLLABLES_DATABASE_URL
|
tomwalters@178
|
38 fi
|
tomwalters@178
|
39
|
tomwalters@54
|
40 if [ ! -d $SOUNDS_ROOT ]; then
|
tomwalters@169
|
41 sudo mkdir -p $SOUNDS_ROOT
|
tomwalters@169
|
42 sudo chown `whoami` $SOUNDS_ROOT
|
tomwalters@54
|
43 fi
|
tomwalters@54
|
44
|
tomwalters@165
|
45 # Untar the CNBH syllables database, and convert the files from FLAC to WAV
|
tomwalters@54
|
46 if [ ! -e $SOUNDS_ROOT/.untar_db_success ]; then
|
tomwalters@54
|
47 tar -x -C $SOUNDS_ROOT -f $SYLLABLES_DATABASE_TAR
|
tomwalters@54
|
48 touch $SOUNDS_ROOT/.untar_db_success
|
tomwalters@54
|
49 fi
|
tomwalters@54
|
50
|
tomwalters@54
|
51 # Convert the database to .WAV format and place it in $SOUNDS_ROOT/clean
|
tomwalters@185
|
52 echo "Converting CNBH-syllables database from FLAC to WAV..."
|
tomwalters@171
|
53 ./cnbh-syllables/feature_generation/convert_flac_to_wav.sh $SOUNDS_ROOT
|
tomwalters@54
|
54
|
tomwalters@54
|
55 # Generate versions of the CNBH syllables spoke pattern with a range of
|
tomwalters@54
|
56 # signal-to-noise ratios (SNRs). The versions are put in the directory
|
tomwalters@54
|
57 # ${SOUNDS_ROOT}/${SNR}_dB/ for each SNR in $SNRS.
|
tomwalters@207
|
58 SNRS="30 27 24 21 18 15 12 9 6 3 0"
|
tomwalters@207
|
59 #SNRS="30" # For testing
|
tomwalters@186
|
60 ./cnbh-syllables/feature_generation/pink_noise.sh $SOUNDS_ROOT/clean/ "$SNRS"
|
tomwalters@54
|
61
|
tomwalters@54
|
62 # Make the list of all feature drectories
|
tomwalters@165
|
63 FEATURE_DIRS="clean"
|
tomwalters@54
|
64 for SNR in $SNRS; do
|
tomwalters@54
|
65 FEATURE_DIRS="$FEATURE_DIRS snr_${SNR}dB"
|
tomwalters@54
|
66 done
|
tomwalters@54
|
67
|
tomwalters@54
|
68 # Generate feature sets (for the full range of SNRs in $FEATURE_DIRS)
|
tomwalters@54
|
69 # 1. Standard MFCC features
|
tomwalters@54
|
70 # 2. AIM features
|
tomwalters@165
|
71 # 3. MFCC features with optimal VTLN
|
tomwalters@169
|
72
|
tomwalters@169
|
73
|
tomwalters@169
|
74 if [ ! -d $FEATURES_ROOT ]; then
|
tomwalters@169
|
75 sudo mkdir -p $FEATURES_ROOT
|
tomwalters@169
|
76 sudo chown `whoami` $FEATURES_ROOT
|
tomwalters@169
|
77 fi
|
tomwalters@169
|
78
|
tomwalters@180
|
79 if [ ! -e /mnt/experiments/htk/.htk_installed_success ]; then
|
tomwalters@180
|
80 ./HTK/install_htk.sh
|
tomwalters@181
|
81 fi
|
tomwalters@180
|
82
|
tomwalters@184
|
83 if [ ! -e /mnt/experiments/aimc/.aimc_build_success ]; then
|
tomwalters@183
|
84 # ./aimc/build_aimc.sh
|
tomwalters@183
|
85 cd ../../
|
tomwalters@183
|
86 scons
|
tomwalters@183
|
87 export PATH=$PATH:`pwd`/build/posix-release/
|
tomwalters@183
|
88 cd -
|
tomwalters@183
|
89 fi
|
tomwalters@183
|
90
|
tomwalters@54
|
91 for SOURCE_SNR in $FEATURE_DIRS; do
|
tomwalters@165
|
92
|
tomwalters@177
|
93 if [ ! -e $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success ]; then
|
tomwalters@54
|
94 mkdir -p $FEATURES_ROOT/mfcc/$SOURCE_SNR/
|
tomwalters@54
|
95 # Generate the list of files to convert
|
tomwalters@189
|
96 ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ htk
|
tomwalters@54
|
97 # Run the conversion
|
tomwalters@209
|
98 #./cnbh-syllables/feature_generation/run_hcopy.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $NUMBER_OF_CORES
|
tomwalters@209
|
99 #touch $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success
|
tomwalters@176
|
100 fi
|
tomwalters@54
|
101
|
tomwalters@177
|
102 if [ ! -e $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success ]; then
|
tomwalters@54
|
103 mkdir -p $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/
|
tomwalters@54
|
104 # Generate the file list and run the conversion (all one step, since this
|
tomwalters@186
|
105 # version uses a different configuration for each talker)
|
tomwalters@209
|
106 #./cnbh-syllables/feature_generation/run_mfcc_vtln_conversion.sh $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/
|
tomwalters@209
|
107 #touch $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success
|
tomwalters@176
|
108 fi
|
tomwalters@54
|
109
|
tomwalters@177
|
110 if [ ! -e $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success ]; then
|
tomwalters@165
|
111 mkdir -p $FEATURES_ROOT/aim/$SOURCE_SNR/
|
tomwalters@189
|
112 ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ ""
|
tomwalters@54
|
113 # Run the conversion
|
tomwalters@209
|
114 ./cnbh-syllables/feature_generation/run_aimcopy.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $NUMBER_OF_CORES
|
tomwalters@209
|
115 touch $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success
|
tomwalters@176
|
116 fi
|
tomwalters@165
|
117 done
|
tomwalters@82
|
118
|
tomwalters@193
|
119 sudo mkdir -p $HMMS_ROOT
|
tomwalters@193
|
120 sudo chown ubuntu $HMMS_ROOT
|
tomwalters@193
|
121
|
tomwalters@54
|
122 # Now run a bunch of experiments.
|
tomwalters@54
|
123 # For each of the feature types, we want to run HMMs with a bunch of
|
tomwalters@54
|
124 # parameters.
|
tomwalters@165
|
125 TRAINING_ITERATIONS="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"
|
tomwalters@165
|
126 TESTING_ITERATIONS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"
|
tomwalters@165
|
127 HMM_STATES="3 4 5 6 7 8"
|
tomwalters@202
|
128 HMM_OUTPUT_COMPONENTS="1 2 3 4 5 6 7"
|
tomwalters@91
|
129
|
tomwalters@209
|
130 return 0
|
tomwalters@202
|
131
|
tomwalters@204
|
132 run_train_test () {
|
tomwalters@207
|
133 # TODO(tom): Make sure that the training SNR is generated first
|
tomwalters@204
|
134 for SOURCE_SNR in $FEATURE_DIRS; do
|
tomwalters@204
|
135 WORK=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$SOURCE_SNR/$TALKERS/
|
tomwalters@204
|
136 mkdir -p $WORK
|
tomwalters@204
|
137 FEATURES_DIR=$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/
|
tomwalters@204
|
138
|
tomwalters@204
|
139 ./cnbh-syllables/run_training_and_testing/train_test_sets/generate_train_test_lists.sh \
|
tomwalters@204
|
140 $TALKERS \
|
tomwalters@204
|
141 $WORK \
|
tomwalters@204
|
142 $FEATURES_DIR \
|
tomwalters@204
|
143 $FEATURE_SUFFIX
|
tomwalters@204
|
144
|
tomwalters@207
|
145 TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$TRAINING_SNR/$TALKERS/training_script
|
tomwalters@207
|
146 TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$TRAINING_SNR/$TALKERS/training_master_label_file
|
tomwalters@207
|
147
|
tomwalters@204
|
148 TESTING_SCRIPT=$WORK/testing_script
|
tomwalters@207
|
149 TESTING_MASTER_LABEL_FILE=$WORK/testing_master_label_file
|
tomwalters@204
|
150
|
tomwalters@204
|
151 ./cnbh-syllables/run_training_and_testing/gen_htk_base_files.sh $WORK
|
tomwalters@204
|
152
|
tomwalters@204
|
153 ./cnbh-syllables/run_training_and_testing/test_features.sh \
|
tomwalters@204
|
154 "$WORK" \
|
tomwalters@204
|
155 "$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/" \
|
tomwalters@204
|
156 "$FEATURE_SUFFIX" \
|
tomwalters@204
|
157 "$HMM_STATES" \
|
tomwalters@204
|
158 "$HMM_OUTPUT_COMPONENTS" \
|
tomwalters@204
|
159 "$TRAINING_ITERATIONS" \
|
tomwalters@204
|
160 "$TESTING_ITERATIONS" \
|
tomwalters@204
|
161 "$FEATURE_SIZE" \
|
tomwalters@204
|
162 "$FEATURE_TYPE" \
|
tomwalters@204
|
163 "$TRAINING_SCRIPT" \
|
tomwalters@204
|
164 "$TESTING_SCRIPT" \
|
tomwalters@206
|
165 "$TRAINING_MASTER_LABEL_FILE" \
|
tomwalters@206
|
166 "$TESTING_MASTER_LABEL_FILE"
|
tomwalters@204
|
167 done
|
tomwalters@204
|
168 }
|
tomwalters@204
|
169
|
tomwalters@204
|
170
|
tomwalters@202
|
171 ########################
|
tomwalters@202
|
172 # Standard MFCCs
|
tomwalters@186
|
173 FEATURE_CLASS=mfcc
|
tomwalters@190
|
174 FEATURE_SUFFIX=htk
|
tomwalters@186
|
175 FEATURE_SIZE=39
|
tomwalters@186
|
176 FEATURE_TYPE=MFCC_0_D_A
|
tomwalters@202
|
177 TALKERS=inner_talkers
|
tomwalters@207
|
178 TRAINING_SNR=clean
|
tomwalters@202
|
179 run_train_test
|
tomwalters@202
|
180 ########################
|
tomwalters@93
|
181
|
tomwalters@202
|
182 ########################
|
tomwalters@202
|
183 # Standard MFCCs
|
tomwalters@202
|
184 # Train on extrema
|
tomwalters@202
|
185 FEATURE_CLASS=mfcc
|
tomwalters@202
|
186 FEATURE_SUFFIX=htk
|
tomwalters@202
|
187 FEATURE_SIZE=39
|
tomwalters@202
|
188 FEATURE_TYPE=MFCC_0_D_A
|
tomwalters@202
|
189 TALKERS=outer_talkers
|
tomwalters@207
|
190 TRAINING_SNR=clean
|
tomwalters@202
|
191 run_train_test
|
tomwalters@202
|
192 ########################
|
tomwalters@202
|
193
|
tomwalters@202
|
194 ########################
|
tomwalters@202
|
195 # MFCCs with VTLN
|
tomwalters@202
|
196 FEATURE_CLASS=mfcc_vtln
|
tomwalters@202
|
197 FEATURE_SUFFIX=htk
|
tomwalters@202
|
198 FEATURE_SIZE=39
|
tomwalters@202
|
199 FEATURE_TYPE=MFCC_0_D_A
|
tomwalters@189
|
200 TALKERS=inner_talkers
|
tomwalters@207
|
201 TRAINING_SNR=clean
|
tomwalters@202
|
202 run_train_test
|
tomwalters@202
|
203 ########################
|
tomwalters@202
|
204
|
tomwalters@202
|
205 ########################
|
tomwalters@202
|
206 # MFCCs with VTLN
|
tomwalters@202
|
207 # Train on extrema
|
tomwalters@202
|
208 FEATURE_CLASS=mfcc_vtln
|
tomwalters@202
|
209 FEATURE_SUFFIX=htk
|
tomwalters@202
|
210 FEATURE_SIZE=39
|
tomwalters@202
|
211 FEATURE_TYPE=MFCC_0_D_A
|
tomwalters@202
|
212 TALKERS=outer_talkers
|
tomwalters@207
|
213 TRAINING_SNR=clean
|
tomwalters@202
|
214 run_train_test
|
tomwalters@202
|
215 ########################
|
tomwalters@202
|
216
|
tomwalters@202
|
217 ########################
|
tomwalters@202
|
218 # AIM Features
|
tomwalters@202
|
219 # TODO (loop over all feature suffixes)
|
tomwalters@202
|
220 ########################
|
tomwalters@202
|
221
|
tomwalters@202
|
222
|
tomwalters@189
|
223
|
tomwalters@187
|
224
|
tomwalters@192
|
225
|