annotate experiments/scripts/master.sh @ 95:b7c1c5e4061a

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