comparison trunk/scripts/gen_features.sh @ 306:42d154648b93

-Modified AIMCopy for slices experiment -Added gen_features script to just generate features for a given SNR
author tomwalters
date Thu, 25 Feb 2010 23:08:08 +0000
parents
children a9e7737cad19
comparison
equal deleted inserted replaced
305:ed91095d9240 306:42d154648b93
1 #!/bin/bash
2 #
3 # Run the syllables database 'spider pattern' through AIM-C
4 #
5 # Copyright 2009-2010 University of Cambridge
6 # Author: Thomas Walters <tom@acousticscale.org>
7
8 # Source directory for all the sound files
9 SOUND_SOURCE="/Users/Tom/Documents/Work/PhD/HTK-AIM/Sounds/"
10
11 # Location of the AIMCopy binary if not in the path
12 AIMCOPY_PREFIX="../build/darwin-release/"
13
14 MACHINE_CORES=2
15
16 # Names of various internal files and directories.
17 # Rename here if you don't like them for some reason.
18 SYLLIST=syls
19 TRAIN_SPEAKERS=train_speakers
20 TEST_SPEAKERS=test_speakers
21 WORK_PREFIX=snr
22 TRAIN_LIST=train.list
23 TEST_LIST=test.list
24 COMBINED_LIST=combined.list
25 FEATURES_DIR=features
26 AIMCOPY_CONFIG=aimcopy.cfg
27 AIMCOPY_LOG_TRAIN=aimcopy_train.log
28 AIMCOPY_LOG_TEST=aimcopy_test.log
29
30
31 # The vowels and consonants that make up the CNBH database
32 VOWELS="a e i o u"
33 CONSONANTS="b d f g h k l m n p r s t v w x y z"
34 SILENCE="sil"
35
36 WORK=${WORK_PREFIX}`echo $1 | tr -d ' '`
37 mkdir -p $WORK
38
39 # Make a copy of this script in the experimental directory
40 cp -p $0 $WORK
41
42
43 echo "Generating syllable list..."
44
45 for v in $VOWELS; do
46 echo $v$v >> $WORK/$SYLLIST.tmp
47 for c in $CONSONANTS; do
48 echo $v$c >> $WORK/$SYLLIST.tmp
49 done
50 done
51
52 # Sort the syllable list and delete the
53 # temporary, unsorted version
54 sort $WORK/$SYLLIST.tmp > $WORK/$SYLLIST
55
56
57 # Generate a list of filenames from the spoke pattern
58 cat <<"EOF" > $WORK/$TRAIN_SPEAKERS
59 170.9p112.2s100.0t+000itd
60 171.0p112.8s100.0t+000itd
61 171.3p111.7s100.0t+000itd
62 171.5p113.1s100.0t+000itd
63 171.9p111.5s100.0t+000itd
64 172.1p113.0s100.0t+000itd
65 172.4p111.9s100.0t+000itd
66 172.5p112.5s100.0t+000itd
67 EOF
68
69 cat <<"EOF" > $WORK/$TEST_SPEAKERS
70 137.0p104.3s100.0t+000itd
71 141.3p135.4s100.0t+000itd
72 145.5p106.3s100.0t+000itd
73 148.8p128.8s100.0t+000itd
74 151.6p83.9s100.0t+000itd
75 153.0p108.1s100.0t+000itd
76 155.5p123.5s100.0t+000itd
77 156.7p90.6s100.0t+000itd
78 159.5p109.6s100.0t+000itd
79 161.1p119.4s100.0t+000itd
80 161.1p96.8s100.0t+000itd
81 163.4p157.6s100.0t+000itd
82 164.7p110.8s100.0t+000itd
83 164.9p102.1s100.0t+000itd
84 165.6p144.0s100.0t+000itd
85 165.7p116.2s100.0t+000itd
86 167.4p133.5s100.0t+000itd
87 167.8p106.5s100.0t+000itd
88 168.6p111.6s100.0t+000itd
89 168.9p125.4s100.0t+000itd
90 169.0p114.0s100.0t+000itd
91 170.0p109.7s100.0t+000itd
92 170.1p119.5s100.0t+000itd
93 171.0p115.5s100.0t+000itd
94 171.7p112.3s100.0t+000itd
95 172.4p109.3s100.0t+000itd
96 173.3p105.6s100.0t+000itd
97 173.5p115.0s100.0t+000itd
98 174.5p100.6s100.0t+000itd
99 174.5p110.6s100.0t+000itd
100 174.9p113.0s100.0t+000itd
101 175.7p118.5s100.0t+000itd
102 176.1p94.5s100.0t+000itd
103 178.0p108.5s100.0t+000itd
104 178.1p87.6s100.0t+000itd
105 178.8p123.6s100.0t+000itd
106 179.0p113.9s100.0t+000itd
107 180.4p80.1s100.0t+000itd
108 183.0p105.7s100.0t+000itd
109 183.0p130.4s100.0t+000itd
110 184.8p115.1s100.0t+000itd
111 188.1p139.2s100.0t+000itd
112 189.6p102.1s100.0t+000itd
113 192.7p116.7s100.0t+000itd
114 194.5p150.4s100.0t+000itd
115 198.1p97.9s100.0t+000itd
116 202.7p118.6s100.0t+000itd
117 208.6p93.2s100.0t+000itd
118 215.2p121.0s100.0t+000itd
119 EOF
120
121 # Construct the conversion scripts for AIMCopy (or HCopy) and
122 # the master label files for the train and test sets
123
124 echo "Generating train and test scripts..."
125 if [ -a $WORK/$TRAIN_LIST ]
126 then
127 rm $WORK/$TRAIN_LIST
128 fi
129 if [ -a $WORK/$TEST_LIST ]
130 then
131 rm $WORK/$TEST_LIST
132 fi
133
134 exec 3> $WORK/$TRAIN_LIST
135 exec 5> $WORK/$TEST_LIST
136 for syllable in $(cat $WORK/$SYLLIST); do
137 for speaker in $(cat $WORK/$TRAIN_SPEAKERS); do
138 SOURCE_FILENAME=$SOUND_SOURCE/$syllable/${syllable}${speaker}.wav
139 DEST_FILENAME=$WORK/$FEATURES_DIR/$syllable/${syllable}${speaker}
140 echo "$SOURCE_FILENAME ${DEST_FILENAME}.htk" >&3
141 done
142 for speaker in $(cat $WORK/$TEST_SPEAKERS); do
143 SOURCE_FILENAME=$SOUND_SOURCE/$syllable/${syllable}${speaker}.wav
144 DEST_FILENAME=$WORK/$FEATURES_DIR/$syllable/${syllable}${speaker}
145 echo "$SOURCE_FILENAME ${DEST_FILENAME}.htk" >&5
146 done
147 done
148 exec 3>&-
149 exec 5>&-
150
151 # Make the necessary directories for the computed features
152 echo "Making directory structure..."
153 mkdir $WORK/$FEATURES_DIR
154 for syllable in $(cat $WORK/$SYLLIST); do
155 mkdir $WORK/$FEATURES_DIR/$syllable
156 done
157
158 # Write the AIMCopy config file
159 echo "Creating AIMCopy config file..."
160 cat <<"EOF" > $WORK/$AIMCOPY_CONFIG
161 input.buffersize=480
162 sai.frame_period_ms=10.0
163 slice.normalize=true
164 ssi.pitch_cutoff=true
165 ssi.weight_by_cutoff=false
166 ssi.weight_by_scaling=true
167 ssi.log_cycles_axis=true
168 EOF
169 echo "noise.level_db=$1" >> $WORK/$AIMCOPY_CONFIG
170
171 echo "Splitting data files..."
172 cat $WORK/${TRAIN_LIST} $WORK/${TEST_LIST} > $WORK/${COMBINED_LIST}
173
174 total_cores=$(($MACHINE_CORES))
175 echo -n $total_cores
176 echo " cores available"
177 total_files=`cat $WORK/${COMBINED_LIST} | wc -l | sed 's/ *//'`
178 echo -n $total_files
179 echo " files to process"
180 files_per_core=$(($total_files/$total_cores+1))
181 echo -n $files_per_core
182 echo " files per core"
183 split -l $files_per_core $WORK/${COMBINED_LIST} $WORK/split_list
184 splits=( $(ls $WORK/split_list*))
185 element=0
186 echo "Spawning tasks..."
187 for ((c=1;c<=$MACHINE_CORES;c+=1)); do
188 s=${splits[$element]}
189 ${AIMCOPY_PREFIX}AIMCopy -C $WORK/$AIMCOPY_CONFIG -S $s &
190 let element=element+1
191 done
192
193 echo "Waiting for tasks to complete..."
194 wait
195 echo "Done!"