annotate trunk/experiments/scripts/master.sh @ 372:26833fbaa597

- AWS
author tomwalters
date Thu, 12 Aug 2010 15:26:35 +0000
parents c3725d638bbb
children ba7037c15192
rev   line source
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@372 128 HMM_OUTPUT_COMPONENTS="1 2 3 4 5 6 7"
tomwalters@335 129
tomwalters@372 130
tomwalters@372 131 ########################
tomwalters@372 132 # Standard MFCCs
tomwalters@356 133 FEATURE_CLASS=mfcc
tomwalters@360 134 FEATURE_SUFFIX=htk
tomwalters@356 135 FEATURE_SIZE=39
tomwalters@356 136 FEATURE_TYPE=MFCC_0_D_A
tomwalters@372 137 TALKERS=inner_talkers
tomwalters@372 138 TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_script
tomwalters@372 139 TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_master_label_file
tomwalters@372 140 run_train_test
tomwalters@372 141 ########################
tomwalters@335 142
tomwalters@372 143 ########################
tomwalters@372 144 # Standard MFCCs
tomwalters@372 145 # Train on extrema
tomwalters@372 146 FEATURE_CLASS=mfcc
tomwalters@372 147 FEATURE_SUFFIX=htk
tomwalters@372 148 FEATURE_SIZE=39
tomwalters@372 149 FEATURE_TYPE=MFCC_0_D_A
tomwalters@372 150 TALKERS=outer_talkers
tomwalters@372 151 TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_script
tomwalters@372 152 TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_master_label_file
tomwalters@372 153 run_train_test
tomwalters@372 154 ########################
tomwalters@372 155
tomwalters@372 156 ########################
tomwalters@372 157 # MFCCs with VTLN
tomwalters@372 158 FEATURE_CLASS=mfcc_vtln
tomwalters@372 159 FEATURE_SUFFIX=htk
tomwalters@372 160 FEATURE_SIZE=39
tomwalters@372 161 FEATURE_TYPE=MFCC_0_D_A
tomwalters@359 162 TALKERS=inner_talkers
tomwalters@372 163 TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_script
tomwalters@372 164 TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_master_label_file
tomwalters@372 165 run_train_test
tomwalters@372 166 ########################
tomwalters@372 167
tomwalters@372 168 ########################
tomwalters@372 169 # MFCCs with VTLN
tomwalters@372 170 # Train on extrema
tomwalters@372 171 FEATURE_CLASS=mfcc_vtln
tomwalters@372 172 FEATURE_SUFFIX=htk
tomwalters@372 173 FEATURE_SIZE=39
tomwalters@372 174 FEATURE_TYPE=MFCC_0_D_A
tomwalters@372 175 TALKERS=outer_talkers
tomwalters@372 176 TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_script
tomwalters@372 177 TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_master_label_file
tomwalters@372 178 run_train_test
tomwalters@372 179 ########################
tomwalters@372 180
tomwalters@372 181 ########################
tomwalters@372 182 # AIM Features
tomwalters@372 183 # TODO (loop over all feature suffixes)
tomwalters@372 184 ########################
tomwalters@372 185
tomwalters@372 186
tomwalters@372 187 run_train_test () {
tomwalters@372 188 for SOURCE_SNR in $FEATURE_DIRS; do
tomwalters@372 189 #SOURCE_SNR="clean"
tomwalters@359 190 WORK=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$SOURCE_SNR/$TALKERS/
tomwalters@363 191 mkdir -p $WORK
tomwalters@359 192 FEATURES_DIR=$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/
tomwalters@359 193
tomwalters@361 194 ./cnbh-syllables/run_training_and_testing/train_test_sets/generate_train_test_lists.sh \
tomwalters@357 195 $TALKERS \
tomwalters@357 196 $WORK \
tomwalters@357 197 $FEATURES_DIR \
tomwalters@357 198 $FEATURE_SUFFIX
tomwalters@357 199
tomwalters@362 200 TESTING_SCRIPT=$WORK/testing_script
tomwalters@362 201
tomwalters@369 202 ./cnbh-syllables/run_training_and_testing/gen_htk_base_files.sh $WORK
tomwalters@369 203
tomwalters@371 204 ./cnbh-syllables/run_training_and_testing/test_features.sh \
tomwalters@371 205 "$WORK" \
tomwalters@371 206 "$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/" \
tomwalters@371 207 "$FEATURE_SUFFIX" \
tomwalters@371 208 "$HMM_STATES" \
tomwalters@371 209 "$HMM_OUTPUT_COMPONENTS" \
tomwalters@371 210 "$TRAINING_ITERATIONS" \
tomwalters@371 211 "$TESTING_ITERATIONS" \
tomwalters@371 212 "$FEATURE_SIZE" \
tomwalters@371 213 "$FEATURE_TYPE" \
tomwalters@371 214 "$TRAINING_SCRIPT" \
tomwalters@372 215 "$TESTING_SCRIPT" \
tomwalters@372 216 "$TRAINING_MASTER_LABEL_FILE"
tomwalters@372 217 done
tomwalters@372 218 }
tomwalters@372 219
tomwalters@372 220