annotate experiments/scripts/master.sh @ 144:f8ace1ee8782

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