2 # Portions Copyright 2004 Sun Microsystems, Inc.
3 # Portions Copyright 1999-2003 Language Technologies Institute,
4 # Carnegie Mellon University.
5 # All Rights Reserved. Use is subject to license terms.
7 # See the file "license.terms" for information on usage and
8 # redistribution of this file, and for a DISCLAIMER OF ALL
11 # Shell script to do a lot of the work to import a cluster
12 # unit selection voice into FreeTTS. This is still a work
15 # You should override these environment variables to match
19 export ESTDIR=/Users/wwalker/work/festival/speech_tools
20 export FESTIVALDIR=/Users/wwalker/work/festival/festival
21 export FESTVOXDIR=/Users/wwalker/work/festival/festvox
22 export FREETTSDIR=/Users/wwalker/work/SourceForge/FreeTTS/FreeTTS
24 export HELPERDIR=$FREETTSDIR/tools/ArcticToFreeTTS
26 export JAVAHEAP=-mx512m
31 # Compile the helping Java classes
33 (cd $HELPERDIR; mkdir -p classes; cd src; javac -d ../classes *.java)
38 # Get FV_VOICENAME and FV_FULLVOICENAME
42 echo Importing $FV_VOICENAME
44 export VOICEDIR=$FREETTSDIR/com/sun/speech/freetts/en/us/$FV_VOICENAME
52 # Import F0_MEAN (for setPitch) and F0_RANGE (for setPitchRange)
54 # [[[WDW FIXME: Currently unused.]]]
56 $FESTIVALDIR/bin/festival -b \
57 festvox/$FV_FULLVOICENAME.scm \
58 $HELPERDIR/scheme/dump_f0_terms.scm \
59 "(begin (voice_${FV_FULLVOICENAME}) (dump_f0_terms))" > \
67 ########################################################################
69 # Create voice-specific files that are not part of the big database. #
71 # [[[WDW FIXME: Currently copies some files from FreeTTS instead of #
72 # generating them directly from the voice data itself.]]] #
74 ########################################################################
76 echo Creating $VOICEDIR/dur_stat.txt
77 $FESTIVALDIR/bin/festival -b \
78 festvox/$FV_FULLVOICENAME.scm \
79 $HELPERDIR/scheme/dump_dur_stat.scm \
80 "(begin (voice_${FV_FULLVOICENAME}) (dump_dur_stat))" > \
81 $VOICEDIR/dur_stat.txt
86 echo Creating $VOICEDIR/durz_cart.txt
87 $FESTIVALDIR/bin/festival -b \
88 festvox/$FV_FULLVOICENAME.scm \
89 $HELPERDIR/scheme/dump_durz_cart.scm \
90 "(begin (voice_${FV_FULLVOICENAME}) (dump_durz_cart))" > \
91 $VOICEDIR/durz_cart.txt
96 echo Creating $VOICEDIR/f0_lr_terms.txt
97 cp $FREETTSDIR/com/sun/speech/freetts/en/us/f0_lr_terms.txt $VOICEDIR
102 echo Creating $VOICEDIR/int_accent_cart.txt
103 cp $FREETTSDIR/com/sun/speech/freetts/en/us/int_accent_cart.txt $VOICEDIR
108 echo Creating $VOICEDIR/int_tone_cart.txt
109 cp $FREETTSDIR/com/sun/speech/freetts/en/us/int_tone_cart.txt $VOICEDIR
114 echo Creating $VOICEDIR/nums_cart.txt
115 cp $FREETTSDIR/com/sun/speech/freetts/en/us/nums_cart.txt $VOICEDIR
120 echo Creating $VOICEDIR/part_of_speech.txt
121 $FESTIVALDIR/bin/festival -b \
122 festvox/$FV_FULLVOICENAME.scm \
123 $HELPERDIR/scheme/dump_pos.scm \
124 "(begin (voice_${FV_FULLVOICENAME}) (dump_pos))" > \
125 $VOICEDIR/part_of_speech.txt
130 echo Creating $VOICEDIR/phoneset.txt
131 $FESTIVALDIR/bin/festival -b \
132 festvox/$FV_FULLVOICENAME.scm \
133 $HELPERDIR/scheme/dump_phoneset.scm \
134 "(begin (voice_${FV_FULLVOICENAME}) (dump_phoneset))" > \
135 $VOICEDIR/phoneset.txt
140 echo Creating $VOICEDIR/phrasing_cart.txt
141 cp $FREETTSDIR/com/sun/speech/freetts/en/us/phrasing_cart.txt $VOICEDIR
146 echo Creating $VOICEDIR/prefix_fsm.txt
147 cp $FREETTSDIR/com/sun/speech/freetts/en/us/prefix_fsm.txt $VOICEDIR
152 echo Creating $VOICEDIR/suffix_fsm.txt
153 cp $FREETTSDIR/com/sun/speech/freetts/en/us/suffix_fsm.txt $VOICEDIR
158 ########################################################################
160 # Create voice-specific files that are part of the big database. #
161 # These will ultimately be concatenated together to make the big txt #
162 # file for the voice data. #
164 ########################################################################
166 echo Creating lpc files
168 bin/make_lpc wav/*.wav
173 echo Creating lpc/lpc.params
174 for file in lpc/*.lpc; do
175 $ESTDIR/bin/ch_track -otype est_ascii $file
176 done | sed '1,/EST_Header_End/d' |
177 awk 'BEGIN {min=0; max=0;} {
178 for (i=4; i<=NF; i++) {
179 if ($i < min) min = $i;
180 if ($i > max) max = $i;
183 printf("LPC_MIN=%f\n",min);
184 printf("LPC_MAX=%f\n",max);
185 printf("LPC_RANGE=%f\n",max-min);
191 echo Creating mcep/mcep.params and converting mcep files to text
192 for file in mcep/*.mcep; do
194 $ESTDIR/bin/ch_track -otype est_ascii $file > $file.txt
196 done | sed '1,/EST_Header_End/d' |
197 awk 'BEGIN {min=0; max=0;} {
198 for (i=4; i<=NF; i++) {
199 if ($i < min) min = $i;
200 if ($i > max) max = $i;
203 printf("MCEP_MIN=%f\n",min);
204 printf("MCEP_MAX=%f\n",max);
205 printf("MCEP_RANGE=%f\n",max-min);
206 }' > mcep/mcep.params
211 echo "Creating short term signal (STS) files in sts/*.sts"
213 java -cp $HELPERDIR/classes FindSTS \
214 `find wav -type f | cut -f2 -d/ | cut -f1 -d.`
219 echo Creating FreeTTS/misc.txt
220 $FESTIVALDIR/bin/festival -b \
221 festvox/$FV_FULLVOICENAME.scm \
222 $HELPERDIR/scheme/dump_misc.scm \
223 "(begin (voice_${FV_FULLVOICENAME}) (dump_misc))" > \
229 # UnitDatabase outputs its own info...
231 java $JAVAHEAP -cp $HELPERDIR/classes UnitDatabase \
232 festival/clunits/${FV_VOICENAME}.catalogue \
233 `find wav -type f | cut -f2 -d/ | cut -f1 -d.`
238 echo Creating FreeTTS/trees.txt
239 $FESTIVALDIR/bin/festival -b \
240 festvox/$FV_FULLVOICENAME.scm \
241 $HELPERDIR/scheme/dump_trees.scm \
242 "(begin (voice_${FV_FULLVOICENAME}) (dump_trees))" > \
248 echo Creating FreeTTS/weights.txt
249 $FESTIVALDIR/bin/festival -b \
250 festvox/$FV_FULLVOICENAME.scm \
251 $HELPERDIR/scheme/dump_join_weights.scm \
252 "(begin (voice_${FV_FULLVOICENAME}) (dump_join_weights))" > \
258 ########################################################################
260 # Now create the big database file and also set up the *.java files #
263 ########################################################################
265 echo Creating $VOICEDIR/$FV_VOICENAME.txt
266 (cd FreeTTS; cat misc.txt unit_catalog.txt trees.txt unit_index.txt sts.txt mcep.txt weights.txt > $VOICEDIR/$FV_VOICENAME.txt)
271 echo Creating $VOICEDIR/ArcticVoiceDirectory.java
272 cat $HELPERDIR/ArcticVoiceDirectory.java.template | \
273 sed "s/%FV_VOICENAME%/$FV_VOICENAME/g" | \
274 sed "s/%FV_NAME%/$FV_NAME/g" | \
275 sed "s/%FV_INST%/$FV_INST/g" > \
276 $VOICEDIR/ArcticVoiceDirectory.java
281 echo Creating $VOICEDIR/ArcticVoice.java
282 cat $HELPERDIR/ArcticVoice.java.template | \
283 sed "s/%FV_VOICENAME%/$FV_VOICENAME/g" | \
284 sed "s/%FV_NAME%/$FV_NAME/g" | \
285 sed "s/%FV_INST%/$FV_INST/g" > \
286 $VOICEDIR/ArcticVoice.java
291 echo Creating $VOICEDIR/voice.Manifest
292 cat $HELPERDIR/voice.Manifest.template | \
293 sed "s/%FV_VOICENAME%/$FV_VOICENAME/g" | \
294 sed "s/%FV_NAME%/$FV_NAME/g" | \
295 sed "s/%FV_INST%/$FV_INST/g" > \
296 $VOICEDIR/voice.Manifest
301 echo Compiling $FV_VOICENAME
302 (cd $FREETTSDIR; ant -Darctic_voice=$FV_VOICENAME)