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