annotate trunk/experiments/scripts/master.sh @ 706:f8e90b5d85fd tip

Delete CARFAC code from this repository. It has been moved to https://github.com/google/carfac Please email me with your github username to get access. I've also created a new mailing list to discuss CARFAC development: https://groups.google.com/forum/#!forum/carfac-dev
author ronw@google.com
date Thu, 18 Jul 2013 20:56:51 +0000
parents 2d0b057e525c
children
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@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@417 28 WORKING_VOLUME=/mnt/scratch0/aim
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@416 37 THIS_DIR=`dirname $0`
tomwalters@415 38 AIMCOPY_CONFIGURATION_FILE=$THIS_DIR/cnbh-syllables/feature_generation/ssi_profile_features.aimcopycfg
tomwalters@413 39
tomwalters@335 40 # Number of cores on the experimental machine. Various scripts will try to use
tomwalters@335 41 # this if it's set.
tomwalters@379 42 # NUMBER_OF_CORES=8
tomwalters@335 43
tomwalters@335 44 # Fail if any command fails
tomwalters@335 45 set -e
tomwalters@335 46
tomwalters@335 47 # Fail if any variable is unset
tomwalters@335 48 set -u
tomwalters@335 49
tomwalters@382 50 ######
tomwalters@382 51 # Step 001 - Get the sounds database
tomwalters@348 52 if [ ! -e $SYLLABLES_DATABASE_TAR ]; then
tomwalters@382 53 mkdir -p `dirname $SYLLABLES_DATABASE_TAR`
tomwalters@348 54 wget -O $SYLLABLES_DATABASE_TAR $SYLLABLES_DATABASE_URL
tomwalters@348 55 fi
tomwalters@348 56
tomwalters@335 57 if [ ! -d $SOUNDS_ROOT ]; then
tomwalters@382 58 mkdir -p $SOUNDS_ROOT
tomwalters@335 59 fi
tomwalters@335 60
tomwalters@382 61 # Untar the CNBH syllables database, and convert the files from FLAC to WAV.
tomwalters@335 62 if [ ! -e $SOUNDS_ROOT/.untar_db_success ]; then
tomwalters@335 63 tar -x -C $SOUNDS_ROOT -f $SYLLABLES_DATABASE_TAR
tomwalters@335 64 touch $SOUNDS_ROOT/.untar_db_success
tomwalters@335 65 fi
tomwalters@335 66
tomwalters@335 67 # Convert the database to .WAV format and place it in $SOUNDS_ROOT/clean
tomwalters@355 68 echo "Converting CNBH-syllables database from FLAC to WAV..."
tomwalters@341 69 ./cnbh-syllables/feature_generation/convert_flac_to_wav.sh $SOUNDS_ROOT
tomwalters@382 70 #
tomwalters@382 71 ######
tomwalters@335 72
tomwalters@382 73 #####
tomwalters@382 74 # Step 002 -
tomwalters@335 75 # Generate versions of the CNBH syllables spoke pattern with a range of
tomwalters@335 76 # signal-to-noise ratios (SNRs). The versions are put in the directory
tomwalters@335 77 # ${SOUNDS_ROOT}/${SNR}_dB/ for each SNR in $SNRS.
tomwalters@417 78 SNRS="45"#" 42 39 36 33" #" 30 27 24 21 18 15 12 9 6 3 0"
tomwalters@377 79 #SNRS="30" # For testing
tomwalters@356 80 ./cnbh-syllables/feature_generation/pink_noise.sh $SOUNDS_ROOT/clean/ "$SNRS"
tomwalters@335 81
tomwalters@335 82 # Make the list of all feature drectories
tomwalters@417 83 #FEATURE_DIRS="clean"
tomwalters@417 84 FEATURE_DIRS=""
tomwalters@335 85 for SNR in $SNRS; do
tomwalters@335 86 FEATURE_DIRS="$FEATURE_DIRS snr_${SNR}dB"
tomwalters@335 87 done
tomwalters@335 88
tomwalters@335 89 # Generate feature sets (for the full range of SNRs in $FEATURE_DIRS)
tomwalters@335 90 # 1. Standard MFCC features
tomwalters@335 91 # 2. AIM features
tomwalters@382 92 # 3. MFCC features with optimal VTLN
tomwalters@339 93
tomwalters@339 94 if [ ! -d $FEATURES_ROOT ]; then
tomwalters@382 95 mkdir -p $FEATURES_ROOT
tomwalters@339 96 fi
tomwalters@339 97
tomwalters@382 98 if [ ! -e $HTK_ROOT/.htk_installed_success ]; then
tomwalters@382 99 ./HTK/install_htk.sh $HTK_ROOT
tomwalters@351 100 fi
tomwalters@350 101
tomwalters@382 102 if [ ! -e $AIMC_ROOT/.aimc_build_success ]; then
tomwalters@382 103 ./aimc/build_aimc.sh $AIMC_ROOT
tomwalters@353 104 fi
tomwalters@415 105 export PATH=$PATH:$AIMC_ROOT/build/posix-release/
tomwalters@353 106
tomwalters@335 107 for SOURCE_SNR in $FEATURE_DIRS; do
tomwalters@347 108 if [ ! -e $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success ]; then
tomwalters@335 109 mkdir -p $FEATURES_ROOT/mfcc/$SOURCE_SNR/
tomwalters@335 110 # Generate the list of files to convert
tomwalters@359 111 ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ htk
tomwalters@335 112 # Run the conversion
tomwalters@382 113 ./cnbh-syllables/feature_generation/run_hcopy.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $NUMBER_OF_CORES
tomwalters@382 114 touch $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success
tomwalters@346 115 fi
tomwalters@335 116
tomwalters@347 117 if [ ! -e $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success ]; then
tomwalters@335 118 mkdir -p $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/
tomwalters@335 119 # Generate the file list and run the conversion (all one step, since this
tomwalters@356 120 # version uses a different configuration for each talker)
tomwalters@382 121 ./cnbh-syllables/feature_generation/run_mfcc_vtln_conversion.sh $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/
tomwalters@382 122 touch $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success
tomwalters@346 123 fi
tomwalters@335 124
tomwalters@347 125 if [ ! -e $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success ]; then
tomwalters@382 126 mkdir -p $FEATURES_ROOT/aim/$SOURCE_SNR/
tomwalters@359 127 ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ ""
tomwalters@335 128 # Run the conversion
tomwalters@413 129 ./cnbh-syllables/feature_generation/run_aimcopy.sh $AIMCOPY_CONFIGURATION_FILE $FEATURES_ROOT/aim/$SOURCE_SNR/ $NUMBER_OF_CORES
tomwalters@379 130 touch $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success
tomwalters@346 131 fi
tomwalters@382 132 done
tomwalters@335 133
tomwalters@382 134 mkdir -p $HMMS_ROOT
tomwalters@363 135
tomwalters@335 136 # Now run a bunch of experiments.
tomwalters@335 137 # For each of the feature types, we want to run HMMs with a bunch of
tomwalters@335 138 # parameters.
tomwalters@382 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@413 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@382 141 TESTING_ITERATIONS="15"
tomwalters@382 142 #HMM_STATES="3 4 5 6 7 8"
tomwalters@382 143 HMM_STATES="4"
tomwalters@382 144 #HMM_OUTPUT_COMPONENTS="1 2 3 4 5 6 7"
tomwalters@382 145 HMM_OUTPUT_COMPONENTS="4"
tomwalters@372 146
tomwalters@374 147 run_train_test () {
tomwalters@377 148 # TODO(tom): Make sure that the training SNR is generated first
tomwalters@374 149 for SOURCE_SNR in $FEATURE_DIRS; do
tomwalters@374 150 WORK=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$SOURCE_SNR/$TALKERS/
tomwalters@374 151 mkdir -p $WORK
tomwalters@374 152 FEATURES_DIR=$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/
tomwalters@385 153 SPOKE_PATTERN_FILE=`pwd`/cnbh-syllables/run_training_and_testing/train_test_sets/gen_spoke_points/spoke_pattern.txt
tomwalters@374 154
tomwalters@374 155 ./cnbh-syllables/run_training_and_testing/train_test_sets/generate_train_test_lists.sh \
tomwalters@374 156 $TALKERS \
tomwalters@374 157 $WORK \
tomwalters@374 158 $FEATURES_DIR \
tomwalters@374 159 $FEATURE_SUFFIX
tomwalters@374 160
tom@442 161 if [ $TRAINING_SNR == 'random' ]; then
tom@442 162 TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_script
tom@442 163 TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_master_label_file
tom@442 164 RANDOMIZED_TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_script_randomized
tom@442 165 RANDOMIZED_TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/clean/$TALKERS/training_master_label_file_randomized
tom@442 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@442 167 TRAINING_SCRIPT=$RANDOMIZED_TRAINING_SCRIPT
tom@442 168 TRAINING_MASTER_LABEL_FILE=$RANDOMIZED_TRAINING_MASTER_LABEL_FILE
tom@442 169 else
tom@442 170 TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$TRAINING_SNR/$TALKERS/training_script
tom@442 171 TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$TRAINING_SNR/$TALKERS/training_master_label_file
tom@442 172 fi
tomwalters@377 173
tomwalters@374 174 TESTING_SCRIPT=$WORK/testing_script
tomwalters@377 175 TESTING_MASTER_LABEL_FILE=$WORK/testing_master_label_file
tomwalters@374 176
tomwalters@374 177 ./cnbh-syllables/run_training_and_testing/gen_htk_base_files.sh $WORK
tomwalters@374 178
tomwalters@374 179 ./cnbh-syllables/run_training_and_testing/test_features.sh \
tomwalters@374 180 "$WORK" \
tomwalters@374 181 "$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/" \
tomwalters@374 182 "$FEATURE_SUFFIX" \
tomwalters@374 183 "$HMM_STATES" \
tomwalters@374 184 "$HMM_OUTPUT_COMPONENTS" \
tomwalters@374 185 "$TRAINING_ITERATIONS" \
tomwalters@374 186 "$TESTING_ITERATIONS" \
tomwalters@374 187 "$FEATURE_SIZE" \
tomwalters@374 188 "$FEATURE_TYPE" \
tomwalters@374 189 "$TRAINING_SCRIPT" \
tomwalters@374 190 "$TESTING_SCRIPT" \
tomwalters@376 191 "$TRAINING_MASTER_LABEL_FILE" \
tomwalters@385 192 "$TESTING_MASTER_LABEL_FILE" \
tomwalters@385 193 "$SPOKE_PATTERN_FILE"
tomwalters@374 194 done
tomwalters@374 195 }
tomwalters@374 196
tomwalters@372 197 ########################
tomwalters@372 198 # Standard MFCCs
tomwalters@356 199 FEATURE_CLASS=mfcc
tomwalters@360 200 FEATURE_SUFFIX=htk
tomwalters@356 201 FEATURE_SIZE=39
tomwalters@356 202 FEATURE_TYPE=MFCC_0_D_A
tomwalters@372 203 TALKERS=inner_talkers
tom@442 204 TRAINING_SNR=random
tomwalters@372 205 run_train_test
tomwalters@372 206 ########################
tomwalters@335 207
tomwalters@372 208 ########################
tomwalters@372 209 # Standard MFCCs
tomwalters@372 210 # Train on extrema
tomwalters@372 211 FEATURE_CLASS=mfcc
tomwalters@372 212 FEATURE_SUFFIX=htk
tomwalters@372 213 FEATURE_SIZE=39
tomwalters@372 214 FEATURE_TYPE=MFCC_0_D_A
tomwalters@372 215 TALKERS=outer_talkers
tomwalters@377 216 TRAINING_SNR=clean
tom@442 217 #run_train_test
tomwalters@372 218 ########################
tomwalters@372 219
tomwalters@372 220 ########################
tomwalters@372 221 # MFCCs with VTLN
tomwalters@372 222 FEATURE_CLASS=mfcc_vtln
tomwalters@372 223 FEATURE_SUFFIX=htk
tomwalters@372 224 FEATURE_SIZE=39
tomwalters@372 225 FEATURE_TYPE=MFCC_0_D_A
tomwalters@359 226 TALKERS=inner_talkers
tom@442 227 TRAINING_SNR=random
tomwalters@372 228 run_train_test
tomwalters@372 229 ########################
tomwalters@372 230
tomwalters@372 231 ########################
tomwalters@372 232 # MFCCs with VTLN
tomwalters@372 233 # Train on extrema
tomwalters@372 234 FEATURE_CLASS=mfcc_vtln
tomwalters@372 235 FEATURE_SUFFIX=htk
tomwalters@372 236 FEATURE_SIZE=39
tomwalters@372 237 FEATURE_TYPE=MFCC_0_D_A
tomwalters@372 238 TALKERS=outer_talkers
tom@442 239 TRAINING_SNR=random
tom@442 240 #run_train_test
tomwalters@372 241 ########################
tomwalters@372 242
tomwalters@382 243 AIM_FEATURE_SUFFIXES="slice_1_no_cutoff ssi_profile_no_cutoff slice_1_cutoff ssi_profile_cutoff smooth_nap_profile"
tomwalters@382 244 for f in $AIM_FEATURE_SUFFIXES
tomwalters@382 245 do
tomwalters@372 246 ########################
tomwalters@372 247 # AIM Features
tomwalters@382 248 # Inner talkers
tomwalters@382 249 FEATURE_CLASS=aim
tomwalters@382 250 FEATURE_SUFFIX=$f
tomwalters@382 251 FEATURE_SIZE=12
tomwalters@382 252 FEATURE_TYPE=USER_E_D_A
tomwalters@382 253 TALKERS=inner_talkers
tom@442 254 TRAINING_SNR=random
tomwalters@382 255 run_train_test
tomwalters@372 256 ########################
tomwalters@372 257
tomwalters@382 258 ########################
tomwalters@382 259 # AIM Features
tomwalters@382 260 # Inner talkers
tomwalters@382 261 FEATURE_CLASS=aim
tomwalters@382 262 FEATURE_SUFFIX=$f
tomwalters@382 263 FEATURE_SIZE=12
tomwalters@382 264 FEATURE_TYPE=USER_E_D_A
tomwalters@382 265 TALKERS=outer_talkers
tomwalters@382 266 TRAINING_SNR=clean
tom@442 267 #run_train_test
tomwalters@382 268 ########################
tomwalters@382 269 done
tomwalters@372 270
tomwalters@359 271
tomwalters@357 272
tomwalters@362 273