upstream version 1.2.2
[debian/freetts] / tools / ArcticToFreeTTS / README.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
3 <!--
4
5 /**
6  * Copyright 2004 Sun Microsystems, Inc.
7  * 
8  * See the file "license.terms" for information on usage and
9  * redistribution of this file, and for a DISCLAIMER OF ALL 
10  * WARRANTIES.
11  */
12
13 -->
14
15 <html>
16     <head><title>CMU ARCTIC to FreeTTS</title></head>
17     <body>
18         <center>
19             <table bgcolor="#FFCC66" width="100%">
20                 <tr>
21                     <td align=center width="100%">
22                         <h1>CMU ARCTIC To FreeTTS</h1>
23                     </td>
24                 </tr>
25             </table>
26         </center>
27
28         <p>This page provides details on importing <a
29         href="http://festvox.org/cmu_arctic/">CMU ARCTIC</a> voices to
30         FreeTTS.  It has been tested on the awb, bdl, jmk, and slt
31         ARCTIC 0.95 voices.</p>
32
33          <p>Note that this is very preliminary
34         documentation meant to help those who are chomping at the bit
35         to get CMU ARCTIC voices into FreeTTS.  There is still some
36         work to do (e.g., the resulting voices do not sound exactly
37         like they do in Festival), but the work is ready for people to
38         give it a shot.</p>
39
40
41         <h3>Obtaining the CMU ARCTIC Voices</h3>
42         <p>Many many thanks to the folks behind the CMU ARCTIC
43         voices.  They have given the world a great wealth of 
44         knowledge and data.
45
46         <p>You can obtain a CMU ARCTIC voice from the
47         <a href="http://festvox.org/cmu_arctic/">CMU ARCTIC</a>
48         web site.  We've succesfully imported the bdl, slt, jmk,
49         and awb voices (note: the awb voice requires you do a 
50         little extra work - see the note at the end of this page).</p>
51
52         <p>As of the writing of this document (January 2005), we
53         have not attempted to create a CMU ARCTIC voice ourselves,
54         but expect the tools provided by FreeTTS will support
55         new CMU ARCTIC voices that you create.</p>
56
57
58         <h3>Preparing to Import a CMU ARCTIC Voice</h3>
59         <p>You need to have downloaded, built, and installed the
60         <a href="http://festvox.org/festival/index.html">Festival
61         Speech Synthesis System</a>.
62
63         <p>The script to import a CMU ARCTIC Voice is
64         tools/ArcticToFreeTTS/ArcticToFreeTTS.sh.  It is designed to
65         be run from the voice directory that contains the CMU ARCTIC
66         data.  Before running the script, you need to edit it to
67         ensure that the following variables are set specifically to
68         your environment:
69         <ul>
70             <li><code>JAVA_HOME</code> - points to your installation
71             of the Java platform.</li> 
72        
73             <li><code>ESTDIR</code> - points to the speech_tools
74             directory of the Festival installation.</li>
75
76             <li><code>FESTIVALDIR</code> - points to the festival
77             directory of the Festival installation.</li>
78
79             <li><code>FESTVOXDIR</code> - points to the festvox
80             directory of the FestVox installation.</li>
81
82             <li><code>FREETTSDIR</code> - points to the FreeTTS
83             directory of the FreeTTS installation.</li>
84         </ul> 
85         <p>At some point, we will probably make life a little
86         easier for you (or perhaps you'd like to make life easier for
87         us and submit your changes back to this open source effort),
88         but right now, please just edit the script.</p>
89
90         <h3>Importing a CMU ARCTIC Voice into FreeTTS</h3>
91         <p>The procedure for importing a CMU ARCTIC voice into FreeTTS
92         is rather simple:</p>
93         <ol>
94             <li>Make sure you've edited the
95             tools/ArcticToFreeTTS/ArcticToFreeTTS.sh script as
96             described above.
97             </li>
98             <li>Download the voice you'd like to import, and unpack
99                 it in a directory.  For example:
100                 <ul>
101                     <p><code>~/work/festival/custom_voices/cmu_us_slt_arctic</code>
102                 </ul>
103             </li>
104             <li>cd to the directory where you unpacked the voice.
105             The contents of this directory should look something like
106             the following:
107                 <ul>
108                     <pre>
109 AREADME         emu             festvox         pm
110 COPYING         etc             lab             pm_lab
111 README          f0              lpc             sts
112 bin             festival        mcep            wav
113                     </pre>
114                 </ul>
115             </li>
116             <li>Run the ArcticToFreeTTS.sh script:
117                 <ul>
118                     <p><code>~/work/SourceForge/FreeTTS/FreeTTS/tools/ArcticToFreeTTS/ArcticToFreeTTS.sh</code>
119                     </p>
120                 </ul>
121             </li>
122         </ol>
123
124         <p>The script will output a fair amount of information and
125         will take a fair amount of time to complete (about 1 hour on a
126         867MHz PowerBook G4 Mac OS X system).  The script creates a
127         new voice directory under your FreeTTS installation.  For
128         example, assume you imported the slt voice.  The script will
129         create the following contents in the following directory:
130         <ul>
131         <pre>
132 com/sun/speech/freetts/en/us/cmu_us_slt_arctic/
133
134 ArcticVoice.java                nums_cart.txt
135 ArcticVoiceDirectory.java       part_of_speech.txt
136 cmu_us_slt_arctic.txt           phoneset.txt
137 dur_stat.txt                    phrasing_cart.txt
138 durz_cart.txt                   prefix_fsm.txt
139 f0_lr_terms.txt                 suffix_fsm.txt
140 int_accent_cart.txt             voice.Manifest
141 int_tone_cart.txt
142         </pre>
143         </ul>
144
145         The script also compiles the voice for you and places the
146         resulting jar in the FreeTTS lib directory.  For example,
147         lib/cmu_us_slt_arctic.jar.  At this point, the voice is ready
148         to be used.  You can test the voice as follows.
149
150         <ol>
151            <li>Make sure the jar file is OK:
152                <ul>
153                <pre>
154 java -jar lib/cmu_us_slt_arctic.jar 
155
156 VoiceDirectory 'com.sun.speech.freetts.en.us.cmu_us_slt_arctic.ArcticVoiceDirectory'
157
158 Name: slt_arctic
159         Description: CMU ARCTIC Cluster Unit Voice
160         Organization: cmu
161         Domain: general
162         Locale: en_US
163         Style: standard
164         Gender: MALE
165         Age: YOUNGER_ADULT
166         Pitch: 100.0
167         Pitch Range: 12.0
168         Pitch Shift: 1.0
169         Rate: 150.0
170         Volume: 1.0
171                </pre>
172                </ul>
173            </li> 
174            <li>Test the voice using the freetts demo
175            application.  Note that the CMU ARCTIC voices are very
176            large.  As such, it may take several minutes before FreeTTS
177            has loaded the voice and made it ready for use.
178                <ul>
179                <pre>
180 java -mx512m -jar lib/freetts.jar -voice slt_arctic
181 Enter text: Hello.
182                </pre>
183                </ul>
184            </li>
185         </ol>
186         
187         <h3>Note on the AWB CMU ARCTIC Voice</h3>
188
189         <p>The AWB CMU ARCTIC voice uses a different unit selection
190         algorithm than the other CMU ARCTIC voices.  That is, whereas
191         the other CMU ARCTIC voices select units based upon phone,
192         stress, onset, and coda features, the AWB CMU ARCTIC voice
193         selects units based solely on phone and stress features.  As
194         such, the AWB CMU ARCTIC voice needs a little extra work to
195         import it to FreeTTS.</p>
196
197         <p>For one thing, the ArcticToFreeTTS tools expect the Scheme
198         for the ARCTIC voices to follow a particular pattern.  In
199         particular, the etc/voice.defs file defines a FV_FULLVOICENAME
200         variable that is built up from the various attributes of the
201         voice. The ArcticToFreeTTS tools expect there to be a file in
202         the festvox subdirectory whose name is the value of
203         FV_FULLVOICENAME with a ".scm" extension.  In this file, it is
204         expected that there will be a definition of the form
205         "voice_$FV_FULLVOICENAME" where $FV_FULLVOICENAME expands to
206         the value of FV_FULLVOICENAME.  
207
208         <p>All the ARCTIC voices except the AWB voice follow this
209         pattern.  The AWB voice, however, uses "f0clunits" as an
210         attribute for some of the types in etc/voice.defs.  <b>Before
211         importing</b>, you'll need to change all the occurrences of
212         "f0clunits" in the cmu_us_awb_arctic etc/voice.defs file to
213         "clunits" in order to match the pattern expected by the
214         ArcticToFreeTTS tools:
215
216         <ul>
217         <pre>
218 FV_INST=cmu
219 FV_LANG=us
220 FV_NAME=awb_arctic
221 FV_TYPE=clunits
222 FV_VOICENAME=$FV_INST"_"$FV_LANG"_"$FV_NAME
223 FV_FULLVOICENAME=$FV_VOICENAME"_"$FV_TYPE
224 FV_F0TYPE=clunits
225 FV_VOICENAME=$FV_INST"_"$FV_LANG"_"$FV_NAME
226 FV_FULLVOICENAME=$FV_VOICENAME"_"$FV_F0TYPE
227 FV_F0TYPE=clunits
228 FV_F0TYPE=clunits
229         </pre>
230         </ul>
231
232         <p>If you do not make this change, you'll see the following
233         error when you run the ArcticToFreeTTS tools.  The error will
234         occur very early in the ArcticToFreeTTS output, so if you are
235         not watching, you'll miss it.  You'll know you didn't make
236         this change, though, because you'll have empty dur_stat.txt
237         and durz_cart.txt files in the
238         com/sun/speech/freetts/en/us/cmu_us_awb_arctic/ directory that
239         was created when you ran the ArcticToFreeTTS tools:
240
241         <ul>
242         <pre>
243 SIOD ERROR: unbound variable : voice_cmu_us_awb_arctic_f0clunits
244         </pre>
245         </ul>
246
247         <p>Once you've made this change, you can run the
248         ArcticToFreeTTS tools to get the AWB data in FreeTTS form.
249
250         <p>Once you've imported the AWB data, you now need to modify
251         the ArcticVoice.java file that was created in
252         com/sun/speech/freetts/en/us/cmu_us_awb_arctic/ when you
253         imported the voice.  The modification tells the voice to use a
254         different unit selector, and requires that you override the
255         "getUnitSelector" method.  First, you'll need to add some
256         extra imports to the file:
257
258         <ul>
259            <pre>
260 import java.io.IOException;
261 import com.sun.speech.freetts.Item;
262 import com.sun.speech.freetts.UtteranceProcessor;
263 import com.sun.speech.freetts.clunits.ClusterUnitSelector;
264            </pre>
265         </ul>
266
267         <p>Next, you'll need to override the getUnitSelector method:
268
269         <ul>
270            <pre>
271     public UtteranceProcessor getUnitSelector() throws IOException {
272         return new AwbUnitSelector(getDatabase());
273     }
274            </pre>
275         </ul>
276  
277         <p>Finally, you'll need
278         to define the new unit selector.  This can be added as a
279         class at the end of the ArcticVoice.java file:
280         <ul>
281             <pre>
282 class AwbUnitSelector extends ClusterUnitSelector {
283     private static final String VOWELS = "aeiou";
284
285     public AwbUnitSelector(URL url) throws IOException {
286         super(url);
287     }
288
289     /**
290      * Sets the cluster unit name given the segment.
291      *
292      * @param seg the segment item that gets the name
293      */
294     protected void setUnitName(Item seg) {
295         String cname = null;
296
297         String segName = seg.getFeatures().getString("name");
298
299         /* If we have a vowel, then the unit name is the segment name
300          * plus a 0 or 1, depending upon the stress of the parent.
301          * Otherwise, the unit name is the segment name plus "coda"
302          * or "onset" based upon the seg_onsetcoda feature processor.
303          */
304         if (VOWELS.indexOf(segName.charAt(0)) >= 0) {
305             cname = segName + seg.findFeature("R:SylStructure.parent.stress");
306         } else {
307             cname = segName;
308         }
309         seg.getFeatures().setString("clunit_name", cname);
310     }
311 }
312             </pre>
313         </ul>
314
315         <p>Once you've made these changes to the ArcticVoice.java
316         file, you can rebuild the voice as follows:
317         <ul>
318             <p><code>ant -Darctic_voice=cmu_us_awb_arctic -find build.xml</code>
319         </ul>
320
321         <p>Good luck, and have fun.</p>
322         <hr>
323
324         <p>See the <a href="../../license.terms">license terms</a>
325         and <a href="../../acknowledgments.txt">acknowledgments</a>.
326         <br>
327         Copyright 2004 Sun Microsystems, Inc.  All Rights
328         Reserved.  Use is subject to license terms.</p>
329     </body>
330 </html>