annotate trunk/experiments/scripts/cnbh-syllables/feature_generation/pink_noise.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 839a370eb554
children
rev   line source
tomwalters@335 1 #!/bin/bash
tomwalters@335 2 # Copyright 2009-2010 Thomas Walters <tom@acousticscale.org>
tomwalters@335 3 #
tomwalters@335 4 # Add pink noise to the CNBH syllables database. The first argument is the
tomwalters@335 5 # path to the clean .wav files. The second argument is a quoted list of the
tomwalters@335 6 # desired SNRs in dB, separated by spaces. Directories are made for each SNR
tomwalters@335 7 # in the directory above that given in the first argument.
tomwalters@335 8 set -e
tomwalters@335 9 set -u
tomwalters@335 10
tomwalters@335 11 CLEAN_SYLLABLES_DATABASE_PATH=$1
tomwalters@335 12 SIGNAL_TO_NOISE_RATIOS=$2
tomwalters@335 13
tomwalters@335 14 # The syllables database is approximately at -9dB re. the max RMS level for a
tomwalters@335 15 # .wav file.
tomwalters@335 16 REFERENCE_SIGNAL_LEVEL="-9"
tomwalters@335 17 SAMPLE_RATE=48000
tomwalters@335 18
tomwalters@335 19 PREV_DIR=`pwd`
tomwalters@335 20 cd $CLEAN_SYLLABLES_DATABASE_PATH
tomwalters@335 21
tomwalters@335 22 for SNR in ${SIGNAL_TO_NOISE_RATIOS}; do
tomwalters@355 23 echo "Generating noisy data for SNR ${SNR}dB"
tomwalters@335 24 if [ ! -e ../snr_${SNR}dB/.pink_noise_success ]
tomwalters@335 25 then
tomwalters@335 26 mkdir -p ../snr_${SNR}dB/
tomwalters@335 27 VOWELS="a e i o u"
tomwalters@335 28 CONSONANTS="b d f g h k l m n p r s t v w x y z"
tomwalters@335 29 for v in $VOWELS; do
tomwalters@335 30 mkdir ../snr_${SNR}dB/$v$v
tomwalters@335 31 for c in $CONSONANTS; do
tomwalters@335 32 mkdir ../snr_${SNR}dB/$c$v
tomwalters@335 33 mkdir ../snr_${SNR}dB/$v$c
tomwalters@335 34 done
tomwalters@335 35 done
tomwalters@335 36 NOISE_LEVEL=$(( $REFERENCE_SIGNAL_LEVEL - $SNR ))
tomwalters@335 37 for file in `find . -iname "*.wav"`; do
tomwalters@335 38 # Note: the 0.684 below is the length of each syllable in the database
tomwalters@335 39 # in seconds
tomwalters@335 40 sox -r ${SAMPLE_RATE} -b 16 -n -t s2 - synth 0.684 pinknoise vol ${NOISE_LEVEL} dB | sox -m -v 0.25 $file -t s2 -r ${SAMPLE_RATE} -c 1 - ../snr_${SNR}dB/${file}
tomwalters@335 41 done
tomwalters@335 42 touch ../snr_${SNR}dB/.pink_noise_success
tomwalters@335 43 fi
tomwalters@335 44 done
tomwalters@335 45 cd $PREV_DIR