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