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@371
|
8 # It builds the HTK binaries and AIM-C AIMCopy binary if they're not
|
tomwalters@371
|
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@371
|
13 # HTK_USERNAME and HTK_PASSWORD - username and password for the site at
|
tomwalters@371
|
14 # http://htk.eng.cam.ac.uk/
|
tomwalters@371
|
15
|
tomwalters@335
|
16
|
tomwalters@335
|
17 # Set these to be the location of your input database, and desired output
|
tomwalters@335
|
18 # locations.
|
tomwalters@348
|
19 SYLLABLES_DATABASE_TAR=/mnt/sounds/cnbh-syllables.tar
|
tomwalters@335
|
20 SOUNDS_ROOT=/mnt/experiments/sounds/
|
tomwalters@335
|
21 FEATURES_ROOT=/mnt/experiments/features/
|
tomwalters@335
|
22 HMMS_ROOT=/mnt/experiments/hmms/
|
tomwalters@335
|
23
|
tomwalters@335
|
24 # Number of cores on the experimental machine. Various scripts will try to use
|
tomwalters@335
|
25 # this if it's set.
|
tomwalters@354
|
26 NUMBER_OF_CORES=1
|
tomwalters@335
|
27
|
tomwalters@335
|
28 # Fail if any command fails
|
tomwalters@335
|
29 set -e
|
tomwalters@335
|
30
|
tomwalters@335
|
31 # Fail if any variable is unset
|
tomwalters@335
|
32 set -u
|
tomwalters@335
|
33
|
tomwalters@348
|
34 if [ ! -e $SYLLABLES_DATABASE_TAR ]; then
|
tomwalters@348
|
35 sudo mkdir -p `dirname $SYLLABLES_DATABASE_TAR`
|
tomwalters@348
|
36 sudo chown ubuntu `dirname $SYLLABLES_DATABASE_TAR`
|
tomwalters@348
|
37 wget -O $SYLLABLES_DATABASE_TAR $SYLLABLES_DATABASE_URL
|
tomwalters@348
|
38 fi
|
tomwalters@348
|
39
|
tomwalters@335
|
40 if [ ! -d $SOUNDS_ROOT ]; then
|
tomwalters@339
|
41 sudo mkdir -p $SOUNDS_ROOT
|
tomwalters@339
|
42 sudo chown `whoami` $SOUNDS_ROOT
|
tomwalters@335
|
43 fi
|
tomwalters@335
|
44
|
tomwalters@335
|
45 # Untar the CNBH syllables database, and convert the files from FLAC to WAV
|
tomwalters@335
|
46 if [ ! -e $SOUNDS_ROOT/.untar_db_success ]; then
|
tomwalters@335
|
47 tar -x -C $SOUNDS_ROOT -f $SYLLABLES_DATABASE_TAR
|
tomwalters@335
|
48 touch $SOUNDS_ROOT/.untar_db_success
|
tomwalters@335
|
49 fi
|
tomwalters@335
|
50
|
tomwalters@335
|
51 # Convert the database to .WAV format and place it in $SOUNDS_ROOT/clean
|
tomwalters@355
|
52 echo "Converting CNBH-syllables database from FLAC to WAV..."
|
tomwalters@341
|
53 ./cnbh-syllables/feature_generation/convert_flac_to_wav.sh $SOUNDS_ROOT
|
tomwalters@335
|
54
|
tomwalters@335
|
55 # Generate versions of the CNBH syllables spoke pattern with a range of
|
tomwalters@335
|
56 # signal-to-noise ratios (SNRs). The versions are put in the directory
|
tomwalters@335
|
57 # ${SOUNDS_ROOT}/${SNR}_dB/ for each SNR in $SNRS.
|
tomwalters@361
|
58 #SNRS="30 27 24 21 18 15 12 9 6 3 0"
|
tomwalters@361
|
59 SNRS="30" # For testing
|
tomwalters@356
|
60 ./cnbh-syllables/feature_generation/pink_noise.sh $SOUNDS_ROOT/clean/ "$SNRS"
|
tomwalters@335
|
61
|
tomwalters@335
|
62 # Make the list of all feature drectories
|
tomwalters@335
|
63 FEATURE_DIRS="clean"
|
tomwalters@335
|
64 for SNR in $SNRS; do
|
tomwalters@335
|
65 FEATURE_DIRS="$FEATURE_DIRS snr_${SNR}dB"
|
tomwalters@335
|
66 done
|
tomwalters@335
|
67
|
tomwalters@335
|
68 # Generate feature sets (for the full range of SNRs in $FEATURE_DIRS)
|
tomwalters@335
|
69 # 1. Standard MFCC features
|
tomwalters@335
|
70 # 2. AIM features
|
tomwalters@335
|
71 # 3. MFCC features with optimal VTLN
|
tomwalters@339
|
72
|
tomwalters@339
|
73
|
tomwalters@339
|
74 if [ ! -d $FEATURES_ROOT ]; then
|
tomwalters@339
|
75 sudo mkdir -p $FEATURES_ROOT
|
tomwalters@339
|
76 sudo chown `whoami` $FEATURES_ROOT
|
tomwalters@339
|
77 fi
|
tomwalters@339
|
78
|
tomwalters@350
|
79 if [ ! -e /mnt/experiments/htk/.htk_installed_success ]; then
|
tomwalters@350
|
80 ./HTK/install_htk.sh
|
tomwalters@351
|
81 fi
|
tomwalters@350
|
82
|
tomwalters@354
|
83 if [ ! -e /mnt/experiments/aimc/.aimc_build_success ]; then
|
tomwalters@353
|
84 # ./aimc/build_aimc.sh
|
tomwalters@353
|
85 cd ../../
|
tomwalters@353
|
86 scons
|
tomwalters@353
|
87 export PATH=$PATH:`pwd`/build/posix-release/
|
tomwalters@353
|
88 cd -
|
tomwalters@353
|
89 fi
|
tomwalters@353
|
90
|
tomwalters@335
|
91 for SOURCE_SNR in $FEATURE_DIRS; do
|
tomwalters@335
|
92
|
tomwalters@347
|
93 if [ ! -e $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success ]; then
|
tomwalters@335
|
94 mkdir -p $FEATURES_ROOT/mfcc/$SOURCE_SNR/
|
tomwalters@335
|
95 # Generate the list of files to convert
|
tomwalters@359
|
96 ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ htk
|
tomwalters@335
|
97 # Run the conversion
|
tomwalters@335
|
98 ./cnbh-syllables/feature_generation/run_hcopy.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $NUMBER_OF_CORES
|
tomwalters@335
|
99 touch $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success
|
tomwalters@346
|
100 fi
|
tomwalters@335
|
101
|
tomwalters@347
|
102 if [ ! -e $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success ]; then
|
tomwalters@335
|
103 mkdir -p $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/
|
tomwalters@335
|
104 # Generate the file list and run the conversion (all one step, since this
|
tomwalters@356
|
105 # version uses a different configuration for each talker)
|
tomwalters@335
|
106 ./cnbh-syllables/feature_generation/run_mfcc_vtln_conversion.sh $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/
|
tomwalters@335
|
107 touch $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success
|
tomwalters@346
|
108 fi
|
tomwalters@335
|
109
|
tomwalters@347
|
110 if [ ! -e $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success ]; then
|
tomwalters@335
|
111 mkdir -p $FEATURES_ROOT/aim/$SOURCE_SNR/
|
tomwalters@359
|
112 ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ ""
|
tomwalters@335
|
113 # Run the conversion
|
tomwalters@361
|
114 #./cnbh-syllables/feature_generation/run_aimcopy.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $NUMBER_OF_CORES
|
tomwalters@361
|
115 #touch $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success
|
tomwalters@346
|
116 fi
|
tomwalters@335
|
117 done
|
tomwalters@335
|
118
|
tomwalters@363
|
119 sudo mkdir -p $HMMS_ROOT
|
tomwalters@363
|
120 sudo chown ubuntu $HMMS_ROOT
|
tomwalters@363
|
121
|
tomwalters@335
|
122 # Now run a bunch of experiments.
|
tomwalters@335
|
123 # For each of the feature types, we want to run HMMs with a bunch of
|
tomwalters@335
|
124 # parameters.
|
tomwalters@335
|
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@335
|
126 TESTING_ITERATIONS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"
|
tomwalters@335
|
127 HMM_STATES="3 4 5 6 7 8"
|
tomwalters@357
|
128 HMM_OUTPUT_COMPONENTS="1 2 3 4 5 6"
|
tomwalters@335
|
129
|
tomwalters@356
|
130 FEATURE_CLASS=mfcc
|
tomwalters@360
|
131 FEATURE_SUFFIX=htk
|
tomwalters@356
|
132 FEATURE_SIZE=39
|
tomwalters@356
|
133 FEATURE_TYPE=MFCC_0_D_A
|
tomwalters@335
|
134
|
tomwalters@371
|
135 #for SOURCE_SNR in $FEATURE_DIRS; do
|
tomwalters@367
|
136 SOURCE_SNR="clean"
|
tomwalters@359
|
137 TALKERS=inner_talkers
|
tomwalters@359
|
138 WORK=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$SOURCE_SNR/$TALKERS/
|
tomwalters@363
|
139 mkdir -p $WORK
|
tomwalters@359
|
140 FEATURES_DIR=$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/
|
tomwalters@359
|
141
|
tomwalters@361
|
142 ./cnbh-syllables/run_training_and_testing/train_test_sets/generate_train_test_lists.sh \
|
tomwalters@357
|
143 $TALKERS \
|
tomwalters@357
|
144 $WORK \
|
tomwalters@357
|
145 $FEATURES_DIR \
|
tomwalters@357
|
146 $FEATURE_SUFFIX
|
tomwalters@357
|
147
|
tomwalters@362
|
148 TRAINING_SCRIPT=$WORK/training_script
|
tomwalters@362
|
149 TESTING_SCRIPT=$WORK/testing_script
|
tomwalters@362
|
150
|
tomwalters@369
|
151 ./cnbh-syllables/run_training_and_testing/gen_htk_base_files.sh $WORK
|
tomwalters@369
|
152
|
tomwalters@371
|
153 ./cnbh-syllables/run_training_and_testing/test_features.sh \
|
tomwalters@371
|
154 "$WORK" \
|
tomwalters@371
|
155 "$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/" \
|
tomwalters@371
|
156 "$FEATURE_SUFFIX" \
|
tomwalters@371
|
157 "$HMM_STATES" \
|
tomwalters@371
|
158 "$HMM_OUTPUT_COMPONENTS" \
|
tomwalters@371
|
159 "$TRAINING_ITERATIONS" \
|
tomwalters@371
|
160 "$TESTING_ITERATIONS" \
|
tomwalters@371
|
161 "$FEATURE_SIZE" \
|
tomwalters@371
|
162 "$FEATURE_TYPE" \
|
tomwalters@371
|
163 "$TRAINING_SCRIPT" \
|
tomwalters@371
|
164 "$TESTING_SCRIPT"
|
tomwalters@371
|
165 #done
|