tomwalters@335: #!/bin/bash tomwalters@335: # Copyright 2010 Thomas Walters tomwalters@335: # tomwalters@335: # Run a series of experiments which compare MFCC features generated by HTK to tomwalters@335: # AIM features generated using AIM-C using a series of syllable recogntiton tomwalters@335: # tasks. tomwalters@371: # This script expects to be run from within the AIM-C source tree. tomwalters@371: # It builds the HTK binaries and AIM-C AIMCopy binary if they're not tomwalters@371: # present. tomwalters@371: # The following environment varaibles should be set before this script is run: tomwalters@371: # SYLLABLES_DATABASE_URL - URL of a tar file containing the CNBH syllables tomwalters@371: # database in FLAC format tomwalters@371: # HTK_USERNAME and HTK_PASSWORD - username and password for the site at tomwalters@371: # http://htk.eng.cam.ac.uk/ tomwalters@371: tomwalters@335: # Set these to be the location of your input database, and desired output tomwalters@335: # locations. tomwalters@348: SYLLABLES_DATABASE_TAR=/mnt/sounds/cnbh-syllables.tar tomwalters@335: SOUNDS_ROOT=/mnt/experiments/sounds/ tomwalters@335: FEATURES_ROOT=/mnt/experiments/features/ tomwalters@335: HMMS_ROOT=/mnt/experiments/hmms/ tomwalters@335: tomwalters@335: # Number of cores on the experimental machine. Various scripts will try to use tomwalters@335: # this if it's set. tomwalters@377: NUMBER_OF_CORES=8 tomwalters@335: tomwalters@335: # Fail if any command fails tomwalters@335: set -e tomwalters@335: tomwalters@335: # Fail if any variable is unset tomwalters@335: set -u tomwalters@335: tomwalters@348: if [ ! -e $SYLLABLES_DATABASE_TAR ]; then tomwalters@348: sudo mkdir -p `dirname $SYLLABLES_DATABASE_TAR` tomwalters@348: sudo chown ubuntu `dirname $SYLLABLES_DATABASE_TAR` tomwalters@348: wget -O $SYLLABLES_DATABASE_TAR $SYLLABLES_DATABASE_URL tomwalters@348: fi tomwalters@348: tomwalters@335: if [ ! -d $SOUNDS_ROOT ]; then tomwalters@339: sudo mkdir -p $SOUNDS_ROOT tomwalters@339: sudo chown `whoami` $SOUNDS_ROOT tomwalters@335: fi tomwalters@335: tomwalters@335: # Untar the CNBH syllables database, and convert the files from FLAC to WAV tomwalters@335: if [ ! -e $SOUNDS_ROOT/.untar_db_success ]; then tomwalters@335: tar -x -C $SOUNDS_ROOT -f $SYLLABLES_DATABASE_TAR tomwalters@335: touch $SOUNDS_ROOT/.untar_db_success tomwalters@335: fi tomwalters@335: tomwalters@335: # Convert the database to .WAV format and place it in $SOUNDS_ROOT/clean tomwalters@355: echo "Converting CNBH-syllables database from FLAC to WAV..." tomwalters@341: ./cnbh-syllables/feature_generation/convert_flac_to_wav.sh $SOUNDS_ROOT tomwalters@335: tomwalters@335: # Generate versions of the CNBH syllables spoke pattern with a range of tomwalters@335: # signal-to-noise ratios (SNRs). The versions are put in the directory tomwalters@335: # ${SOUNDS_ROOT}/${SNR}_dB/ for each SNR in $SNRS. tomwalters@377: SNRS="30 27 24 21 18 15 12 9 6 3 0" tomwalters@377: #SNRS="30" # For testing tomwalters@356: ./cnbh-syllables/feature_generation/pink_noise.sh $SOUNDS_ROOT/clean/ "$SNRS" tomwalters@335: tomwalters@335: # Make the list of all feature drectories tomwalters@335: FEATURE_DIRS="clean" tomwalters@335: for SNR in $SNRS; do tomwalters@335: FEATURE_DIRS="$FEATURE_DIRS snr_${SNR}dB" tomwalters@335: done tomwalters@335: tomwalters@335: # Generate feature sets (for the full range of SNRs in $FEATURE_DIRS) tomwalters@335: # 1. Standard MFCC features tomwalters@335: # 2. AIM features tomwalters@335: # 3. MFCC features with optimal VTLN tomwalters@339: tomwalters@339: tomwalters@339: if [ ! -d $FEATURES_ROOT ]; then tomwalters@339: sudo mkdir -p $FEATURES_ROOT tomwalters@339: sudo chown `whoami` $FEATURES_ROOT tomwalters@339: fi tomwalters@339: tomwalters@350: if [ ! -e /mnt/experiments/htk/.htk_installed_success ]; then tomwalters@350: ./HTK/install_htk.sh tomwalters@351: fi tomwalters@350: tomwalters@354: if [ ! -e /mnt/experiments/aimc/.aimc_build_success ]; then tomwalters@353: # ./aimc/build_aimc.sh tomwalters@353: cd ../../ tomwalters@353: scons tomwalters@353: export PATH=$PATH:`pwd`/build/posix-release/ tomwalters@353: cd - tomwalters@353: fi tomwalters@353: tomwalters@335: for SOURCE_SNR in $FEATURE_DIRS; do tomwalters@335: tomwalters@347: if [ ! -e $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success ]; then tomwalters@335: mkdir -p $FEATURES_ROOT/mfcc/$SOURCE_SNR/ tomwalters@335: # Generate the list of files to convert tomwalters@359: ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ htk tomwalters@335: # Run the conversion tomwalters@335: ./cnbh-syllables/feature_generation/run_hcopy.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $NUMBER_OF_CORES tomwalters@335: touch $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success tomwalters@346: fi tomwalters@335: tomwalters@347: if [ ! -e $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success ]; then tomwalters@335: mkdir -p $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/ tomwalters@335: # Generate the file list and run the conversion (all one step, since this tomwalters@356: # version uses a different configuration for each talker) tomwalters@335: ./cnbh-syllables/feature_generation/run_mfcc_vtln_conversion.sh $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ tomwalters@335: touch $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success tomwalters@346: fi tomwalters@335: tomwalters@347: if [ ! -e $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success ]; then tomwalters@335: mkdir -p $FEATURES_ROOT/aim/$SOURCE_SNR/ tomwalters@359: ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ "" tomwalters@335: # Run the conversion tomwalters@361: #./cnbh-syllables/feature_generation/run_aimcopy.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $NUMBER_OF_CORES tomwalters@361: #touch $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success tomwalters@346: fi tomwalters@335: done tomwalters@335: tomwalters@363: sudo mkdir -p $HMMS_ROOT tomwalters@363: sudo chown ubuntu $HMMS_ROOT tomwalters@363: tomwalters@335: # Now run a bunch of experiments. tomwalters@335: # For each of the feature types, we want to run HMMs with a bunch of tomwalters@335: # parameters. tomwalters@335: 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: TESTING_ITERATIONS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20" tomwalters@335: HMM_STATES="3 4 5 6 7 8" tomwalters@372: HMM_OUTPUT_COMPONENTS="1 2 3 4 5 6 7" tomwalters@335: tomwalters@372: tomwalters@374: run_train_test () { tomwalters@377: # TODO(tom): Make sure that the training SNR is generated first tomwalters@374: for SOURCE_SNR in $FEATURE_DIRS; do tomwalters@374: WORK=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$SOURCE_SNR/$TALKERS/ tomwalters@374: mkdir -p $WORK tomwalters@374: FEATURES_DIR=$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/ tomwalters@374: tomwalters@374: ./cnbh-syllables/run_training_and_testing/train_test_sets/generate_train_test_lists.sh \ tomwalters@374: $TALKERS \ tomwalters@374: $WORK \ tomwalters@374: $FEATURES_DIR \ tomwalters@374: $FEATURE_SUFFIX tomwalters@374: tomwalters@377: TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$TRAINING_SNR/$TALKERS/training_script tomwalters@377: TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$TRAINING_SNR/$TALKERS/training_master_label_file tomwalters@377: tomwalters@374: TESTING_SCRIPT=$WORK/testing_script tomwalters@377: TESTING_MASTER_LABEL_FILE=$WORK/testing_master_label_file tomwalters@374: tomwalters@374: ./cnbh-syllables/run_training_and_testing/gen_htk_base_files.sh $WORK tomwalters@374: tomwalters@374: ./cnbh-syllables/run_training_and_testing/test_features.sh \ tomwalters@374: "$WORK" \ tomwalters@374: "$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/" \ tomwalters@374: "$FEATURE_SUFFIX" \ tomwalters@374: "$HMM_STATES" \ tomwalters@374: "$HMM_OUTPUT_COMPONENTS" \ tomwalters@374: "$TRAINING_ITERATIONS" \ tomwalters@374: "$TESTING_ITERATIONS" \ tomwalters@374: "$FEATURE_SIZE" \ tomwalters@374: "$FEATURE_TYPE" \ tomwalters@374: "$TRAINING_SCRIPT" \ tomwalters@374: "$TESTING_SCRIPT" \ tomwalters@376: "$TRAINING_MASTER_LABEL_FILE" \ tomwalters@376: "$TESTING_MASTER_LABEL_FILE" tomwalters@374: done tomwalters@374: } tomwalters@374: tomwalters@374: tomwalters@372: ######################## tomwalters@372: # Standard MFCCs tomwalters@356: FEATURE_CLASS=mfcc tomwalters@360: FEATURE_SUFFIX=htk tomwalters@356: FEATURE_SIZE=39 tomwalters@356: FEATURE_TYPE=MFCC_0_D_A tomwalters@372: TALKERS=inner_talkers tomwalters@377: TRAINING_SNR=clean tomwalters@372: run_train_test tomwalters@372: ######################## tomwalters@335: tomwalters@372: ######################## tomwalters@372: # Standard MFCCs tomwalters@372: # Train on extrema tomwalters@372: FEATURE_CLASS=mfcc tomwalters@372: FEATURE_SUFFIX=htk tomwalters@372: FEATURE_SIZE=39 tomwalters@372: FEATURE_TYPE=MFCC_0_D_A tomwalters@372: TALKERS=outer_talkers tomwalters@377: TRAINING_SNR=clean tomwalters@372: run_train_test tomwalters@372: ######################## tomwalters@372: tomwalters@372: ######################## tomwalters@372: # MFCCs with VTLN tomwalters@372: FEATURE_CLASS=mfcc_vtln tomwalters@372: FEATURE_SUFFIX=htk tomwalters@372: FEATURE_SIZE=39 tomwalters@372: FEATURE_TYPE=MFCC_0_D_A tomwalters@359: TALKERS=inner_talkers tomwalters@377: TRAINING_SNR=clean tomwalters@372: run_train_test tomwalters@372: ######################## tomwalters@372: tomwalters@372: ######################## tomwalters@372: # MFCCs with VTLN tomwalters@372: # Train on extrema tomwalters@372: FEATURE_CLASS=mfcc_vtln tomwalters@372: FEATURE_SUFFIX=htk tomwalters@372: FEATURE_SIZE=39 tomwalters@372: FEATURE_TYPE=MFCC_0_D_A tomwalters@372: TALKERS=outer_talkers tomwalters@377: TRAINING_SNR=clean tomwalters@372: run_train_test tomwalters@372: ######################## tomwalters@372: tomwalters@372: ######################## tomwalters@372: # AIM Features tomwalters@372: # TODO (loop over all feature suffixes) tomwalters@372: ######################## tomwalters@372: tomwalters@372: tomwalters@359: tomwalters@357: tomwalters@362: