flite.texi 57 KB

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