tomwalters@54: #!/bin/bash tomwalters@54: # Copyright 2010 Thomas Walters tomwalters@54: # tomwalters@54: # Run a series of experiments which compare MFCC features generated by HTK to tomwalters@54: # AIM features generated using AIM-C using a series of syllable recogntiton tomwalters@54: # tasks. tomwalters@90: # This script expects to be run from within the AIM-C source tree. tomwalters@101: # It builds the HTK binaries and AIM-C AIMCopy binary if they're not tomwalters@101: # present. tomwalters@90: # The following environment varaibles should be set before this script is run: tomwalters@90: # SYLLABLES_DATABASE_URL - URL of a tar file containing the CNBH syllables tomwalters@90: # database in FLAC format tomwalters@101: # HTK_USERNAME and HTK_PASSWORD - username and password for the site at tomwalters@90: # http://htk.eng.cam.ac.uk/ tomwalters@98: # NUMBER_OF_CORES - total number of machine cores tomwalters@90: tomwalters@54: # Set these to be the location of your input database, and desired output tomwalters@101: # locations. (Note: the user running this script needs write permissions on tomwalters@101: # the $WORKING_VOLUME.) tomwalters@101: WORKING_VOLUME=/mnt/scratch1 tomwalters@101: tomwalters@101: SYLLABLES_DATABASE_TAR=$WORKING_VOLUME/001-downloaded_sounds_data/cnbh-syllables.tar tomwalters@101: SOUNDS_ROOT=$WORKING_VOLUME/002-sounds/ tomwalters@101: FEATURES_ROOT=$WORKING_VOLUME/003-features/ tomwalters@101: HMMS_ROOT=$WORKING_VOLUME/004-hmms/ tomwalters@101: HTK_ROOT=$WORKING_VOLUME/software/htk/ tomwalters@101: AIMC_ROOT=$WORKING_VOLUME/software/aimc/ tomwalters@54: tomwalters@54: # Number of cores on the experimental machine. Various scripts will try to use tomwalters@54: # this if it's set. tomwalters@98: # NUMBER_OF_CORES=8 tomwalters@54: tomwalters@54: # Fail if any command fails tomwalters@54: set -e tomwalters@54: tomwalters@54: # Fail if any variable is unset tomwalters@54: set -u tomwalters@54: tomwalters@101: ###### tomwalters@101: # Step 001 - Get the sounds database tomwalters@67: if [ ! -e $SYLLABLES_DATABASE_TAR ]; then tomwalters@101: mkdir -p `dirname $SYLLABLES_DATABASE_TAR` tomwalters@67: wget -O $SYLLABLES_DATABASE_TAR $SYLLABLES_DATABASE_URL tomwalters@67: fi tomwalters@67: tomwalters@54: if [ ! -d $SOUNDS_ROOT ]; then tomwalters@101: mkdir -p $SOUNDS_ROOT tomwalters@54: fi tomwalters@54: tomwalters@101: # Untar the CNBH syllables database, and convert the files from FLAC to WAV. tomwalters@54: if [ ! -e $SOUNDS_ROOT/.untar_db_success ]; then tomwalters@54: tar -x -C $SOUNDS_ROOT -f $SYLLABLES_DATABASE_TAR tomwalters@54: touch $SOUNDS_ROOT/.untar_db_success tomwalters@54: fi tomwalters@54: tomwalters@54: # Convert the database to .WAV format and place it in $SOUNDS_ROOT/clean tomwalters@74: echo "Converting CNBH-syllables database from FLAC to WAV..." tomwalters@60: ./cnbh-syllables/feature_generation/convert_flac_to_wav.sh $SOUNDS_ROOT tomwalters@101: # tomwalters@101: ###### tomwalters@54: tomwalters@101: ##### tomwalters@101: # Step 002 - tomwalters@54: # Generate versions of the CNBH syllables spoke pattern with a range of tomwalters@54: # signal-to-noise ratios (SNRs). The versions are put in the directory tomwalters@54: # ${SOUNDS_ROOT}/${SNR}_dB/ for each SNR in $SNRS. tomwalters@96: SNRS="30 27 24 21 18 15 12 9 6 3 0" tomwalters@96: #SNRS="30" # For testing tomwalters@75: ./cnbh-syllables/feature_generation/pink_noise.sh $SOUNDS_ROOT/clean/ "$SNRS" tomwalters@54: tomwalters@54: # Make the list of all feature drectories tomwalters@54: FEATURE_DIRS="clean" tomwalters@54: for SNR in $SNRS; do tomwalters@54: FEATURE_DIRS="$FEATURE_DIRS snr_${SNR}dB" tomwalters@54: done tomwalters@54: tomwalters@54: # Generate feature sets (for the full range of SNRs in $FEATURE_DIRS) tomwalters@54: # 1. Standard MFCC features tomwalters@54: # 2. AIM features tomwalters@101: # 3. MFCC features with optimal VTLN tomwalters@58: tomwalters@58: if [ ! -d $FEATURES_ROOT ]; then tomwalters@101: mkdir -p $FEATURES_ROOT tomwalters@58: fi tomwalters@58: tomwalters@101: if [ ! -e $HTK_ROOT/.htk_installed_success ]; then tomwalters@101: ./HTK/install_htk.sh $HTK_ROOT tomwalters@70: fi tomwalters@69: tomwalters@101: if [ ! -e $AIMC_ROOT/.aimc_build_success ]; then tomwalters@101: ./aimc/build_aimc.sh $AIMC_ROOT tomwalters@72: fi tomwalters@72: tomwalters@54: for SOURCE_SNR in $FEATURE_DIRS; do tomwalters@66: if [ ! -e $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success ]; then tomwalters@54: mkdir -p $FEATURES_ROOT/mfcc/$SOURCE_SNR/ tomwalters@54: # Generate the list of files to convert tomwalters@78: ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ htk tomwalters@54: # Run the conversion tomwalters@101: ./cnbh-syllables/feature_generation/run_hcopy.sh $FEATURES_ROOT/mfcc/$SOURCE_SNR/ $NUMBER_OF_CORES tomwalters@101: touch $FEATURES_ROOT/mfcc/$SOURCE_SNR/.make_mfcc_features_success tomwalters@65: fi tomwalters@54: tomwalters@66: if [ ! -e $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success ]; then tomwalters@54: mkdir -p $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/ tomwalters@54: # Generate the file list and run the conversion (all one step, since this tomwalters@75: # version uses a different configuration for each talker) tomwalters@101: ./cnbh-syllables/feature_generation/run_mfcc_vtln_conversion.sh $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ tomwalters@101: touch $FEATURES_ROOT/mfcc_vtln/$SOURCE_SNR/.make_mfcc_vtln_features_success tomwalters@65: fi tomwalters@54: tomwalters@66: if [ ! -e $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success ]; then tomwalters@101: mkdir -p $FEATURES_ROOT/aim/$SOURCE_SNR/ tomwalters@78: ./cnbh-syllables/feature_generation/gen_hcopy_aimcopy_script.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $SOUNDS_ROOT/$SOURCE_SNR/ "" tomwalters@54: # Run the conversion tomwalters@98: ./cnbh-syllables/feature_generation/run_aimcopy.sh $FEATURES_ROOT/aim/$SOURCE_SNR/ $NUMBER_OF_CORES tomwalters@98: touch $FEATURES_ROOT/aim/$SOURCE_SNR/.make_aim_features_success tomwalters@65: fi tomwalters@101: done tomwalters@54: tomwalters@101: mkdir -p $HMMS_ROOT tomwalters@82: tomwalters@54: # Now run a bunch of experiments. tomwalters@54: # For each of the feature types, we want to run HMMs with a bunch of tomwalters@54: # parameters. tomwalters@101: TRAINING_ITERATIONS="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" # 16 17 18 19 20" tomwalters@101: #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: TESTING_ITERATIONS="15" tomwalters@101: #HMM_STATES="3 4 5 6 7 8" tomwalters@101: HMM_STATES="4" tomwalters@101: #HMM_OUTPUT_COMPONENTS="1 2 3 4 5 6 7" tomwalters@101: HMM_OUTPUT_COMPONENTS="4" tomwalters@91: tomwalters@93: run_train_test () { tomwalters@96: # TODO(tom): Make sure that the training SNR is generated first tomwalters@93: for SOURCE_SNR in $FEATURE_DIRS; do tomwalters@93: WORK=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$SOURCE_SNR/$TALKERS/ tomwalters@93: mkdir -p $WORK tomwalters@93: FEATURES_DIR=$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/ tomwalters@104: SPOKE_PATTERN_FILE=`pwd`/cnbh-syllables/run_training_and_testing/train_test_sets/gen_spoke_points/spoke_pattern.txt tomwalters@93: tomwalters@93: ./cnbh-syllables/run_training_and_testing/train_test_sets/generate_train_test_lists.sh \ tomwalters@93: $TALKERS \ tomwalters@93: $WORK \ tomwalters@93: $FEATURES_DIR \ tomwalters@93: $FEATURE_SUFFIX tomwalters@93: tomwalters@96: TRAINING_SCRIPT=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$TRAINING_SNR/$TALKERS/training_script tomwalters@96: TRAINING_MASTER_LABEL_FILE=$HMMS_ROOT/$FEATURE_CLASS/$FEATURE_SUFFIX/$TRAINING_SNR/$TALKERS/training_master_label_file tomwalters@96: tomwalters@93: TESTING_SCRIPT=$WORK/testing_script tomwalters@96: TESTING_MASTER_LABEL_FILE=$WORK/testing_master_label_file tomwalters@93: tomwalters@93: ./cnbh-syllables/run_training_and_testing/gen_htk_base_files.sh $WORK tomwalters@93: tomwalters@93: ./cnbh-syllables/run_training_and_testing/test_features.sh \ tomwalters@93: "$WORK" \ tomwalters@93: "$FEATURES_ROOT/$FEATURE_CLASS/$SOURCE_SNR/" \ tomwalters@93: "$FEATURE_SUFFIX" \ tomwalters@93: "$HMM_STATES" \ tomwalters@93: "$HMM_OUTPUT_COMPONENTS" \ tomwalters@93: "$TRAINING_ITERATIONS" \ tomwalters@93: "$TESTING_ITERATIONS" \ tomwalters@93: "$FEATURE_SIZE" \ tomwalters@93: "$FEATURE_TYPE" \ tomwalters@93: "$TRAINING_SCRIPT" \ tomwalters@93: "$TESTING_SCRIPT" \ tomwalters@95: "$TRAINING_MASTER_LABEL_FILE" \ tomwalters@104: "$TESTING_MASTER_LABEL_FILE" \ tomwalters@104: "$SPOKE_PATTERN_FILE" tomwalters@93: done tomwalters@93: } tomwalters@93: tomwalters@91: ######################## tomwalters@91: # Standard MFCCs tomwalters@75: FEATURE_CLASS=mfcc tomwalters@79: FEATURE_SUFFIX=htk tomwalters@75: FEATURE_SIZE=39 tomwalters@75: FEATURE_TYPE=MFCC_0_D_A tomwalters@91: TALKERS=inner_talkers tomwalters@96: TRAINING_SNR=clean tomwalters@91: run_train_test tomwalters@91: ######################## tomwalters@54: tomwalters@91: ######################## tomwalters@91: # Standard MFCCs tomwalters@91: # Train on extrema tomwalters@91: FEATURE_CLASS=mfcc tomwalters@91: FEATURE_SUFFIX=htk tomwalters@91: FEATURE_SIZE=39 tomwalters@91: FEATURE_TYPE=MFCC_0_D_A tomwalters@91: TALKERS=outer_talkers tomwalters@96: TRAINING_SNR=clean tomwalters@91: run_train_test tomwalters@91: ######################## tomwalters@91: tomwalters@91: ######################## tomwalters@91: # MFCCs with VTLN tomwalters@91: FEATURE_CLASS=mfcc_vtln tomwalters@91: FEATURE_SUFFIX=htk tomwalters@91: FEATURE_SIZE=39 tomwalters@91: FEATURE_TYPE=MFCC_0_D_A tomwalters@78: TALKERS=inner_talkers tomwalters@96: TRAINING_SNR=clean tomwalters@91: run_train_test tomwalters@91: ######################## tomwalters@91: tomwalters@91: ######################## tomwalters@91: # MFCCs with VTLN tomwalters@91: # Train on extrema tomwalters@91: FEATURE_CLASS=mfcc_vtln tomwalters@91: FEATURE_SUFFIX=htk tomwalters@91: FEATURE_SIZE=39 tomwalters@91: FEATURE_TYPE=MFCC_0_D_A tomwalters@91: TALKERS=outer_talkers tomwalters@96: TRAINING_SNR=clean tomwalters@91: run_train_test tomwalters@91: ######################## tomwalters@91: tomwalters@101: AIM_FEATURE_SUFFIXES="slice_1_no_cutoff ssi_profile_no_cutoff slice_1_cutoff ssi_profile_cutoff smooth_nap_profile" tomwalters@101: for f in $AIM_FEATURE_SUFFIXES tomwalters@101: do tomwalters@91: ######################## tomwalters@91: # AIM Features tomwalters@101: # Inner talkers tomwalters@101: FEATURE_CLASS=aim tomwalters@101: FEATURE_SUFFIX=$f tomwalters@101: FEATURE_SIZE=12 tomwalters@101: FEATURE_TYPE=USER_E_D_A tomwalters@101: TALKERS=inner_talkers tomwalters@101: TRAINING_SNR=clean tomwalters@101: run_train_test tomwalters@91: ######################## tomwalters@91: tomwalters@101: ######################## tomwalters@101: # AIM Features tomwalters@101: # Inner talkers tomwalters@101: FEATURE_CLASS=aim tomwalters@101: FEATURE_SUFFIX=$f tomwalters@101: FEATURE_SIZE=12 tomwalters@101: FEATURE_TYPE=USER_E_D_A tomwalters@101: TALKERS=outer_talkers tomwalters@101: TRAINING_SNR=clean tomwalters@101: run_train_test tomwalters@101: ######################## tomwalters@101: done tomwalters@91: tomwalters@78: tomwalters@76: tomwalters@81: