Debian Codegraph @

doc/flite.texi

raw ◀ ▶
3 Debian patches touch this file
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename flite.info
4 @settitle Flite: a small, fast speech synthesis engine
•5 @dircategory sound
6 @direntry
7 flite: (flite). a small, fast speech synthesis engine
8 @end direntry
9 @finalout
10 @setchapternewpage odd
11 @c %**end of header
12
13 @c This document was modelled on the numerous examples of texinfo
14 @c documentation available with GNU software, primarily the hello
15 @c world example, but many others too. I happily acknowledge their
16 @c aid in producing this document -- awb
17
18 @set EDITION 2.0
19 @set VERSION 2.0
20 @set UPDATED 18th November 2014
21
22 @ifinfo
23 This file documents @code{Flite}, a small, fast run-time speech
24 synthesis engine.
25
26 Copyright (C) 2001-2014 Carnegie Mellon University
27
28 Permission is granted to make and distribute verbatim copies of
29 this manual provided the copyright notice and this permission notice
30 are preserved on all copies.
31
32 @ignore
33 Permission is granted to process this file through TeX, or otherwise and
34 print the results, provided the printed document carries copying
35 permission notice identical to this one except for the removal of this
36 paragraph (this paragraph not being relevant to the printed manual).
37
38 @end ignore
39 Permission is granted to copy and distribute modified versions of this
40 manual under the conditions for verbatim copying, provided that the entire
41 resulting derived work is distributed under the terms of a permission
42 notice identical to this one.
43
44 Permission is granted to copy and distribute translations of this manual
45 into another language, under the above conditions for modified versions,
46 except that this permission notice may be stated in a translation approved
47 by the authors.
48 @end ifinfo
49
50 @titlepage
51 @title Flite: a small, fast speech synthesis engine
52 @subtitle System documentation
53 @subtitle Edition @value{EDITION}, for Flite version @value{VERSION}
54 @subtitle @value{UPDATED}
55 @author by Alan W Black and Kevin A. Lenzo
56
57 @page
58 @vskip 0pt plus 1filll
59 Copyright @copyright{} 2001-2014 Carnegie Mellon University, all rights
60 reserved.
61
62 Permission is granted to make and distribute verbatim copies of
63 this manual provided the copyright notice and this permission notice
64 are preserved on all copies.
65
66 Permission is granted to copy and distribute modified versions of this
67 manual under the conditions for verbatim copying, provided that the entire
68 resulting derived work is distributed under the terms of a permission
69 notice identical to this one.
70
71 Permission is granted to copy and distribute translations of this manual
72 into another language, under the above conditions for modified versions,
73 except that this permission notice may be stated in a translation approved
74 by the Carnegie Mellon University
75 @end titlepage
76
77 @node Top, , , (dir)
78
79 @menu
80 * Abstract:: initial comments
81 * Copying:: How you can copy and share the code
82 * Acknowledgements:: List of contributors
83 * Installation:: Compilation and Installation
84 * Flite Design::
85 * APIs:: Standard functions
86 * Converting FestVox Voices:: building flite voices from FestVox ones
87
88 @end menu
89
90 @node Abstract, Copying, , Top
91 @chapter Abstract
92
93 This document provides a user manual for flite, a small, fast
94 run-time speech synthesis engine.
95
96 This manual is nowhere near complete.
97
98 Flite offers text to speech synthesis in a small and efficient binary.
99 It is designed for embedded systems like PDAs as well large server
100 installation which must serve synthesis to many ports. Flite is part
101 of the suite of free speech synthesis tools which include Edinburgh
102 University's Festival Speech Synthesis System
103 @url{http://www.festvox.org/festival} and Carnegie
104 Mellon University's FestVox project @url{http://festvox.org}, which
105 provides tools, scripts, and documentation for building new synthetic
106 voices.
107
108 Flite is written in ANSI C, and is designed to be portable
109 to almost any platform, including very small hardware.
110
111 Flite is really just a synthesis library that can be linked into other
112 programs, it includes two simple voices with the distribution, an old
113 diphone voice and an example limited domain voice which uses the newer
114 unit selection techniques we have been developing. Neither of these
115 voices would be considered production voices but serve as examples, new
116 voices will be released as they are developed.
117
118 The latest versions, comments, new voices etc for Flite are available
119 from its home page which may be found at
120 @example
121 @url{http://cmuflite.org}
122 @end example
123
124 @node Copying, Acknowledgements, Abstract, Top
125 @chapter Copying
126
127 Flite is free software. It is distributed under an X11-like license.
128 Apart from the few exceptions noted below (which still have
129 similarly open licenses) the general license is
130 @example
131 Language Technologies Institute
132 Carnegie Mellon University
133 Copyright (c) 1999-2014
134 All Rights Reserved.
135
136 Permission is hereby granted, free of charge, to use and distribute
137 this software and its documentation without restriction, including
138 without limitation the rights to use, copy, modify, merge, publish,
139 distribute, sublicense, and/or sell copies of this work, and to
140 permit persons to whom this work is furnished to do so, subject to
141 the following conditions:
142 1. The code must retain the above copyright notice, this list of
143 conditions and the following disclaimer.
144 2. Any modifications must be clearly marked as such.
145 3. Original authors' names are not deleted.
146 4. The authors' names are not used to endorse or promote products
147 derived from this software without specific prior written
148 permission.
149
150 CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK
151 DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
152 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
153 SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE
154 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
155 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
156 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
157 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
158 THIS SOFTWARE.
159 @end example
160
161 @node Acknowledgements, Installation, Copying, Top
162 @chapter Acknowledgements
163
164 The initial development of flite was primarily done by awb while
165 travelling, perhaps the name is doubly appropriate as a substantial
166 amount of the coding was done over 30,000ft). During most of that
167 time awb was funded by the Language Technologies Institute at
168 Carnegie Mellon University.
169
170 Kevin A. Lenzo was involved in the design, conversion techniques and
171 representations for the voice distributed with flite (as well as being
172 the actual voice itself).
173
174 Other contributions are:
175 @itemize @bullet
176 @item Nagoya Institute of Technology
177 The MLSA, MLPG code comes directly NITECH's hts engine code, though we
178 have done some optimizations.
179 @item Marcela Charfuelan (DFKI)
180 For the mixed-excitation techniques (but no direct code). These
181 originally came from NITECH but we understood the techniques from
182 Marcela's Open Mary Java code and implemented them in our optimized
183 version of MLSA.
184 @item David Huggins-Daines:
185 much of the very early clunits code, porting to multiple platforms,
186 substantial code tidy up and configure/autoconf guidance (up to 2001).
187 @item Cepstral, LLC (@url{http://cepstral.com}):
188 For supporting DHD to spend time (in early 2001) on flite and passing
189 back the important fixes and enhancements while on a project funded by
190 the Portuguese Foundation for Science and Technology (FCT) Praxis XXI
191 program specifically to produce an open source synthesizer.
192 @item Willie Walker <william.walker@@sun.com> and the Sun Speech Group:
193 lots of low level bugs (and fixes).
194 @item Henry Spencer:
195 For the regex code
196 @item University of Edinburgh:
197 for releasing Festival for free, making a companion runtime synthesizer
198 a practical project, much of the design of flite relies on the
199 architecture decisions made in the Festival Speech Synthesis Systems and
200 the Edinburgh Speech Tools.
201
202 The duration cart tree and intonation (accent and F0) models for the
203 US English voice were derived from the models in the Festival
204 distribution. which in turn were trained from the Boston University FM
205 Radio Data Corpus.
206
207 @item Carnegie Mellon University
208 The included lexicon is derived from CMULEX and the letter to sound
209 rules are constructed using the Lenzo and Black techniques for
210 building LTS decision graphs.
211 @item Craig Reese: IDA/Supercomputing Research Center and Joe Campbell: Department of Defense
212 who wrote the ulaw conversion routines in src/speech/cst_wave_utils.c
213 @end itemize
214
215
216 @node Installation, Flite Design, Acknowledgements, Top
217 @chapter Installation
218
219 Flite consist simple of a set of C files. GNU configure is
220 used to configure the engine and will work on most
221 major architectures.
222
223 In general, the following should build the system
224 @example
225 tar zxvf flite-XXX.tar.gz
226 cd flite-XXX
227 ./configure
228 make
229 @end example
230 However you will need to explicitly call GNU make
231 @code{gmake} if @code{make} is not GNU make on your system.
232
233 The configuration process build a file @file{config/config} which under
234 some circumstances may need to be edited, e.g. to add unusual options or
235 dealing with cross compilation.
236
237 On Linux systems, we also support shared libraries which are useful for
238 keeping space down when multiple different application are linked to the
239 flite libraries. For development we strongly discourage use of shared
240 libraries as it is too easy to either not set them up correctly or
241 accidentally pick up the wrong version. But for installation they are
242 definitely encouraged. That is if you are just going to make and
243 install they are good but unless you know what @var{LD_LIBRARY_PATH}
244 does, it may be better to use static libraries (the default) if you are
245 changing C code or building your own voices.
246 @example
247 ./configure --enable-shared
248 make
249 @end example
250 This will build both shared and static versions of the libraries but
251 will link the executables to the @emph{shared} libraries thus you will
252 need to install the libraries in a place that your dynamic linker will
253 find them (cf. /etc/ld.so.conf) or set @var{LD_LIBRARY_PATH}
254 appropriately.
255
256 @example
257 make install
258 @end example
259 Will install the binaries (@file{bin/flite*}), include files and
260 libraries in appropriate subdirectories of the defined install
261 directory, @file{/usr/local} by default. You can change this at configure
262 time with
263 @example
264 ./configure --prefix=/opt
265 @end example
266
267 @section Windows Support
268
269 @section Window CE Support
270
271 @emph{NOTE: as Windows CE is somewhat rare now, we do not guarantee this
272 still works.}
273
274 Flite has been successfully compiled by a number of different groups
275 under Windows CE. The system should compile under Embedded Visual
276 Studio but we not have the full details.
277
278 The system as distributed does compile under the gcc @file{mingw32ce}
279 toolchain available from @url{http://cegcc.sourceforge.net/}. The
280 current version can be compiled and run under WinCE with a primitive
281 application called @file{flowm}. @file{flowm} is a simple application
282 that allows playing of typed-in text, or full text to speech on
283 a file. Files should be a simple ascii text files @code{*.txt}. The
284 application allows the setting of the byte position to start synthesis
285 from.
286
287 Assuming you have @file{mingw32ce} installed you can configure as
288 @example
289 ./configure --target=arm-wince
290 make
291 @end example
292 The resulting binary is given in @file{wince/flowm.exe}. If you copy
293 this onto your Windows Mobile device and run it, it should allow you
294 to speak typed-in text and any @file{*.txt} files you have on your
295 device.
296
297 The application uses @code{cmu_us_kal} as the voice for default.
298 Although it is possible to include the clustergen voices, they may be
299 too slow to be really practical. An 8KHz clustergen voice with a
300 reduced order to 13 gives a voices that runs acceptably on an hp2755
301 (624MHz) but still marginal on an AT&T Tilt (400MHz).
302
303 Building 8KHz clustergen voices is currently a bit of hack. We take the
304 standard waveforms and resample them to 8KHz, then relabel the sample
305 rate to be 16KHz. Then build the voice as normal (as if the speaker
306 spoke twice as fast. You may need to have tune the F0 parameters in
307 @file{etc/f0.params}. This seems to basically work. Then after the
308 waveform is synthesized (still in the "chipmunk'' domain) we then
309 playit back at 8KHz. This effectively means we generate half the
310 number of samples and the frames are really at 10ms. A second
311 reduction is an option on the basic @file{build_flite} command. A
312 second argument can specify order reduction, thus instead of the
313 standard 25 static parameters (plus its deltas) we can reduce this to
314 13 and still get acceptable results
315 @example
316 ./bin/build_flite cg 13
317 cd flite
318 make
319 @end example
320 Importantly this uses less space, and uses less time to synthesis.
321 These @code{SPEECH_HACKS} in @file{src/cg/cst_mlsa.c} are switched on
322 by default when @code{UNDER_CE} is defined.
323
324 The reduced order properly extracts the statics (and stddev) and
325 deltas (and stddev) from the predicted parameter clusters and makes it
326 as if those were the sizes of parameters that were used to the train
327 the voice.
328
329 @section PalmOS Support
330
331 @emph{NOTE: as PalmOS is somewhat rare now, we do not guarantee this
332 still works.}
333
334 Support for PalmOS was removed from 1.9, I no longer have any working
335 PalmOS devices. But this section remains for people who do, but they
336 may need to update something to make this work.
337
338 Starting with 1.3 we have initial support for PalmOS using the free
339 development tools. The compilation method assumes the target device
340 is running PalmOS 5.0 (or later) on an ARM processor. Following
341 convention in the Palm world, the app that the user interacts with is
342 actually a m68k application compiled with the m68 gcc cross compiler,
343 the resulting code is interpreted by the PalmOS 5.0 device. The core
344 flite code is in native ARM, and hence uses the ARM gcc cross
345 compiler. An interesting amout of support code is required to
346 get all this work properly.
347
348 The user app is called @code{flop} (FLite on Palm) and like most apps
349 written by awb, is functional, but ugly. You should not let a
350 short-sighted Scotsman, who still thinks command line interfaces are
351 cool, design a graphical app. But it does work and can read typed-in
352 text. The @file{armflite.ro} resources are designed with the idea
353 that proper applications will be written using it as a library.
354
355 The @file{flop.prc} application is distributed separately so it can be used
356 without having to install all these tools. But if you want to PalmOS
357 development here is what you need to do to compile Flite for PalmOS and
358 the flop application.
359
360 There are number of different application development environments for
361 Palm, here I only describe the Unix based one as this is what was
362 used. You will need the PalmOS SDK 5.0 from palmOne
363 @url{http://www.palmone.com/us/developers/}. This is
364 free but does require registration. Out of the lots of different
365 files you can get for palmOne you will eventually find
366 @file{palmos-sdk-5.0r3-1.noarch.rpm}, install that on your linux
367 machine
368 @example
369 rpm -i palmos-sdk-5.0r3-1.noarch.rpm
370 @end example
371 You will also need the various gcc based cross compilers
372 @url{http://prc-tools.sourceforge.net/}
373 @example
374 prc-tools-2.3-1.i386.rpm
375 prc-tools-arm-2.3-1.i386.rpm
376 prc-tools-htmldocs-2.3-1.noarch.rpm
377 @end example
378 The Palm Resource compiler
379 @url{http://pilrc.sourceforge.net/}
380 @example
381 pilrc-3.1-1.i386.rpm
382 @end example
383 And maybe the emulator
384 @url{http://www.palmos.com/dev/tools/emulator/}
385 @example
386 pose-3.5-2.i386.rpm
387 pose-skins-1.9-1.noarch.rpm
388 pose-skins-handspring-3.1H4-1.noarch.rpm
389 @end example
390 Though as POSE doesn't support ARM code, @file{Simulator} does but
391 that only works under Windows, POSE is only useful for debugging the
392 m68k parts of the app.
393
394 Install these
395 @example
396 rpm -i prc-tools-2.3-1.i386.rpm
397 rpm -i prc-tools-arm-2.3-1.i386.rpm
398 rpm -i prc-tools-htmldocs-2.3-1.noarch.rpm
399 rpm -i pilrc-3.1-1.i386.rpm
400 rpm -i pose-3.5-2.i386.rpm
401 rpm -i pose-skins-1.9-1.noarch.rpm
402 rpm -i pose-skins-handspring-3.1H4-1.noarch.rpm
403 @end example
404 We also need the prc-tools to know which SDK is available
405 @example
406 palmdev-prep
407 @end example
408 In addition we use Greg Parker's PEAL
409 @url{http://www.sealiesoftware.com/peal/} ELF ARM loader. You need to
410 download this and compile and install it yourself, so that
411 @code{peal-postlink} is in your path. Greg was very helpful and even
412 added support for large data segments for this work (though in the end
413 we don't actually use them). Some peal code is in our distribution
414 (which is valid under his licence) but if you use a different version
415 of peal you may need to ensure they are matched, by updating
416 the peal code in @file{palm/}. We used version @file{peal-2004-12-29}.
417
418 The other palm specific function we require is @code{par}
419 @url{http://www.djw.org/product/palm/par/} which is part of the
420 @code{prc.tgz} distribution. We use @code{par} to construct resources
421 from raw binary files. There are other programs that can do this but
422 we found this one adequate. Again you must compile this and ensure
423 @code{par} is in your path. Note no part of @code{par} ends up
424 in the distributed system.
425
426 Given all of the above you should be able to compile the
427 Palm code and the @code{flop} application.
428 @example
429 ./configure --target=arm-palmos
430 make
431 @end example
432 The resulting application should be in @file{palm/flop/flop.prc}
433 which can then be installed on your Plam device
434 @example
435 pilot-xfer -i palm/flop/flop.prc
436 @end example
437 Setting up the tools, and getting a working Linux/Palm conduit is not
438 particularly easy but it is possible. Although some attempt was made
439 to use the Simulator, (PalmOS 5.0/ARM simulator) under Windows, it
440 never really contributed to the development. The POSE (m68k) emulator
441 though was use to develop the @code{flop} application itself.
442
443 @subsection Some notes on the PalmOS port
444
445 Throughout the PalmOS developer documentation they continually remind
446 you that a Palm device is not a full computer, its an extention of the
447 desktop. But seeing devices like the Treo 600 can easily make one
448 forget and want the device to do real computational work. PalmOS is
449 designed for small light weight devices so it is easy to start hitting
450 the boundaries of its capabilities when trying to port larger
451 aplications.
452
453 PalmOS5.0 still has interesting limitations, in the m68k domain,
454 @code{int}'s are 16 bit and using memory segments greater than 65K
455 require special work. Quaint as these are, they do significantly
456 affect the port. At first we thought that only the key
457 computationally expensive parts would be in ARM (so-called
458 @code{armlets}) but trying to compile the whole flite code in m68k
459 with long/short distinctions and sub-64K code segment limitations was
460 just too hard.
461
462 Thus all the Flite code, USEnglish, Lexicon and diphone databases
463 actually are compiled in the ARM domain. There is however no system
464 support in the ARM domain so call backs to m68k system functions are
465 necessary. With care calls to system functions can be significantly
466 limited so only a few call backs needed to be written. These are in
467 @file{palm/pocore/}. I believe CodeWarrior has better support for
468 this, but in this case we rolled our own (though help from other open
469 source examples was important).
470
471 We manage the m68k/ARM interface through PEAL, which is basically a
472 linker for ARM code and calling mechanism from m68k. PEAL deals with
473 globals and spliting the code into 65K chunks automatically.
474
475 Flite does however have a number of large data segments, in the
476 lexicon and the voice database itself. PEAL can deal with this but it
477 loads large segments by copying them into the dynamic heap, which on
478 most Palm device is less than 2M. This isn't big enough.
479
480 Thus we changed Flite to restrict the number of large data sgements it
481 used (and also did some new compression on them). The five segments: the
482 lts rules, the lexical entries, the voice LPC coefficients, the voice
483 residuals and the voice residual index are now treated a data segments
484 that are split into 65400 sized segments and loaded into feature
485 memory space, which is in the storage heap and typically much bigger.
486 This means we do need about 2-3 megabyte free on the device to run.
487 We did look into just indexing the 65400 byte segments directly but
488 that looked like being too much work, and we're only going to be able
489 to run on 16M sized Palms anyway (there aren't any 8M ARM Palms with
490 audio, expect maybe some SmartPhones).
491
492 Using Flite from m68k land involves getting a @code{flite_info}
493 structure from @code{flite_init()}. This contains a bunch of fields
494 that be set and sent to the ARM domain Flite synthesizer proper within
495 which other output fields may be set and returned. This isn't a very
496 general structure, but is adequate. Note the necessary byte swapping
497 (for the top level fileds) is done for the this structure, before
498 calling the ARM native @code{arm_flite_synth_text} and swapped back
499 again after returning.
500
501 Display, playing audio, pointy-clicky event thingies are all done in
502 the m68K domain.
503
504 @subsection Using the PalmOS
505
506 There are three basic functions that access the ARM flite
507 functions: @code{flite_init()}, @code{flite_synth_text()} and
508 @code{flite_end()}.
509
510 @node Flite Design, APIs, Installation, Top
511 @chapter Flite Design
512
513 @section Background
514
515 Flite was primarily developed to address one of the most common
516 complaints about the Festival Speech Synthesis System. Festival is
517 large and slow, even with the software bloat common amongst most
518 products and that that bloat has helped machines get faster, have more
519 memory and large disks, still Festival is criticized for its size.
520
521 Although sometimes this complaint is unfair, it is valid and although
522 much work was done to ensure Festival can be trimmed and run fast it
523 still requires substantial resources per utterance to run. After some
524 investigation to see if Festival itself could be trimmed down it became
525 clear because there was a core set of functions that were sufficient for
526 synthesis that a new implementation containing only those aspects that
527 were necessary would be easier than trimming down Festival itself.
528
529 Given that a new implementation was being considered a number of
530 problems with Festival could also be addressed at the same time.
531 Festival is not thread-safe, and although it runs under Windows, in
532 server mode it relies on the Unix-centric view of fast forks with
533 copy-on-write shared memory for servicing clients. This is a perfectly
534 safe and practical solution for Unix systems, but under Windows where
535 threads are the more common feature used for servicing multiple events
536 and forking is expensive, a non-thread safe program can't be used as
537 efficiently.
538
539 Festival is written in C++ which was a good decision at the time and
540 perfectly suitable for a large program. However what was discovered
541 over the years of development is that C++ is not a portable language.
542 Different C++ compilers are quite different and it takes significant
543 amount of work to ensure compatibility of the code base over multiple
544 compilers. What makes this worse is that new versions of each compiler
545 are incompatible and changes are required. At first this looked like we
546 were producing bad quality code but after 10 years it is clear that it is
547 also that the compilers are still maturing. Thus it is clear that
548 Festival and the Edinburgh Speech Tools will continue to require
549 constant support as new versions of compilers are released.
550
551 A second problem with C++ is the size and efficiency of the code
552 produced. Proponents of C++ may rightly argue that Festival and the
553 Edinburgh Speech Tools aren't properly designed, but irrespective if
554 that is true or not, it is true that the size of the code is much larger
555 and slower than it need be for what it does. Throughout the design
556 there is a constant trade-off between elegancy and efficiency which
557 unfortunately at times in Festival requires untidy solutions of
558 copying data out of objects processing it and copying back because
559 direct access (particularly in some signal processing routines)
560 is just too inefficient.
561
562 Another major criticism of Festival is the use of Scheme as the
563 interpreter language. Even though it is a simple to implement language
564 that is adequate for Festival's needs and can be easily included in the
565 distribution, people still hate it. Often these people do learn to use
566 it and appreciate how run time configurability is very desirable and that
567 new voices may be added without recompilation. Scheme does have garbage
568 collection which makes leaky programs much harder to write and as some
569 of the intended audience for developing in Festival will not be hard
570 core programmers a safe programming language seems very desirable.
571
572 After taking into consideration all of the above it was decided to
573 develop Flite as a new system written in ANSI C. C is much more
574 portable than C++ as well as offering much lower level control of the
575 size of the objects and data structure it uses.
576
577 Flite is not intended as a research and development platform for speech
578 synthesis, Festival is and will continue to be the best platform for
579 that. Flite however is designed as a run-time engine when an
580 application needs to be delivered. It specifically addresses two
581 communities. First as a engine for small devices such as PDAs and
582 telephones where the memory and CPU power are limited and in some cases do
583 not even have a conventional operating system.
584
585 The second community is for those running synthesis servers for many
586 clients. Here although large fixed databases are acceptable, the size
587 of memory required per utterance and speed in which they can be
588 synthesized is crucial.
589
590 However in spite of the decision to build a new synthesis engine we see
591 this as being tightly coupled into the existing free software synthesis
592 tools or Festival and the FestVox voice building suite. Flite offers
593 a companion run-time engine. Our intended mode of development is
594 to build new voices in FestVox and debug and tune them in Festival.
595 Then for deployment the FestVox format voice may be (semi-)automatically
596 compiled into a form that can be used by Flite.
597
598 In case some people feel that development of a small run-time
599 synthesizer is not an appropriate thing to do within a University and is
600 more suited to commercial development, we have a few points which they
601 should be aware of that to our mind justify this work.
602
603 We have long felt that research in speech and language should have an
604 identifiable link to ultimate commercial use. In providing a platform
605 that can be used in consumer products that falls within the same
606 framework as our research we can better understand what research issues
607 are actually important to the improvement our work.
608
609 In considering small useful synthesizers it forces a more explicit
610 definition of what is necessary in a synthesizer and also how we can
611 trade size, flexibility and speed with the quality of synthesized
612 output. Defining that relationship is a research issue.
613
614 We are also advocates of speech technology within other research areas
615 and the ability to offer support on new platforms such as PDAs and
616 wearables allows for more interesting speech applications such as
617 speech-to-speech translation, robots, and interactive personal digital
618 assistants, that will prove new and interesting areas of research.
619 Thus having a platform that others around us can more easily integrate
620 into their research makes our work more satisfying.
621
622 @section Key Decisions
623
624 The basic architecture of Festival is good. It is well proven. Paul
625 Taylor, Alan W. Black and Richard Caley spent many hours debating low
626 level aspects of representation and structure that would both be
627 adequate for current theories but also allow for future theories too.
628 The heterogeneous relation graphs (HRG) are theoretically adequate,
629 computationally efficient and well proven. Thus both because HRGs have
630 such a background and that Flite is to be compatible with voices and
631 models developed in Festival, Flite uses HRGs as its basic utterance
632 representation structure.
633
634 Most of a synthesizer is in its data (lexicons, unit database etc),
635 the actual synthesis code is pretty small. In Festival most of that
636 data exists in external files which are loaded on demand. This is
637 obviously slow and memory expensive (you need both a copy on the data
638 on disk and in memory). As one of the principal targets for Flite is
639 very small machines we wanted to allow that core data to be in ROM,
640 and be appropriately mapped into RAM without any explicit loading
641 (some OS's call this XIP -- execute in place). This can be done by
642 various memory mapping functions (in Unix its called mmap) and is the
643 core technique used in shared libraries (called DLLs in some parts of
644 the world). Thus the data should be in a format that it can be
645 directly accessed. If you are going to directly access data you need
646 to ensure the byte layout is appropriate for the architecture you are
647 running on, byte order and address width become crucial if you want to
648 avoid any extra conversion code at access time (like byte swapping).
649
650 At first is was considered that synthesis data would be converted in
651 binary files which could be mmap'ed into the runtime systems but
652 building appropriate binaries files for architectures is quite a job.
653 However the C compiler does this in a standard way. Therefore the mode
654 of operation for data within Flite is to convert it to C code (actually
655 C structures) and use the C compiler to generate the appropriate binary
656 structures.
657
658 Using the C compiler is a good portable solution but it as these
659 structures can be very big this can tax the C compiler somewhat. Also
660 because this data is not going to change at run time it can all be
661 declared @code{const}. Which means (in Unix) it will be in the text
662 segment and hence read only (this can be ROM on platforms which have
663 that distinction). For structures to be const all their subparts
664 must also be const thus all relevant parts must be in the same file,
665 hence the unit databases files can be quite big.
666
667 Of course, this all presumes that you have a C compiler robust enough to
668 compile these files, hardware smart enough to treat flash ROM as memory
669 rather than disk, or an operating system smart enough to demand-page
670 executables. Certain "popular" operating systems and compilers fail in
671 at least one of these respects, and therefore we have provided the
672 flexibility to use memory-mapped file I/O on voice databases, where
673 available, or simply to load them all into memory.
674
675 @chapter Structure
676
677 The flite distribution consists of two distinct parts:
678 @itemize @bullet
679 @item The flite library containing the core synthesis code
680 @item Voice(s) for flite. These contain three sub-parts
681 @itemize @bullet
682 @item Language models:
683 text processing, prosody models etc.
684 @item Lexicon and letter to sound rules
685 @item Unit database and voice definition
686 @end itemize
687 @end itemize
688
689 @section cst_val
690
691 This is a basic simple object which can contain ints, floats, strings
692 and other objects. It also allows for lists using the Scheme/Lisp,
693 car/cdr architecture (as that is the most efficient way to represent
694 arbitrary trees and lists).
695
696 The @code{cst_val} structure is carefully designed to take up only 8 bytes (or
697 16 on a 64-bit machine). The multiple union structure that it can
698 contain is designed so there are no conflicts. However it depends on
699 the fact that a pointer to a @code{cst_val} is guaranteed to lie on a even
700 address boundary (which is true for all architectures I know of). Thus
701 the distinction between between cons (i.e. list) objects and atomic
702 values can be determined by the odd/evenness of the least significant bits
703 of the first address in a @code{cst_val}. In some circles this is considered
704 hacky, in others elegant. This was done in flite to ensure that the most
705 common structure is 8 bytes rather than 12 which saves significantly on
706 memory.
707
708 All @code{cst_val}'s except those of type cons are reference counted. A
709 few functions generate new lists of @code{cst_val}'s which the user
710 should be careful about as they need to explicitly delete them (notably
711 the lexicon lookup function that returns a list of phonemes).
712 Everything that is added to an utterance will be deleted (and/or
713 dereferenced) when the utterance is deleted.
714
715 Like Festival, user types can be added to the @code{cst_val}s. In
716 Festival this can be done on the fly but because this requires the
717 updating of some list when each new type is added, this wouldn't be
718 thread safe. Thus an explicit method of defining user types is done in
719 @file{src/utils/cst_val_user.c}. This is not as neat as defining on the
720 fly or using a registration function but it is thread safe and these
721 user types won't change often.
722
723 @node APIs, Converting FestVox Voices, Flite Design, Top
724 @chapter APIs
725
726 Flite is a library that we expected will be embedded into other
727 applications. Included with the distribution is a small example
728 executable that allows synthesis of strings of text and text files
729 from the command line.
730
731 You may want to look at Bard @file{http://festvox.org/bard/}, an ebook
732 reader with a tight coupling to flite as a synthesizer. This is the
733 most elaborate use of the Flite API within our suite of programs.
734
735 @section flite binary
736
737 The example flite binary may be suitable for very simple applications.
738 Unlike Festival its start up time is very short (less than 25ms on a PIII
739 500MHz) making it practical (on larger machines) to call it each
740 time you need to synthesize something.
741 @example
742 flite TEXT OUTPUTTYPE
743 @end example
744 If @code{TEXT} contains a space it is treated as a string of text and
745 converted to speech, if it does not contain a space @code{TEXT} is
746 treated as a file name and the contents of that file are converted to
747 speech. The option @code{-t} specifies @code{TEXT} is to be treat
748 as text (not a filename) and @code{-f} forces treatment as a file.
749 Thus
750 @example
751 flite -t hello
752 @end example
753 will say the word "hello" while
754 @example
755 flite hello
756 @end example
757 will say the content of the file @file{hello}. Likewise
758 @example
759 flite "hello world."
760 @end example
761 will say the words "hello world" while
762 @example
763 flite -f "hello world"
764 @end example
765 will say the contents of a file @file{hello world}. If no argument is
766 specified text is read from standard input.
767
768 The second argument @code{OUTPUTTYPE} is the name of a file the output
769 is written to, or if it is @code{play} then it is played to the audio
770 device directly. If it is @code{none} then the audio is created but
771 discarded, this is used for benchmarking. If it is @code{stream} then
772 the audio is streamed through a call back function (though this is not
773 particularly useful in the command line version. If @code{OUTPUTTYPE}
774 is omitted, @code{play} is assumed. You can also explicitly set the
775 outputtype with the @code{-o} flag.
776 @example
777 flite -f doc/alice -o alice.wav
778 @end example
779
780 @section Voice selection
781
782 All the voices in the distribution are collected into a single simple
783 list in the global variable @code{flite_voice_list}. You can select a
784 voice from this list from the command line
785 @example
786 flite -voice awb -f doc/alice -o alice.wav
787 @end example
788 And list which voices are currently supported in the binary with
789 @example
790 flite -lv
791 @end example
792 The voices which get linked together are those listed in the
793 @code{VOICES} in the @file{main/Makefile}. You can change that as you
794 require.
795
796 Voices may also be dynamically loaded from files as well as built in.
797 The argument to the @code{-voice} option may be pathname to a dumped
798 (Clustergen) voice. This may be a Unix pathname or a URL (only protocols @file{http} and @file{file} are supported. For example
799 @example
800 flite -voice file://cmu_us_awb.flitevox -f doc/alice -o alice.wav
801 flite -voice http://festvox.org/voices/cmu_us_ksp.flitevox -f doc/alice -o alice.wav
802 @end example
803 Voices will be loaded once and added to @code{flite_voice_list}.
804 Although these voices are often small (a few megabytes) there will
805 still be some time required to read them in the first time. The
806 voices are not mapped, they are read into newly created structures.
807
808 This loading function is currently only supported for Clustergen
809 voices.
810
811 @section C example
812
813 Each voice in Flite is held in a structure, a pointer to which is
814 returned by the voice registration function. In the standard
815 distribution, the example diphone voice is @code{cmu_us_kal}.
816
817 Here is a simple C program that uses the flite library
818 @example
•819 #include <flite/flite.h>
820
821 cst_voice * register_cmu_us_kal(const char *voxdir);
822
823 int main(int argc, char **argv)
824 @{
825 cst_voice *v;
826
827 if (argc != 2)
828 @{
829 fprintf(stderr,"usage: flite_test FILE\n");
830 exit(-1);
831 @}
832
833 flite_init();
834
835 v = register_cmu_us_kal(NULL);
836
837 flite_file_to_speech(argv[1],v,"play");
838
839 @}
840 @end example
841 Assuming the shell variable FLITEDIR is set to the flite directory
842 the following will compile the system (with appropriate changes for
843 your platform if necessary).
844 @example
•845 gcc -Wall -g -o flite_test flite_test.c -I$FLITEDIR/include
846 -L$FLITEDIR/lib -lflite_cmu_us_kal -lflite_usenglish
847 -lflite_cmulex -lflite -lm
848 @end example
849
850 @section Public Functions
851
852 Although, of course you are welcome to call lower level functions,
853 there a few key functions that will satisfy most users
854 of flite.
855 @table @code
856 @item void flite_init(void);
857 This must be called before any other flite function can be called. As
858 of Flite 1.1, it actually does nothing at all, but there is no guarantee
859 that this will remain true.
860 @item cst_wave *flite_text_to_wave(const char *text,cst_voice *voice);
861 Returns a waveform (as defined in @file{include/cst_wave.h}) synthesized
862 from the given text string by the given voice.
863 @item float flite_file_to_speech(const char *filename, cst_voice *voice, const char *outtype);
864 synthesizes all the sentences in the file @file{filename} with given
865 voice. Output (at present) can only reasonably be, @code{play} or
866 @code{none}. If the feature @code{file_start_position} with an
867 integer, that point is used as start position in the file to be synthesized.
868 @item float flite_text_to_speech(const char *text, cst_voice *voice, const char *outtype);
869 synthesizes the text in string point to by @code{text}, with the given
870 voice. @code{outtype} may be a filename where the generated waveform is
871 written to, or "play" and it will be sent to the audio device, or
872 "none" and it will be discarded. The return value is the
873 number of seconds of speech generated.
874 @item cst_utterance *flite_synth_text(const char *text,cst_voice *voice);
875 synthesize the given text with the given voice and returns an utterance
876 from it for further processing and access.
877 @item cst_utterance *flite_synth_phones(const char *phones,cst_voice *voice);
878 synthesize the given phones with the given voice and returns an utterance
879 from it for further processing and access.
880 @item cst_voice *flite_voice_select(const char *name);
881 returns a pointer to the voice named @code{name}. Will retrurn
882 @code{NULL} if there is not match, if @code{name == NULL} then the
883 first voice in the voice list is returned. If @code{name} is a url
884 (starting with @file{file:} or @file{http:}, that file will be
885 accessed and the voice will be downloaded from there.
886 @item float flite_ssml_file_to_speech(const char *filename, cst_voice *voice, const char *outtype);
887 Will read the file as ssml, not all ssml tags are supported but many
888 are, unsupported ones are ignored. Voice selection works by naming
889 the internal name of the voice, or the name may be a url and the voice
890 will be loaded. The audio tag is supported for loading waveform files, again urls are supported.
891 @item float flite_ssml_text_to_speech(const char *text, cst_voice *voice, const char *outtype);
892 Will treat the text as ssml.
893 @item int flite_voice_add_lex_addenda(cst_voice *v, const cst_string *lexfile);
894 loads the pronunciations from @code{lexfile} into the lexicon
895 identified in the given voice (which will cause all other voices using
896 that lexicon to also get this new addenda list. An example lexicon
897 file is given in @file{flite/tools/examples.lex}. Words may be in
898 double quotes, an optional part of speech tag may be give. A colon
899 separates the headword/postag from the list of phonemes. Stress
900 values (if used in the lexicon) must be specified. Bad phonemes will
901 be complained about on standard out.
902 @end table
903
904 @section Streaming Synthesis
905
906 In 1.4 support was added for streaming synthesis. Basically you may
907 provide a call back function that will be called with waveform data
908 immediately when it is available. This potentially can reduce the
909 delay between sending text to the synthesized and having audio
910 available.
911
912 The support is through a call back function of type
913 @example
914 int audio_stream_chunk(const cst_wave *w, int start, int size,
915 int last, cst_audio_streaming_info *asi)
916 @end example
917 If the utterance feature @code{streaming_info} is set (which can
918 be set in a voice or in an utterance). The LPC or MLSA resynthesis
919 functions will call the provided function as buffers become available.
920 The LPC and MLSA waveform synthesis functions are used for diphones,
921 limited domain, unit selection and clustergen voices. Note explicit
922 support is required for streaming so new waveform synthesis function
923 may not have the functionality.
924
925 An example streaming function is provided in
926 @file{src/audio/au_streaming.c} and is used by the example flite main
927 program when @code{stream} is given as the playing option. (Though in
928 the command line program the function it isn't really useful.)
929
930 In order to use streaming you must provide call back function in your
931 particular thread. This is done by adding features to the voice in
932 your thread. Suppose your function was declared as
933
934 @example
935 int example_audio_stream_chunk(const cst_wave *w, int start, int size,
936 int last, void *user)
937 @end example
938 You can add this function as the streaming function through the statement
939 @example
940 cst_audio_streaming_info *asi;
941 ...
942 asi = new_audio_streaming_info();
943 asi->asc = example_audio_stream_chunk;
944 feat_set(voice->features,
945 "streaming_info",
946 audio_streaming_info_val(asi));
947 @end example
948 You may also optionally include your own pointer to any information
949 you additionally want to pass to your function. For example
950 @example
951 typedef my_callback_struct @{
952 cst_audiodev *fd;
953 int count;
954 @};
955 cst_audio_streaming_info *asi;
956
957 ...
958
959 mcs = cst_alloc(my_callback_struct,1);
960 mcs->fd=NULL;
961 mcs->count=1;
962
963 asi = new_audio_streaming_info();
964 asi->asc = example_audio_stream_chunk;
965 asi->userdata = mcs;
966 feat_set(voice->features,
967 "streaming_info",
968 audio_streaming_info_val(asi));
969 @end example
970 Another example is given in @file{testsuite/by_word_main.c} which
971 shows a call back funtion that also prints the token as it is being
972 synthesized. The @file{utt} field in the
973 @file{cst_audio_streaming_info} structure will be set to the current
974 utterance. Please note that the @file{item} field in the
975 @file{cst_audio_streaming_info} structure is for your convenience and
976 is not set by anyone at all. The previous sentence exists in the
977 documentation so that I can point at it, when user's fail to read it.
978
979 @node Converting FestVox Voices, , APIs, top
980 @chapter Converting FestVox Voices
981
982 As of 1.2 initial scripts have been added to aid the conversion of
983 FestVox voices to Flite. In general the conversion cannot be automatic.
984 For example all specific Scheme code written for a voice needs to be
985 hand converted to C to work in Flite, this can be a major task.
986
987 Simple conversion scripts are given as examples of the stages you need
988 to go through. These are designed to work on standard (English)
989 diphone sets, and simple limited domain voices. The conversion
990 technique will almost certainly fail for large unit selection voices
991 due to limitations in the C compiler (more discussion below). In 1.4
992 we have also added support for converting clustergen voices too (which
993 is a little easier, see section below).
994
995 @section Cocantenative Voice Building
996
997 Conversion is basically taking the description of units (clunit
998 catalogue or diphone index) and constructing some C files that can be
999 compiled to form a usable database. Using the C compiler to generate
1000 the object files has the advantage that we do not need to worry about
1001 byte order, alignment and object formats as the C compiler for the
1002 particular target platform should be able to generate the right code.
1003
1004 Before you start ensure you have successfully built and run your FestVox
1005 voice in Festival. Flite is not designed as a voice building/debugging
1006 tool it is just a delivery vehicle for finalized voices so you should
1007 first ensure you are satisfied with the quality of Festival voices
1008 before you start converting it for Flite.
1009
1010 The following basic stages are required:
1011 @itemize @bullet
1012 @item Setup the directories and copy the conversion scripts
1013 @item Build the LPC files
1014 @item Build the MCEP files (for ldom/clunits)
1015 @item Convert LPC (MCEP) into STS (short term signal) files
1016 @item Convert the catalogue/diphone index
1017 @item Compile the generated C code
1018 @end itemize
1019
1020 The conversion assumes the environment variable @code{FLITEDIR}
1021 is set, for example
1022 @example
1023 export FLITEDIR=/home/awb/projects/flite/
1024 @end example
1025 The basic flite conversion takes place within a FestVox voice directory.
1026 Thus all of the conversion scripts expect that the standard files are
1027 available. The first task is to build some new directories and copy in
1028 the build scripts. The scripts are copied rather than linked from the
1029 Flite directories as you may need to change these for your particular
1030 voices.
1031 @example
1032 $FLITEDIR/tools/setup_flite
1033 @end example
1034 This will read @file{etc/voice.defs}, which should have been created by
1035 the FestVox build process (except in very old versions of FestVox).
1036
1037 If you don't have a @file{etc/voice.defs} you can construct one
1038 with @code{festvox/src/general/guess_voice_defs} in the Festvox
1039 distribution, or generate one by hand making it look
1040 like
1041 @example
1042 FV_INST=cmu
1043 FV_LANG=us
1044 FV_NAME=ked_timit
1045 FV_TYPE=clunits
1046 FV_VOICENAME=$FV_INST"_"$FV_LANG"_"$FV_NAME
1047 FV_FULLVOICENAME=$FV_VOICENAME"_"$FV_TYPE
1048 @end example
1049
1050 The main script build building the Flite voice is @file{bin/build_flite}
1051 which will eventually build sufficient C code in @file{flite/} that can
1052 be compiled with the constructed @file{flite/Makefile} to give you a
1053 library that can be linked into applications and also an example
1054 @file{flite} binary with the constructed voice built-in.
1055
1056 You can run all of these stages, except the final make, together by
1057 running the the build script with no arguments
1058 @example
1059 ./bin/build_flite
1060 @end example
1061 But as things may not run smoothly, we will go through the
1062 stages explicitly.
1063
1064 The first stage is to build the LPC files, this may have already been
1065 done as part of the diphone building process (though probably not in
1066 the ldom/clunit case). In our experience it is very important that the
1067 records be of similar power, as mis-matched power can often cause
1068 overflows in the resulting flite (and sometimes Festival) voices. Thus,
1069 for diphone voices, it is important to run the power normalization
1070 techniques described int he FestVox document. The Flite LPC build
1071 process also builds a parameter file of the ranges of the LPC parameters
1072 used in later coding of the files, so even if you have already built your
1073 LPC files you should still do this again
1074 @example
1075 ./bin/build_flite lpc
1076 @end example
1077
1078 For ldom, and clunit voices (but not for diphone voices) we also
1079 need the Mel-frequency Cepstral Coefficients. These are assumed to
1080 have been cleared and are in @file{mcep/} as they are necessary
1081 for running the voice in Festival. This stage simply constructs
1082 information about the range of the mcep parameters.
1083 @example
1084 ./bin/build_flite mcep
1085 @end example
1086
1087 The next stage is to construct the STS files. Short Term Signals (STS)
1088 are built for each pitch period in the database. These are ascii files
1089 (one for each utterance file in the database, with LPC coefficients, and
1090 ulaw encoded residuals for each pitch period. These are built using a
1091 binary executable built as part of the Flite build
1092 (@file{flite/tools/find_sts}.
1093 @example
1094 ./bin/build_flite sts
1095 @end example
1096 Note that the flite code expects waveform files to be in Microsoft RIFF
1097 format and cannot deal with files in other formats. Some earlier
1098 versions of the Edinburgh Speech Tools used NIST as the default header
1099 format. This is likely to cause flite and its related programs not
1100 work. So do ensure your waveform files are in riff format (ch_wave -info
1101 wav/* will tell you the format). And the following fill convert
1102 all your wave files
1103 @example
1104 mv wav wav.nist
1105 mkdir wav
1106 cd wav.nist
1107 for i in *.wav
1108 do
1109 ch_wave -otype riff -o ../wav/$i $i
1110 done
1111 @end example
1112
1113 The next stage is to convert the index to the required C format. For
1114 diphone voices this takes the @file{dic/*.est} index files, for
1115 clunit/ldom voices it takes the @file{festival/clunit/VOICE.catalogue}
1116 and @file{festival/trees/VOICE.tree} files. This process uses a binary
1117 executable built as part of the Flite build process
1118 (@file{flite/tools/flite_sort}) to sort the indices into the same
1119 sorting order required for flite to run. (Using unix sort may or may
1120 not give the same result due to definitions of lexicographic order so
1121 we use the very same function in C that will be used in flite to ensure
1122 that a consistent order is given.)
1123 @example
1124 ./bin/build_flite idx
1125 @end example
1126 All the necessary C files should now have been built in @file{flite/}
1127 and you may compile them by
1128 @example
1129 cd flite
1130 make
1131 @end example
1132 This should give a library and an executable called @file{flite} that
1133 can run as
1134 @example
1135 ./flite "Hello World"
1136 @end example
1137 Assuming a general voice. For ldom voices it will only be able to say
1138 things in its domain. This @file{flite} binary offers the same options
1139 as standard the standard @file{flite} binary compiled in the Flite build
1140 but with your voice rather than the distributed voices.
1141
1142 Almost certainly this process will not run smoothly for you. Building
1143 voices is still a very hard thing to do and problems will probably
1144 exist.
1145
1146 This build process does not deal with customization for the given
1147 voices. Thus you will need to edit @file{flite/VOICE.c} to set
1148 intonation ranges and duration stretch for your particular voice.
1149
1150 For example in our @file{cmu_us_sls_diphone} voice (a US English female
1151 diphone voice). We had to change the default parameters from
1152 @example
1153 feat_set_float(v->features,"int_f0_target_mean",110.0);
1154 feat_set_float(v->features,"int_f0_target_stddev",15.0);
1155
1156 feat_set_float(v->features,"duration_stretch",1.0);
1157 @end example
1158 to
1159 @example
1160 feat_set_float(v->features,"int_f0_target_mean",167.0);
1161 feat_set_float(v->features,"int_f0_target_stddev",25.0);
1162
1163 feat_set_float(v->features,"duration_stretch",1.0);
1164 @end example
1165
1166 Note this conversion is limited. Because it depends on the C compiler
1167 to do the final conversion into binary object format (a good idea in
1168 general for portability), you can easily generate files too big for the
1169 C compiler to deal with. We have spent some time investigating this
1170 so the largest possible voices can be converted but it is still too
1171 limited for our larger voices. In general the limitation seems to be
1172 best quantified by the number of pitch periods in the database. After
1173 about 100k pitch periods the files get too big to handle. There are
1174 probably solutions to this but we have not yet investigated them. This
1175 limitation doesn't seem to be an issue with the diphone voices as they
1176 are typically much smaller than unit selection voices.
1177
1178 @section Statistical Voice Building (Clustergen)
1179
1180 The process of building from a clustergen (cg) voice is also
1181 supported. It is assumed the environment variable @code{FLITEDIR} is
1182 set
1183 @example
1184 export FLITEDIR=/home/awb/projects/flite/
1185 @end example
1186 After you build the clustergen voice you can convert by first setting
1187 up the skeleton files in the @file{flite/} directory
1188 @example
1189 $FLITEDIR/tools/setup_flite
1190 @end example
1191 Assuming @file{etc/voice.defs} properly identifies the voice the cg
1192 templates will be compied in.
1193
1194 The conversion itself is actually much faster than a clunit build
1195 (there is less to actually convert).
1196 @example
1197 ./bin/build_flite cg
1198 @end example
1199 Will convert then necessary models into files in the @file{flite/}
1200 directory. The you can compile it with
1201 @example
1202 cd flite
1203 make
1204 ./flite_cmu_us_awb "Hello world"
1205 @end example
1206 Note that the voice that is to be converted *must* be a standard
1207 clustergen voice with f0, mceps, delta mceps (optionally strengths for
1208 mixed excitation) and voicing in its
1209 combined coeffs files. The method could be changed to deal with other
1210 possibilities but it will only work for default build method.
1211
1212 The generated library @file{libflite_cmu_us_awb.a} may be linked with
1213 other programs like any other flite voice. The binary generated
1214 @code{flite_cmu_us_awb} links in only one voice (unlike the flite binary in
1215 the full flite distribution.
1216
1217 A single flat file contain the cg voice can also be generated that can
1218 be loaded at run time into the flite binary. You can dump this file
1219 from the initial constructed flite binary
1220 @example
1221 ./flite_cmu_us_awb -voicedump cmu_us_awb.flitevox
1222 @end example
1223 The file cmu_us_awb.flitevox may now be references (with pathname/url) on
1224 the flite command line and used by the synthesizer
1225 @example
1226 ./flite -voice cmu_us_awb.flitevox "Hello World"
1227 @end example
1228
1229 @section Lexicon Conversion
1230
1231 As of 1.3 the script for converting the CMU lexicon (as distributed as
1232 part of Festival) is included. @file{make_cmulex} will use the
1233 version of CMULEX unpacked in the current directory to build a new
1234 lexicon. Also in 1.3. a more sophisticated compression technique is
1235 used to reduce the lexicon size. The lexicon is pruned, removing
1236 those words which the letter to sound rule models get correct. Also
1237 the letters and phones are separately huffman coded to produce a
1238 smaller lexicon.
1239
1240 @section Language Conversion
1241
1242 This is by far the weakest part as this is the most open ended. There
1243 are basic tools in the @file{flite/tools/} directory that include Scheme
1244 code to convert various Scheme structures to C include CART tree
1245 conversion and Lisp list conversion. The other major source of help
1246 here is the existing language examples in @file{flite/lang/usenglish/}.
1247
1248 Adding new language support is far from automatic, but there are core
1249 scripts for setting up new Flite support for languages and lexicons. There
1250 are also scripts for converting (Festival) phoneset definitions to C
1251 and converting Festival lexicons to LTS rules and compressed lexicons
1252 in C.
1253
1254 But beyond that you are sort of on your own. The largest gap here is
1255 text normalization. We do not yet have a standardize model for text
1256 normalization with well definied models for which we could write
1257 conversion scripts.
1258
1259 However here is a step by step attempt to show you what to do when
1260 building support for a new language/lexicon.
1261
1262 Suppose we need to create support for Pashto, and already have a
1263 festival voice running, and want it now to run in flite. Converting
1264 the voice itself (unitselction or clustergen) is fairly robust, but
1265 you will also need C libraries for @file{cmu_pashto_lang} and
1266 @file{cmu_pasho_lex}. The first stage is to create the basic
1267 temple files for these. In the core @file{flite/} source directory
1268 type
1269 @example
1270 ./tools/make_new_lang_lex pashto
1271 @end example
1272 This will create language and lex template files in
1273 @file{lang/cmu_pashto_lang/'} and @file{cmu_pashto_lex}.
1274
1275 Then in firectory @file{lang/cmu_pashto_lang/} type
1276 @example
1277 festival $FLITEDIR/tools/make_phoneset.scm
1278 ...
1279 festival> (phonesettoC "cmu_pashto" (car (load "PATHTO/cmu_pashto_transtac_phoneset.scm" t)) "pau" ".")
1280 @end example
1281 This will create @file{cmu_pashto_lang_phoneset.[ch]}. You must the add these
1282 explicitly to the @file{Makefile}.
1283
1284 Then in @file{lang/cmu_pashto_lex/} you have to build the C version of
1285 the lexicon and letter to sound rules. The core script is in
1286 @file{flite/tools/build_lex}.
1287 @example
1288 mkdir lex
1289 cd lex
1290 cp -p $FLITEDIR/tooks/build_lex .
1291 @end example
1292 Edit build_lex to give it the name of your lexicon name, and compiled
1293 lexicon from your voice.
1294 @example
1295 LEXNAME=cmu_pashto
1296 LEXFILE=lexicon.out
1297 @end example
1298 You should (I think) remove the first line ``MNCL'' from your
1299 @file{lexicon.out} file, note this @emph{must} be the compiled lexicon
1300 not the list of entries you compiled from as it expects the ordering, and
1301 the syllabification.
1302 @example
1303 ./build_lex setup
1304 @end example
1305 Build the letter to sound rules (probably again)
1306 @example
1307 ./build_lex lts
1308 @end example
1309 Convert the compiled letter to sound rules to C. This converts the
1310 decision trees to decision graphs and runs WFST minimization of them
1311 to get a more efficient set of structures. This puts the generated C
1312 files in @file{c/}.
1313 @example
1314 ./build_lex lts2c
1315 @end example
1316 Now convert the lexical entries themselves
1317 @example
1318 ./build_lex lex
1319 @end example
1320 Again the generate C files will be put in @file{c/}.
1321
1322 Now we generated a Huffman codes compressed lexicon to reduce the
1323 lexicon size, merging frequent letter sequences and phone sequences.
1324 @example
1325 ./build_lex compresslex
1326 @end example
1327 The copy the @file{.c} and @file{.h} files to @file{lang/cmu_pashto_lex/}
1328 [something about compressed and non-compressed???]
1329
1330
1331 @chapter Porting to new platforms
1332
1333 byte order, unions, compiler restrictions
1334
1335 @chapter Future developments
1336
1337 @contents
1338
1339 @bye