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