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