home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / fest-141.zip / festival / festival.inf (.txt) < prev    next >
OS/2 Help File  |  1999-12-24  |  256KB  |  7,190 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. -Preface- ΓòÉΓòÉΓòÉ
  3.  
  4. This file documents the Festival Speech Synthesis System a general text to 
  5. speech system for making your computer talk and developing new synthesis 
  6. techniques. 
  7.  
  8. Copyright (C) 1996-1999 University of Edinburgh 
  9.  
  10. Permission is granted to make and distribute verbatim copies of this manual 
  11. provided the copyright notice and this permission notice are preserved on all 
  12. copies. 
  13.  
  14. Permission is granted to copy and distribute modified versions of this manual 
  15. under the conditions for verbatim copying, provided that the entire resulting 
  16. derived work is distributed under the terms of a permission notice identical to 
  17. this one. 
  18.  
  19. Permission is granted to copy and distribute translations of this manual into 
  20. another language, under the above conditions for modified versions, except that 
  21. this permission notice may be stated in a translation approved by the authors. 
  22.  
  23. This file documents the Festival Speech Synthesis System VERSION.  This 
  24. document contains many gaps and is still in the process of being written. 
  25.  
  26.  Abstract                      initial comments 
  27.  Copying                       How you can copy and share the code 
  28.  Acknowledgements              List of contributors 
  29.  What is new                   Enhancements since last public release 
  30.  Overview                      Generalities and Philosophy 
  31.  Installation                  Compilation and Installation 
  32.  Quick start                   Just tell me what to type 
  33.  Scheme                        A quick introduction to Festival's scripting 
  34.                                language  Text methods for interfacing to 
  35.                                Festival 
  36.  TTS                           Text to speech modes 
  37.  XML/SGML mark-up              XML/SGML mark-up Language 
  38.  Emacs interface               Using Festival within Emacs  Internal functions 
  39.  Phonesets                     Defining and using phonesets 
  40.  Lexicons                      Building and compiling Lexicons 
  41.  Utterances                    Existing and defining new utterance types 
  42.                                Modules 
  43.  Text analysis                 Tokenizing text 
  44.  POS tagging                   Part of speech tagging 
  45.  Phrase breaks                 Finding phrase breaks 
  46.  Intonation                    Intonations modules 
  47.  Duration                      Duration modules 
  48.  UniSyn synthesizer            The UniSyn waveform synthesizer 
  49.  Diphone synthesizer           Building and using diphone synthesizers 
  50.  Other synthesis methods       other waveform synthesis methods 
  51.  Audio output                  Getting sound from Festival 
  52.  Voices                        Adding new voices (and languages) 
  53.  Tools                         CART, Ngrams etc 
  54.  Building models from databases  Adding new modules and writing C++ code 
  55.  Programming                   Programming in Festival (Lisp/C/C++) 
  56.  API                           Using Festival in other programs 
  57.  Examples                      Some simple (and not so simple) examples 
  58.  Problems                      Reporting bugs. 
  59.  References                    Other sources of information 
  60.  Feature functions             List of builtin feature functions. 
  61.  Variable list                 Short descriptions of all variables 
  62.  Function list                 Short descriptions of all functions 
  63.  Index                         Index of concepts. 
  64.  
  65.  
  66. ΓòÉΓòÉΓòÉ 2. Abstract ΓòÉΓòÉΓòÉ
  67.  
  68.  This document provides a user manual for the Festival Speech Synthesis System, 
  69.  version VERSION. 
  70.  
  71.  Festival offers a general framework for building speech synthesis systems as 
  72.  well as including examples of various modules.  As a whole it offers full text 
  73.  to speech through a number APIs: from shell level, though a Scheme command 
  74.  interpreter, as a C++ library, and an Emacs interface.  Festival is 
  75.  multi-lingual, we have develeoped voices in many languages including English 
  76.  (UK and US), Spanish and Welsh, though English is the most advanced. 
  77.  
  78.  The system is written in C++ and uses the Edinburgh Speech Tools for low level 
  79.  architecture and has a Scheme (SIOD) based command interpreter for control. 
  80.  Documentation is given in the FSF texinfo format which can generate a printed 
  81.  manual, info files and HTML. 
  82.  
  83.  The latest details and a full software distribution of the Festival Speech 
  84.  Synthesis System are available through its home page which may be found at 
  85.  
  86.                       http://www.cstr.ed.ac.uk/projects/festival.html
  87.  
  88.  
  89. ΓòÉΓòÉΓòÉ 3. Copying ΓòÉΓòÉΓòÉ
  90.  
  91.  As we feeel the core system has reached an acceptable level of maturity from 
  92.  1.4.0 the basic system is released under a free lience, without the commercial 
  93.  restrictions we imposed on early versions. The basic system has been placed 
  94.  under an X11 type licence which as free licences go is pretty free.  No GPL 
  95.  code is included in festival or the speech tools themselves (though some 
  96.  auxiliary files are GPL'd e.g. the Emacs mode for Festival).  We have 
  97.  deliberately choosen a licence that should be compatible with our commercial 
  98.  partners and our free software users. 
  99.  
  100.  However although the code is free, we still offer no warranties and no 
  101.  maintenance.  We will continue to endeavor to fix bugs and answer queries when 
  102.  can, but are not in a position to guarantee it.  We will consider maintenance 
  103.  contracts and consultancy if desired, please contacts us for details. 
  104.  
  105.  Also note that not all the voices and lexicons we distribute with festival are 
  106.  free.  Particularly the British English lexicon derived from Oxford Advanced 
  107.  Learners' Dictionary is free only for non-commercial use (we will release an 
  108.  alternative soon).  Also the Spanish diphone voice we relase is only free for 
  109.  non-commercial use. 
  110.  
  111.  If you are using Festival or the speech tools in commercial environment, even 
  112.  though no licence is required, we would be grateful if you let us know as it 
  113.  helps justify ourselves to our various sponsors. 
  114.  
  115.  The current copyright on the core system is 
  116.  
  117.                            The Festival Speech Synthesis System: version 1.4.1
  118.                               Centre for Speech Technology Research
  119.                                  University of Edinburgh, UK
  120.                                  Copyright (c) 1996-1999
  121.                                   All Rights Reserved.
  122.  
  123.                        Permission is hereby granted, free of charge, to use and distribute
  124.                        this software and its documentation without restriction, including
  125.                        without limitation the rights to use, copy, modify, merge, publish,
  126.                        distribute, sublicense, and/or sell copies of this work, and to
  127.                        permit persons to whom this work is furnished to do so, subject to
  128.                        the following conditions:
  129.                         1. The code must retain the above copyright notice, this list of
  130.                          conditions and the following disclaimer.
  131.                         2. Any modifications must be clearly marked as such.
  132.                         3. Original authors' names are not deleted.
  133.                         4. The authors' names are not used to endorse or promote products
  134.                          derived from this software without specific prior written
  135.                          permission.
  136.  
  137.                        THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK
  138.                        DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  139.                        ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  140.                        SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE
  141.                        FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  142.                        WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  143.                        AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  144.                        ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  145.                        THIS SOFTWARE.
  146.  
  147.  
  148. ΓòÉΓòÉΓòÉ 4. Acknowledgements ΓòÉΓòÉΓòÉ
  149.  
  150.  The code in this system was primarily written by Alan W Black, Paul Taylor and 
  151.  Richard Caley.  Festival sits on top of the Edinburgh Speech Tools Library, 
  152.  and uses much of its functionality. 
  153.  
  154.  Amy Isard wrote a synthesizer for her MSc project in 1995, which first used 
  155.  the Edinburgh Speech Tools Library.  Although Festival doesn't contain any 
  156.  code from that system, her system was used as a basic model. 
  157.  
  158.  Much of the design and philosophy of Festival has been built on the experience 
  159.  both Paul and Alan gained from the development of various previous 
  160.  synthesizers and software systems, especially CSTR's Osprey and Polyglot 
  161.  systems taylor91 and ATR's CHATR system black94. 
  162.  
  163.  However, it should be stated that Festival is fully developed at CSTR and 
  164.  contains neither proprietary code or ideas. 
  165.  
  166.  Festival contains a number of subsystems integrated from other sources and we 
  167.  acknowledge those systems here. 
  168.  
  169.  
  170. ΓòÉΓòÉΓòÉ 4.1. SIOD ΓòÉΓòÉΓòÉ
  171.  
  172.  The Scheme interpreter (SIOD -- Scheme In One Defun 3.0) was written by George 
  173.  Carrett  (gjc@mitech.com, gjc@paradigm.com) and offers a basic small Scheme 
  174.  (Lisp) interpreter suitable for embedding in applications such as Festival as 
  175.  a scripting language.  A number of changes and improvements have been added in 
  176.  our development but it still remains that basic system. We are grateful to 
  177.  George and Paradigm Associates Incorporated for providing such a useful and 
  178.  well-written sub-system. 
  179.  
  180.                                   Scheme In One Defun (SIOD)
  181.                                   COPYRIGHT (c) 1988-1994 BY
  182.                           PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS.
  183.                                     ALL RIGHTS RESERVED
  184.                       Permission to use, copy, modify, distribute and sell this software
  185.                       and its documentation for any purpose and without fee is hereby
  186.                       granted, provided that the above copyright notice appear in all copies
  187.                       and that both that copyright notice and this permission notice appear
  188.                       in supporting documentation, and that the name of Paradigm Associates
  189.                       Inc not be used in advertising or publicity pertaining to distribution
  190.                       of the software without specific, written prior permission.
  191.                       PARADIGM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  192.                       ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  193.                       PARADIGM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  194.                       ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  195.                       WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  196.                       ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  197.                       SOFTWARE.
  198.  
  199.  
  200. ΓòÉΓòÉΓòÉ 4.2. editline ΓòÉΓòÉΓòÉ
  201.  
  202.  Because of conflicts between the copyright for GNU readline, for which an 
  203.  optional interface was included in earlier versions, we have replace the 
  204.  interface with a complete command line editing system based on 'editline'. 
  205.  'Editline' was posted to the USENET newsgroup 'comp.sources.misc' in 1992.  A 
  206.  number of modifications have been made to make it more useful to us but the 
  207.  original code (contained within the standard speech tools distribution) and 
  208.  our modifications fall under the following licence. 
  209.  
  210.                       Copyright 1992 Simmule Turner and Rich Salz.  All rights reserved.
  211.  
  212.                       This software is not subject to any license of the American Telephone
  213.                       and Telegraph Company or of the Regents of the University of California.
  214.  
  215.                       Permission is granted to anyone to use this software for any purpose on
  216.                       any computer system, and to alter it and redistribute it freely, subject
  217.                       to the following restrictions:
  218.                       1. The authors are not responsible for the consequences of use of this
  219.                         software, no matter how awful, even if they arise from flaws in it.
  220.                       2. The origin of this software must not be misrepresented, either by
  221.                         explicit claim or by omission.  Since few users ever read sources,
  222.                         credits must appear in the documentation.
  223.                       3. Altered versions must be plainly marked as such, and must not be
  224.                         misrepresented as being the original software.  Since few users
  225.                         ever read sources, credits must appear in the documentation.
  226.                       4. This notice may not be removed or altered.
  227.  
  228.  
  229. ΓòÉΓòÉΓòÉ 4.3. Edinburgh Speech Tools Library ΓòÉΓòÉΓòÉ
  230.  
  231.  The Edinburgh Speech Tools lies at the core of Festival. Although developed 
  232.  separately, much of the development of certain parts of the Edinburgh Speech 
  233.  Tools has been directed by Festival's needs.  In turn those who have 
  234.  contributed to the Speech Tools make Festival a more usable system. 
  235.  
  236.  See Section Acknowledgements of Edinburgh Speech Tools Library Manual. 
  237.  
  238.  Online information about the Edinburgh Speech Tools library is available 
  239.  through 
  240.  
  241.                       http://www.cstr.ed.ac.uk/projects/speech_tools.html
  242.  
  243.  
  244. ΓòÉΓòÉΓòÉ 4.4. Others ΓòÉΓòÉΓòÉ
  245.  
  246.  Many others have provided actual code and support for Festival, for which we 
  247.  are grateful.  Specifically, 
  248.  
  249.      Alistair Conkie: various low level code points and some design work, 
  250.       Spanish synthesis, the old diphone synthesis code. 
  251.  
  252.      Steve Isard:directorship and LPC diphone code, design of diphone schema. 
  253.  
  254.      EPSRC:who fund Alan Black and Paul Taylor. 
  255.  
  256.      Sun Microsystems Laboratories: for supporting the project and funding 
  257.       Richard. 
  258.  
  259.      AT&T Labs - Research:for supporting the project. 
  260.  
  261.      Paradigm Associates and George Carrett:for Scheme in one defun. 
  262.  
  263.      Mike Macon:Improving the quality of the diphone synthesizer and LPC 
  264.       analysis. 
  265.  
  266.      Kurt Dusterhoff:Tilt intonation training and modelling. 
  267.  
  268.      Amy Isard:for her SSML project and related synthesizer. 
  269.  
  270.      Richard Tobin:for answering all those difficult questions, the socket 
  271.       code, and the XML parser. 
  272.  
  273.      Simmule Turner and Rich Salz:command line editor (editline) 
  274.  
  275.      Borja Etxebarria:Help with the Spanish synsthesis 
  276.  
  277.      Briony Williams:Welsh synthesis 
  278.  
  279.      Jacques H. de Villiers: 'jacques@cse.ogi.edu' from CSLUat OGI, for the 
  280.       TCL interface, and other usability issues 
  281.  
  282.      Kevin Lenzo: 'lenzo@cs.cmu.edu' from CMU for the PERLinterface. 
  283.  
  284.      Rob Clarke:for support under Linux. 
  285.  
  286.      Samuel Audet 'guardia@cam.org':OS/2 support 
  287.  
  288.      Mari Ostendorf:For providing access to the BU FM Radio corpus from which 
  289.       some modules were trained. 
  290.  
  291.      Melvin Hunt:from whose work we based our residual LPC synthesis model on 
  292.  
  293.      Oxford Text Archive:For the computer users version of Oxford Advanced 
  294.       Learners' Dictionary (redistributed with permission). 
  295.  
  296.      Reading University:for access to MARSEC from which the phrase break model 
  297.       was trained. 
  298.  
  299.      LDC & Penn Tree Bank:from which the POS tagger was trained, 
  300.       redistribution of the models is with permission from the LDC. 
  301.  
  302.      Roger Burroughes and Kurt Dusterhoff:For letting us capture their voices. 
  303.  
  304.      ATR and Nick Campbell:for first getting Paul and Alan to work together 
  305.       and for the experience we gained. 
  306.  
  307.      FSF:for G++, make, ┬╖┬╖┬╖┬╖ 
  308.  
  309.      Center for Spoken Language Understanding:CSLU at OGI, particularly Ron 
  310.       Cole and Mike Macon, have acted as significant users for the system 
  311.       giving significant feedback and allowing us to teach courses on Festival 
  312.       offering valuable real-use feedback. 
  313.  
  314.      Our beta testers:Thanks to all the people who put up with previous 
  315.       versions of the system and reported bugs, both big and small.  These 
  316.       comments are very important to the constant improvements in the system. 
  317.       And thanks for your quick responses when I had specific requests. 
  318.  
  319.      And our users ┬╖┬╖┬╖Many people have downloaded earlier versions of the 
  320.       system.  Many have found problems with installation and use and have 
  321.       reported it to us. Many of you have put up with multiple compilations 
  322.       trying to fix bugs remotely.  We thank you for putting up with us and are 
  323.       pleased you've taken the time to help us improve our system.  Many of you 
  324.       have come up with uses we hadn't thought of, which is always rewarding. 
  325.  
  326.       Even if you haven't actively responded, the fact that you use the system 
  327.       at all makes it worthwhile. 
  328.  
  329.  
  330. ΓòÉΓòÉΓòÉ 5. What is new ΓòÉΓòÉΓòÉ
  331.  
  332.  Compared to the the previous major release (1.3.0 release Aug 1998) 1.4.0 is 
  333.  not functionally so different from its previous versions. This release is 
  334.  primarily a consolidation release fixing and tidying up some of the lower 
  335.  level aspects of the system to allow better modularity for some of our future 
  336.  planned modules. 
  337.  
  338.      Copyright change: The system is now free and has no commercial 
  339.       restriction.  Note that currently on the US voices (ked and kal) are also 
  340.       now unrestricted.  The UK English voices depend on the Oxford Advanced 
  341.       Learners' Dictionary of Current English which cannot be used for 
  342.       commercial use without permission from Oxford University Press. 
  343.  
  344.      Architecture tidy up:the interfaces to lower level part parts of the 
  345.       system have been tidied up deleting some of the older code that was 
  346.       supported for compatibility reasons.  This is a much higher dependence of 
  347.       features and easier (and safer) ways to register new objects as feature 
  348.       values and Scheme objects.  Scheme has been tidied up.  It is no longer 
  349.       "in one defun" but "in one directory". 
  350.  
  351.      New documentation system for speech tools:A new docbook based 
  352.       documentation system has been added to the speech tools.  Festival's 
  353.       documentation will will move over to this sometime soon too. 
  354.  
  355.      initial JSAPI support: both JSAPI and JSML (somewhatsimilar to Sable) now 
  356.       have initial impelementations.  They of course depend on Java support 
  357.       which so far we have only (successfully) investgated under Solaris and 
  358.       Linux. 
  359.  
  360.      Generalization of statistical models:  CART, ngrams,and WFSTs are now 
  361.       fully supported from Lisp and can be used with a generalized viterbi 
  362.       function.  This makes adding quite complex statistical models easy 
  363.       without adding new C++. 
  364.  
  365.      Tilt Intonation modelling:Full support is now included for the Tilt 
  366.       intomation models, both training and use. 
  367.  
  368.      Documentation on Bulding New Voices in Festival:documentation, scripts 
  369.       etc. for building new voices and languages in the system, see 
  370.  
  371.                       http://www.cstr.ed.ac.uk/projects/festival/docs/festvox/
  372.  
  373.  
  374. ΓòÉΓòÉΓòÉ 6. Overview ΓòÉΓòÉΓòÉ
  375.  
  376.  Festival is designed as a speech synthesis system for at least three levels of 
  377.  user.  First, those who simply want high quality speech from arbitrary text 
  378.  with the minimum of effort.  Second, those who are developing language systems 
  379.  and wish to include synthesis output.  In this case, a certain amount of 
  380.  customization is desired, such as different voices, specific phrasing, dialog 
  381.  types etc.  The third level is in developing and testing new synthesis 
  382.  methods. 
  383.  
  384.  This manual is not designed as a tutorial on converting text to speech but for 
  385.  documenting the processes and use of our system.  We do not discuss the 
  386.  detailed algorithms involved in converting text to speech or the relative 
  387.  merits of multiple methods, though we will often give references to relevant 
  388.  papers when describing the use of each module. 
  389.  
  390.  For more general information about text to speech we recommend Dutoit's 'An 
  391.  introduction to Text-to-Speech Synthesis' dutoit97.  For more detailed 
  392.  research issues in TTS see sproat98 or vansanten96. 
  393.  
  394.  Philosophy                    Why we did it like it is 
  395.  Future                        How much better its going to get 
  396.  
  397.  
  398. ΓòÉΓòÉΓòÉ 6.1. Philosophy ΓòÉΓòÉΓòÉ
  399.  
  400.  One of the biggest problems in the development of speech synthesis, and other 
  401.  areas of speech and language processing systems, is that there are a lot of 
  402.  simple well-known techniques lying around which can help you realise your 
  403.  goal.  But in order to improve some part of the whole system it is necessary 
  404.  to have a whole system in which you can test and improve your part.  Festival 
  405.  is intended as that whole system in which you may simply work on your small 
  406.  part to improve the whole.  Without a system like Festival, before you could 
  407.  even start to test your new module you would need to spend significant effort 
  408.  to build a whole system, or adapt an existing one before you could start 
  409.  working on your improvements. 
  410.  
  411.  Festival is specifically designed to allow the addition of new modules, easily 
  412.  and efficiently, so that development need not get bogged down in 
  413.  re-implementing the wheel. 
  414.  
  415.  But there is another aspect of Festival which makes it more useful than simply 
  416.  an environment for researching into new synthesis techniques. It is a fully 
  417.  usable text-to-speech system suitable for embedding in other projects that 
  418.  require speech output.  The provision of a fully working easy-to-use speech 
  419.  synthesizer in addition to just a testing environment is good for two specific 
  420.  reasons.  First, it offers a conduit for our research, in that our experiments 
  421.  can quickly and directly benefit users of our synthesis system.  And secondly, 
  422.  in ensuring we have a fully working usable system we can immediately see what 
  423.  problems exist and where our research should be directed rather where our 
  424.  whims take us. 
  425.  
  426.  These concepts are not unique to Festival.  ATR's CHATR system (black94) 
  427.  follows very much the same philosophy and Festival benefits from the 
  428.  experiences gained in the development of that system. Festival benefits from 
  429.  various pieces of previous work.  As well as CHATR, CSTR's previous 
  430.  synthesizers, Osprey and the Polyglot projects influenced many design 
  431.  decisions.  Also we are influenced by more general programs in considering 
  432.  software engineering issues, especially GNU Octave and Emacs on which the 
  433.  basic script model was based. 
  434.  
  435.  Unlike in some other speech and language systems, software engineering is 
  436.  considered very important to the development of Festival.  Too often research 
  437.  systems consist of random collections of hacky little scripts and code.  No 
  438.  one person can confidently describe the algorithms it performs, as parameters 
  439.  are scattered throughout the system, with tricks and hacks making it 
  440.  impossible to really evaluate why the system is good (or bad).  Such systems 
  441.  do not help the advancement of speech technology, except perhaps in pointing 
  442.  at ideas that should be further investigated.  If the algorithms and 
  443.  techniques cannot be described externally from the program such that they can 
  444.  reimplemented by others, what is the point of doing the work? 
  445.  
  446.  Festival offers a common framework where multiple techniques may be 
  447.  implemented (by the same or different researchers) so that they may be tested 
  448.  more fairly in the same environment. 
  449.  
  450.  As a final word, we'd like to make two short statements which both achieve the 
  451.  same end but unfortunately perhaps not for the same reasons: Good software 
  452.            engineering makes good research easier But the following seems to be 
  453.  true also If you spend enough effort on something it can be shown to be better 
  454.            than its competitors. 
  455.  
  456.  
  457. ΓòÉΓòÉΓòÉ 6.2. Future ΓòÉΓòÉΓòÉ
  458.  
  459.  Festival is still very much in development.  Hopefully this state will 
  460.  continue for a long time. It is never possible to complete software, there are 
  461.  always new things that can make it better.  However as time goes on 
  462.  Festival's core architecture will stabilise and little or no changes will be 
  463.  made.  Other aspects of the system will gain greater attention such as 
  464.  waveform synthesis modules, intonation techniques, text type dependent 
  465.  analysers etc. 
  466.  
  467.  Festival will improve, so don't expected it to be the same six months from 
  468.  now. 
  469.  
  470.  A number of new modules and enhancements are already under consideration at 
  471.  various stages of implementation.  The following is a non-exhaustive list of 
  472.  what we may (or may not) add to Festival over the next six months or so. 
  473.  
  474.      Selection-based synthesis: Moving away from diphone technology to more 
  475.       generalized selection of units for speech database. 
  476.  
  477.      New structure for linguistic content of utterances:Using techniques for 
  478.       Metrical Phonology we are building more structure representations of 
  479.       utterances reflecting there linguistic significance better.  This will 
  480.       allow improvements in prosody and unit selection. 
  481.  
  482.      Non-prosodic prosodic control:For language generation systems and custom 
  483.       tasks where the speech to be synthesized is being generated by some 
  484.       program, more information about text structure will probably exist, such 
  485.       as phrasing, contrast, key items etc.  We are investigating the 
  486.       relationship of high-level tags to prosodic information through the Sole 
  487.       project http://www.cstr.ed.ac.uk/projects/sole.html 
  488.  
  489.      Dialect independent lexicons:Currently for each new dialect we need a new 
  490.       lexicon, we are currently investigating a form of lexical specification 
  491.       that is dialect independent that allows the core form to be mapped to 
  492.       different dialects.  This will make the generation of voices in different 
  493.       dialects much easier. 
  494.  
  495.  
  496. ΓòÉΓòÉΓòÉ 7. Installation ΓòÉΓòÉΓòÉ
  497.  
  498.  This section describes how to install Festival from source in a new location 
  499.  and customize that installation. 
  500.  
  501.  Requirements                  Software/Hardware requirements for Festival 
  502.  Configuration                 Setting up compilation 
  503.  Site initialization           Settings for your particular site 
  504.  Checking an installation      But does it work ┬╖┬╖┬╖ 
  505.  Y2K                           Comment on Festival and year 2000 
  506.  
  507.  
  508. ΓòÉΓòÉΓòÉ 7.1. Requirements ΓòÉΓòÉΓòÉ
  509.  
  510.  In order to compile Festival you first need the following source packages 
  511.  
  512.  festival-1.4.1.tar.gz Festival Speech Synthesis System source 
  513.  
  514.  speech_tools-1.2.1.tar.gzThe Edinburgh Speech Tools Library 
  515.  
  516.  festlex_NAME.tar.gzThe lexicon distribution, where possible, includes the 
  517.            lexicon input file as well as the compiled form, for your 
  518.            convenience.  The lexicons have varying distribution policies, but 
  519.            are all free except OALD, which is only free for non-commercial use 
  520.            (we are working on a free replacement).  In some cases only a 
  521.            pointer to an ftp'able file plus a program to convert that file to 
  522.            the Festival format is included. 
  523.  
  524.  festvox_NAME.tar.gzYou'll need a speech database.  A number are available 
  525.            (with varying distribution policies).  Each voice may have other 
  526.            dependencies such as requiring particular lexicons 
  527.  
  528.  festdoc_1.4.1.tar.gzFull postscript, info and html documentation for Festival 
  529.            and the Speech Tools.  The source of the documentation is available 
  530.            in the standard distributions but for your conveniences it has been 
  531.            pre-generated. 
  532.  
  533.  In addition to Festival specific sources you will also need 
  534.  
  535.  A UNIX machine Currently we have compiled and tested the system under Solaris 
  536.            (2.5(.1), 2.6 and 2.7), SunOS (4.1.3), FreeBSD 2.2, 3.x, Linux 
  537.            (Redhat 4.1, 5.0, 5.1, 5.2, 6.0 and other Linux distributions), and 
  538.            it should work under OSF (Dec Alphas) SGI (Irix), HPs (HPUX).  But 
  539.            any standard UNIX machine should be acceptable.  We have now 
  540.            successfully ported this version to Windows NT nad Windows 95 (using 
  541.            the Cygnus GNU win32 environment). This is still a young port but 
  542.            seems to work. 
  543.  
  544.  A C++ compilerNote that C++ is not very portable even between different 
  545.            versions of the compiler from the same vendor.  Although we've tried 
  546.            very hard to make the system portable, we know it is very unlikely 
  547.            to compile without change except with compilers that have already 
  548.            been tested. The currently tested systems are 
  549.  
  550.                1. Sun Sparc Solaris 2.5, 2.5.1, 2.6, 2.7: GCC 2.7.2, GCC 2.8.1, 
  551.                   SunCC 4.1, egcs 1.1.1, egcs 1.1.2, GCC 2.95.1 
  552.  
  553.                2. Sun Sparc SunOS 4.1.3: GCC 2.7.2 
  554.  
  555.                3. Intel SunOS 2.5.1: GCC 2.7.2 
  556.  
  557.                4. FreeBSD for Intel 2.2.1, 2.2.6 and 3.x (ELF based) GCC 
  558.                   2.7.2.1, GCC 2.95.1 
  559.  
  560.                5. Linux (2.0.30) for Intel (RedHat 4.1/5.0/5.1/5.2/6.0): GCC 
  561.                   2.7.2, GCC 2.7.2/egcs-1.0.2, egcs 1.1.1, egcs-1.1.2, GCC 
  562.                   2.95.1 
  563.  
  564.                6. Windows NT 4.0: GCC 2.7.2 plus egcs (from Cygnus GNU win32 
  565.                   b19), Visual C++ PRO v5.0 
  566.  
  567.              Note if GCC works on one version of Unix it usually works on 
  568.              others. 
  569.  
  570.              We still recommend GCC 2.7.2 which we use as our standard 
  571.              compiler.  It is (mostly) standard across platforms and compiles 
  572.              faster and produces better code than any of the other compilers 
  573.              we've used. 
  574.  
  575.              We have compiled both the speech tools and Festival under Windows 
  576.              NT 4.0 and Windows 95 using the GNU tools available from Cygnus. 
  577.  
  578.                                               ftp://ftp.cygnus.com/pub/gnu-win32/.
  579.  
  580.  GNU make  Due to there being too many different make programs out there we 
  581.            have tested the system using GNU make on all systems we use. Others 
  582.            may work but we know GNU make does. 
  583.  
  584.  Audio hardwareYou can use Festival without audio output hardware but it 
  585.            doesn't sound very good (though admittedly you can hear less 
  586.            problems with it).  A number of audio systems are supported 
  587.            (directly inherited from the audio support in the Edinburgh Speech 
  588.            Tools Library): NCD's NAS (formerly called netaudio) a network 
  589.            transparent audio system (which can be found at 
  590.            ftp://ftp.x.org/contrib/audio/nas/); '/dev/audio' (at 8k ulaw and 
  591.            8/16bit linear), found on Suns, Linux machines and FreeBSD; and a 
  592.            method allowing arbitrary UNIX commands. See Audio output. 
  593.  
  594.  Earlier versions of Festival mistakenly offered a command line editor 
  595.  interface to the GNU package readline, but due to conflicts with the GNU 
  596.  Public Licence and Festival's licence this interface was removed in version 
  597.  1.3.1.  Even Festival's new free licence would cause problems as readline 
  598.  support would restrict Festival linking with non-free code.  A new command 
  599.  line interface based on editline was provided that offers similar 
  600.  functionality.  Editline remains a compilation option as it is probably not 
  601.  yet as portable as we would like it to be. 
  602.  
  603.  In addition to the above, in order to process the documentation you will need 
  604.  'TeX', 'dvips' (or similar), GNU's 'makeinfo' (part of the texinfo package) 
  605.  and 'texi2html' which is available from http://wwwcn.cern.ch/dci/texi2html/. 
  606.  
  607.  However the document files are also available pre-processed into, postscript, 
  608.  DVI, info and html as part of the distribution in 'festdoc-1.4.X.tar.gz'. 
  609.  
  610.  Most of the related software not part of the Festival distribution has been 
  611.  made available in 
  612.  
  613.                       ftp://ftp.cstr.ed.ac.uk/pub/festival/extras/
  614.  
  615.  Ensure you have a fully installed and working version of your C++ compiler. 
  616.  Most of the problems people have had in installing Festival have been due to 
  617.  incomplete or bad compiler installation.  It might be worth checking if the 
  618.  following program works if you don't know if anyone has used your C++ 
  619.  installation before. 
  620.  
  621.                       #include <iostream.h>
  622.                       int main (int argc, char **argv)
  623.                       {
  624.                         cout << "Hello world\n";
  625.                       }
  626.  
  627.  Unpack all the source files in a new directory.  The directory will then 
  628.  contain two subdirectories 
  629.  
  630.                       speech_tools/
  631.                       festival/
  632.  
  633.  
  634. ΓòÉΓòÉΓòÉ 7.2. Configuration ΓòÉΓòÉΓòÉ
  635.  
  636.  First ensure you have a compiled version of the Edinburgh Speech Tools 
  637.  Library.  See 'speech_tools/INSTALL' for instructions. 
  638.  
  639.  Before compilation of Festival it is necessary to configure your 
  640.  implementation to be aware of the environment it is being compiled in. 
  641.  Specifically it must know the names of various local programs, such as your 
  642.  compiler; directories were local libraries are held, and choices for various 
  643.  options about sub-systems it is to use.  In most cases this can be done 
  644.  automatically if your system is a supported, otherwise it may be necessary to 
  645.  edit a few lines. 
  646.  
  647.  All compilation information is set in a local per installation file called 
  648.  'config/config'.  You should copy the example one, mark it writable and edit 
  649.  it according to your local set up. 
  650.  
  651.                       cd config/
  652.                       cp config-dist config
  653.                       chmod +w config
  654.  'config/config' is included by all 'Makefiles' in the system and therefore 
  655.  should be the only place machine specific information need be changed.  Note 
  656.  that all 'Makefiles' define the variable TOP to allow appropriate relative 
  657.  addressing of directories within the 'Makefiles' and their included files. 
  658.  
  659.  For the most part Festival configuration inherits the configuration from your 
  660.  speech tools config file ('┬╖┬╖/speech_tools/config/config'). Additional 
  661.  optional modules may be added by adding them to the end of your config file 
  662.  e.g. 
  663.  
  664.                       ALSO_INCLUDE += clunits
  665.  Adding and new module here will treat is as a new directory in the 
  666.  'src/modules/' and compile it into the system in the same way the OTHER_DIRS 
  667.  feature was used in previous versions. 
  668.  
  669.  If the compilation directory being accessed by NFS or if you use an 
  670.  automounter (e.g. amd) it is recommend to explicitly set the variable 
  671.  FESTIVAL_HOME in 'config/config'. The command pwd is not reliable when a 
  672.  directory may have multiple names. 
  673.  
  674.  To check your configuration type in the 'festival/' directory. 
  675.  
  676.                       gnumake info
  677.  
  678.  If that seems fine, compile the system with 
  679.  
  680.                       gnumake
  681.  
  682.  On completion you can check the system with 
  683.  
  684.                       gnumake test
  685.  
  686.  Note that the single most common reason for problems in compilation and 
  687.  linking found amongst the beta testers was a bad installation of GNU C++.  If 
  688.  you get many strange errors in G++ library header files or link errors it is 
  689.  worth checking that your system has the compiler, header files and runtime 
  690.  libraries properly installed.  This may be checked by compiling a simple 
  691.  program under C++ and also finding out if anyone at your site has ever used 
  692.  the installation.  Most of these installation problems are caused by upgrading 
  693.  to a newer version of libg++ without removing the older version so a mixed 
  694.  version of the '.h' files exist. 
  695.  
  696.  Although we have tried very hard to ensure that Festival compiles with no 
  697.  warnings this is not possible under some systems. 
  698.  
  699.  Under SunOS the system include files do not declare a number of system 
  700.  provided functions.  This a bug in Sun's include files.  This will causes 
  701.  warnings like "implicit definition of fprintf".  These are harmless. 
  702.  
  703.  Under Sun's CC compiler a number of warnings are given about not being able to 
  704.  find source, particularly for operator << and some == operators.  It is 
  705.  unclear why this should be a warning as the code exists in other files 
  706.  deliberately for modularity purposes and should not be visible in these files 
  707.  anyway.  These warnings are harmless. 
  708.  
  709.  Under Linux a warning at link time about reducing the size of some symbols 
  710.  often is produced.  This is harmless.  There is often occasional warnings 
  711.  about some socket system function having an incorrect argument type, this is 
  712.  also harmless. 
  713.  
  714.  The speech tools and festival compile under Windows95 or Windows NT with 
  715.  Visual C++ v5.0 using the Microsoft 'nmake' make program.  We've only done 
  716.  this with the Professonal edition, but have no reason to believe that it 
  717.  relies on anything not in the standard edition. 
  718.  
  719.  In accordance to VC++ conventions, object files are created with extension 
  720.  ┬╖obj, executables with extension .exe and libraries with extension ┬╖lib. This 
  721.  may mean that both unix and Win32 versions can be built in the same directory 
  722.  tree, but I wouldn't rely on it. 
  723.  
  724.  To do this you require nmake Makefiles for the system. These can be generated 
  725.  from the gnumake Makefiles, using the command 
  726.  
  727.                       gnumake VCMakefile
  728.  in the speech_tools and festival directories. I have only done this under 
  729.  unix, it's possible it would work under the cygnus gnuwin32 system. 
  730.  
  731.  If 'make.depend' files exist (i.e. if you have done 'gnumake depend' in unix) 
  732.  equivalent 'vc_make.depend' files will be created, if not the VCMakefiles will 
  733.  not contain dependency information for the '.cc' files. The result will be 
  734.  that you can compile the system once, but changes will not cause the correct 
  735.  things to be rebuilt. 
  736.  
  737.  In order to compile from the DOS command line using Visual C++ you need to 
  738.  have a collection of environment variables set. In Windows NT there is an 
  739.  instalation option for Visual C++ which sets these globally. Under Windows95 
  740.  or if you don't ask for them to be set globally under NT you need to run 
  741.  
  742.                       vcvars32.bat
  743.  See the VC++ documentation for more details. 
  744.  
  745.  Once you have the source trees with VCMakefiles somewhere visible from 
  746.  Windows, you need to copy 'peech_tools\config\vc_config-dist' to 
  747.  'speech_tools\config\vc_config' and edit it to suit your local situation. Then 
  748.  do the same with 'festival\config\vc_config-dist'. 
  749.  
  750.  The thing most likely to need changing is the definition of FESTIVAL_HOME in 
  751.  'festival\config\vc_config_make_rules' which needs to point to where you have 
  752.  put festival. 
  753.  
  754.  Now you can compile. cd to the speech_tools directory and do 
  755.  
  756.                       nmake /nologo /fVCMakefile
  757.  and the library, the programs in main and the test programs should be 
  758.  compiled. 
  759.  
  760.  The tests can't be run automatically under Windows. A simple test to check 
  761.  that things are probably OK is: 
  762.  
  763.                       main\na_play testsuite\data\ch_wave.wav
  764.  which reads and plays a waveform. 
  765.  
  766.  Next go into the festival directory and do 
  767.  
  768.                       nmake /nologo /fVCMakefile
  769.  to build festival. When it's finished, and assuming you have the voices and 
  770.  lexicons unpacked in the right place, festival should run just as under unix. 
  771.  
  772.  We should remind you that the NT/95 ports are still young and there may yet be 
  773.  problems that we've not found yet.  We only recommend the use the speech tools 
  774.  and Festival under Windows if you have significant experience in C++ under 
  775.  those platforms. 
  776.  
  777.  Most of the modules 'src/modules' are actually optional and the system could 
  778.  be compiled without them.  The basic set could be reduced further if certain 
  779.  facilities are not desired.  Particularly: 'donovan' which is only required if 
  780.  the donovan voice is used; 'rxp' if no XML parsing is required (e.g. Sable); 
  781.  and 'parser' if no stochastic paring is required (this parser isn't used for 
  782.  any of our currently released voices).  Actually even 'UniSyn' and 
  783.  'UniSyn_diphone' could be removed if some external waveform synthesizer is 
  784.  being used (e.g. MBROLA) or some alternative one like 'OGIresLPC'.  Removing 
  785.  unused modules will make the festival binary smaller and (potentially) start 
  786.  up faster but don't expect too much. You can delete these by changing the 
  787.  BASE_DIRS variable in 'src/modules/Makefile'. 
  788.  
  789.  
  790. ΓòÉΓòÉΓòÉ 7.3. Site initialization ΓòÉΓòÉΓòÉ
  791.  
  792.  Once compiled Festival may be further customized for particular sites. At 
  793.  start up time Festival loads the file 'init.scm' from its library directory. 
  794.  This file further loads other necessary files such as phoneset descriptions, 
  795.  duration parameters, intonation parameters, definitions of voices etc.  It 
  796.  will also load the files 'sitevars.scm' and 'siteinit.scm' if they exist. 
  797.  'sitevars.scm' is loaded after the basic Scheme library functions are loaded 
  798.  but before any of the festival related functions are loaded.  This file is 
  799.  intended to set various path names before various subsystems are loaded. 
  800.  Typically variables such as lexdir (the directory where the lexicons are 
  801.  held), and voices_dir (pointing to voice directories) should be reset here if 
  802.  necessary. 
  803.  
  804.  The default installation will try to find its lexicons and voices 
  805.  automatically based on the value of load-path (this is derived from 
  806.  FESTIVAL_HOME at compilation time or by using the --libdir at run-time).  If 
  807.  the voices and lexicons have been unpacked into subdirectories of the library 
  808.  directory (the default) then no site specific initialization of the above 
  809.  pathnames will be necessary. 
  810.  
  811.  The second site specific file is 'siteinit.scm'.  Typical examples of local 
  812.  initialization are as follows.  The default audio output method is NCD's NAS 
  813.  system if that is supported as that's what we use normally in CSTR.  If it is 
  814.  not supported, any hardware specific mode is the default (e.g. sun16audio, 
  815.  freebas16audio, linux16audio or mplayeraudio). But that default is just a 
  816.  setting in 'init.scm'.  If for example in your environment you may wish the 
  817.  default audio output method to be 8k mulaw through '/dev/audio' you should add 
  818.  the following line to your 'siteinit.scm' file 
  819.  
  820.                       (Parameter.set 'Audio_Method 'sunaudio)
  821.  Note the use of Parameter.set rather than Parameter.def the second function 
  822.  will not reset the value if it is already set. Remember that you may use the 
  823.  audio methods sun16audio. linux16audio or freebsd16audio only if NATIVE_AUDIO 
  824.  was selected in 'speech_tools/config/config' and your are on such machines. 
  825.  The Festival variable *modules* contains a list of all supported 
  826.  functions/modules in a particular installation including audio support.  Check 
  827.  the value of that variable if things aren't what you expect. 
  828.  
  829.  If you are installing on a machine whose audio is not directly supported by 
  830.  the speech tools library, an external command may be executed to play a 
  831.  waveform.  The following example is for an imaginary machine that can play 
  832.  audio files through a program called 'adplay' with arguments for sample rate 
  833.  and file type.  When playing waveforms, Festival, by default, outputs as 
  834.  unheadered waveform in native byte order.  In this example you would set up 
  835.  the default audio playing mechanism in 'siteinit.scm' as follows 
  836.  
  837.                       (Parameter.set 'Audio_Method 'Audio_Command)
  838.                       (Parameter.set 'Audio_Command "adplay -raw -r $SR $FILE")
  839.  For Audio_Command method of playing waveforms Festival supports two additional 
  840.  audio parameters. Audio_Required_Rate allows you to use Festivals internal 
  841.  sample rate conversion function to any desired rate.  Note this may not be as 
  842.  good as playing the waveform at the sample rate it is originally created in, 
  843.  but as some hardware devices are restrictive in what sample rates they 
  844.  support, or have naive resample functions this could be optimal.  The second 
  845.  addition audio parameter is Audio_Required_Format which can be used to specify 
  846.  the desired output forms of the file.  The default is unheadered raw, but this 
  847.  may be any of the values supported by the speech tools (including nist, esps, 
  848.  snd, riff, aiff, audlab, raw and, if you really want it, ascii). 
  849.  
  850.  For example suppose you run Festival on a remote machine and are not running 
  851.  any network audio system and want Festival to copy files back to your local 
  852.  machine and simply cat them to '/dev/audio'.  The following would do that 
  853.  (assuming permissions for rsh are allowed). 
  854.  
  855.                       (Parameter.set 'Audio_Method 'Audio_Command)
  856.                       ;; Make output file ulaw 8k (format ulaw implies 8k)
  857.                       (Parameter.set 'Audio_Required_Format 'ulaw)
  858.                       (Parameter.set 'Audio_Command
  859.                        "userhost=`echo $DISPLAY | sed 's/:.*$//'`; rcp $FILE $userhost:$FILE; \
  860.                        rsh $userhost \"cat $FILE >/dev/audio\" ; rsh $userhost \"rm $FILE\"")
  861.  Note there are limits on how complex a command you want to put in the 
  862.  Audio_Command string directly.  It can get very confusing with respect to 
  863.  quoting.  It is therefore recommended that once you get past a certain 
  864.  complexity consider writing a simple shell script and calling it from the 
  865.  Audio_Command string. 
  866.  
  867.  A second typical customization is setting the default speaker.  Speakers 
  868.  depend on many things but due to various licence (and resource) restrictions 
  869.  you may only have some diphone/nphone databases available in your 
  870.  installation.  The function name that is the value of voice_default is called 
  871.  immediately after 'siteinit.scm' is loaded offering the opportunity for you to 
  872.  change it.  In the standard distribution no change should be required.  If you 
  873.  download all the distributed voices voice_rab_diphone is the default voice. 
  874.  You may change this for a site by adding the following to 'siteinit.scm' or 
  875.  per person by changing your '.festivalrc'.  For example if you wish to change 
  876.  the default voice to the American one voice_ked_diphone 
  877.  
  878.                       (set! voice_default 'voice_ked_diphone)
  879.  Note the single quote, and note that unlike in early versions voice_default is 
  880.  not a function you can call directly. 
  881.  
  882.  A second level of customization is on a per user basis.  After loading 
  883.  'init.scm', which includes 'sitevars.scm' and 'siteinit.scm' for local 
  884.  installation, Festival loads the file '.festivalrc' from the user's home 
  885.  directory (if it exists).  This file may contain arbitrary Festival commands. 
  886.  
  887.  For example a particular installation of Festival may set Spanish as the 
  888.  default language by adding 
  889.  
  890.                       (language_spanish)
  891.  in 'siteinit.scm', while a user may wish their version to use Welsh by 
  892.  default.  In this case they would add 
  893.  
  894.                       (language_welsh)
  895.  to their '.festivalrc' in their home directory. 
  896.  
  897.  
  898. ΓòÉΓòÉΓòÉ 7.4. Checking an installation ΓòÉΓòÉΓòÉ
  899.  
  900.  Once compiled and site initialization is set up you should test to see if 
  901.  Festival can speak or not. 
  902.  
  903.  Start the system 
  904.  
  905.                       $ bin/festival
  906.                       Festival Speech Synthesis System 1.4.1:release November 1999
  907.                       Copyright (C) University of Edinburgh, 1996-1999. All rights reserved.
  908.                       For details type `(festival_warranty)'
  909.                       festival> ^D
  910.  If errors occur at this stage they are most likely to do with pathname 
  911.  problems.  If any error messages are printed about non-existent files check 
  912.  that those pathnames point to where you intended them to be.  Most of the 
  913.  (default) pathnames are dependent on the basic library path.  Ensure that is 
  914.  correct.  To find out what it has been set to, start the system without 
  915.  loading the init files. 
  916.  
  917.                       $ bin/festival -q
  918.                       Festival Speech Synthesis System 1.4.1:release November 1999
  919.                       Copyright (C) University of Edinburgh, 1996-1999. All rights reserved.
  920.                       For details type `(festival_warranty)'
  921.                       festival> libdir
  922.                       "/projects/festival/lib/"
  923.                       festival> ^D
  924.  This should show the pathname you set in your 'config/config'. 
  925.  
  926.  If the system starts with no errors try to synthesize something 
  927.  
  928.                       festival> (SayText "hello world")
  929.  Some files are only accessed at synthesis time so this may show up other 
  930.  problem pathnames.  If it talks, you're in business, if it doesn't, here are 
  931.  some possible problems. 
  932.  
  933.  If you get the error message 
  934.  
  935.                       Can't access NAS server
  936.  You have selected NAS as the audio output but have no server running on that 
  937.  machine or your DISPLAY or AUDIOSERVER environment variable is not set 
  938.  properly for your output device.  Either set these properly or change the 
  939.  audio output device in 'lib/siteinit.scm' as described above. 
  940.  
  941.  Ensure your audio device actually works the way you think it does.  On Suns, 
  942.  the audio output device can be switched into a number of different output 
  943.  modes, speaker, jack, headphones.  If this is set to the wrong one you may not 
  944.  hear the output.  Use one of Sun's tools to change this (try 
  945.  '/usr/demo/SOUND/bin/soundtool').  Try to find an audio file independent of 
  946.  Festival and get it to play on your audio. Once you have done that ensure that 
  947.  the audio output method set in Festival matches that. 
  948.  
  949.  Once you have got it talking, test the audio spooling device. 
  950.  
  951.                       festival> (intro)
  952.  This plays a short introduction of two sentences, spooling the audio output. 
  953.  
  954.  Finally exit from Festival (by end of file or (quit)) and test the script mode 
  955.  with. 
  956.  
  957.                       $ examples/saytime
  958.  
  959.  A test suite is included with Festival but it makes certain assumptions about 
  960.  which voices are installed.  It assumes that voice_rab_diphone 
  961.  ('festvox_rabxxxx.tar.gz') is the default voice and that voice_ked_diphone and 
  962.  voice_don_diphone ('festvox_kedxxxx.tar.gz' and 'festvox_don.tar.gz') are 
  963.  installed.  Also local settings in your 'festival/lib/siteinit.scm' may affect 
  964.  these tests.  However, after installation it may be worth trying 
  965.  
  966.                       gnumake test
  967.  from the 'festival/' directory.  This will do various tests including basic 
  968.  utterance tests and tokenization tests.  It also checks that voices are 
  969.  installed and that they don't interfere with each other. These tests are 
  970.  primarily regression tests for the developers of Festival, to ensure new 
  971.  enhancements don't mess up existing supported features.  They are not designed 
  972.  to test an installation is successful, though if they run correctly it is most 
  973.  probable the installation has worked. 
  974.  
  975.  
  976. ΓòÉΓòÉΓòÉ 7.5. Y2K ΓòÉΓòÉΓòÉ
  977.  
  978.  Festival comes with no warranty therefore we will not make any legal statement 
  979.  about the performance of the system.  However a number of people have ask 
  980.  about Festival and Y2K compliance, and we have decided to make some comments 
  981.  on this. 
  982.  
  983.  Every effort has been made to ensure that Festival will continue running as 
  984.  before into the next millenium.  However even if Festival itself has no 
  985.  problems it is dependent on the operating system environment it is running in. 
  986.  During compilation dates on files are important and the compilation process 
  987.  may not work if your machine cannot assign (reasonable) dates to new files. 
  988.  At run time there is less dependence on system dates and times.  Specifically 
  989.  times are used in generation of random numbers (where only relative time is 
  990.  important) and as time stamps in log files when festival runs in server mode, 
  991.  thus we feel it is unlikely there will be any problems. 
  992.  
  993.  However, as a speech synthesizer, Festival must make explicit decisions about 
  994.  the pronunciation of dates in the next two decades when people themselves have 
  995.  not yet made such decisions.  Most people are still unsure how to read years 
  996.  written as '01, '04, '12, 00s, 10s, (cf. '86, 90s).  It is interesting to note 
  997.  that while there is a convenient short name for the last decade of the 
  998.  twentieth century, the "ninties" there is no equivalent name for the first 
  999.  decade of the twenty-first century (or the second).  In the mean time we have 
  1000.  made reasonable decisions about such pronunciations. 
  1001.  
  1002.  Once people have themselves become Y2K compliant and decided what to actually 
  1003.  call these years, if their choices are different from how Festival pronounces 
  1004.  them we reserve the right to change how Festival speaks these dates to match 
  1005.  their belated decisions.  However as we do not give out warranties about 
  1006.  compliance we will not be requiring our users to return signed Y2K compliant 
  1007.  warranties about their own compliance either. 
  1008.  
  1009.  
  1010. ΓòÉΓòÉΓòÉ 8. Quick start ΓòÉΓòÉΓòÉ
  1011.  
  1012.  This section is for those who just want to know the absolute basics to run the 
  1013.  system. 
  1014.  
  1015.  Festival works in two fundamental modes, command mode and text-to-speech mode 
  1016.  (tts-mode).  In command mode, information (in files or through standard input) 
  1017.  is treated as commands and is interpreted by a Scheme interpreter.  In 
  1018.  tts-mode, information (in files or through standard input) is treated as text 
  1019.  to be rendered as speech. The default mode is command mode, though this may 
  1020.  change in later versions. 
  1021.  
  1022.  Basic command line options 
  1023.  Simple command driven session 
  1024.  Getting some help 
  1025.  
  1026.  
  1027. ΓòÉΓòÉΓòÉ 8.1. Basic command line options ΓòÉΓòÉΓòÉ
  1028.  
  1029.  Festival's basic calling method is as 
  1030.  
  1031.                       festival [options] file1 file2 ┬╖┬╖┬╖
  1032.  
  1033.  Options may be any of the following 
  1034.  
  1035.  -q        start Festival without loading 'init.scm' or user's '.festivalrc' 
  1036.  
  1037.   -b
  1038.  
  1039.  --batch   After processing any file arguments do not become interactive 
  1040.  
  1041.   -i
  1042.  
  1043.  --interactiveAfter processing file arguments become interactive.  This option 
  1044.            overrides any batch argument. 
  1045.  
  1046.  --tts     Treat file arguments in text-to-speech mode, causing them to be 
  1047.            rendered as speech rather than interpreted as commands.  When 
  1048.            selected in interactive mode the command line edit functions are not 
  1049.            available 
  1050.  
  1051.  --command Treat file arguments in command mode.  This is the default. 
  1052.  
  1053.  --language LANGSet the default language to LANG.  Currently LANG may be one of 
  1054.            english, spanish or welsh (depending on what voices are actually 
  1055.            available in your installation). 
  1056.  
  1057.  --server  After loading any specified files go into server mode.  This is a 
  1058.            mode where Festival waits for clients on a known port (the value of 
  1059.            server_port, default is 1314).  Connected clients may send commands 
  1060.            (or text) to the server and expect waveforms back. See Server/client 
  1061.            API.  Note server mode may be unsafe and allow unauthorised access 
  1062.            to your machine, be sure to read the security recommendations in 
  1063.            Server/client API 
  1064.  
  1065.  --script scriptfileRun scriptfile as a Festival script file.  This is similar 
  1066.            to to --batch but it encapsulates the command line arguments into 
  1067.            the Scheme variables argv and argc, so that Festival scripts may 
  1068.            process their command line arguments just like any other program. 
  1069.            It also does not load the the basic initialisation files as 
  1070.            sometimes you may not want to do this.  If you wish them, you should 
  1071.            copy the loading sequence from an example Festival script like 
  1072.            'festival/examples/saytext'. 
  1073.  
  1074.  --heap NUMBERThe Scheme heap (basic number of Lisp cells) is of a fixed size 
  1075.            and cannot be dynamically increased at run time (this would 
  1076.            complicate garbage collection).  The default size is 210000 which 
  1077.            seems to be more than adequate for most work.  In some of our 
  1078.            training experiments where very large list structures are required 
  1079.            it is necessary to increase this.  Note there is a trade off between 
  1080.            size of the heap and time it takes to garbage collect so making this 
  1081.            unnecessarily big is not a good idea.  If you don't understand the 
  1082.            above explanation you almost certainly don't need to use the option. 
  1083.  In command mode, if the file name starts with a left parenthesis, the name 
  1084.  itself is read and evaluated as a Lisp command.  This is often convenient when 
  1085.  running in batch mode and a simple command is necessary to start the whole 
  1086.  thing off after loading in some other specific files. 
  1087.  
  1088.  
  1089. ΓòÉΓòÉΓòÉ 8.2. Sample command driven session ΓòÉΓòÉΓòÉ
  1090.  
  1091.  Here is a short session using Festival's command interpreter. 
  1092.  
  1093.  Start Festival with no arguments 
  1094.  
  1095.                       $ festival
  1096.                       Festival Speech Synthesis System 1.4.1:release November 1999
  1097.                       Copyright (C) University of Edinburgh, 1996-1999. All rights reserved.
  1098.                       For details type `(festival_warranty)'
  1099.                       festival>
  1100.  
  1101.  Festival uses the a command line editor based on editline for terminal input 
  1102.  so command line editing may be done with Emacs commands.  Festival also 
  1103.  supports history as well as function, variable name, and file name completion 
  1104.  via the TAB key. 
  1105.  
  1106.  Typing help will give you more information, that is help without any 
  1107.  parenthesis.  (It is actually a variable name whose value is a string 
  1108.  containing help.) 
  1109.  
  1110.  Festival offers what is called a read-eval-print loop, because it reads an 
  1111.  s-expression (atom or list), evaluates it and prints the result.  As Festival 
  1112.  includes the SIOD Scheme interpreter most standard Scheme commands work 
  1113.  
  1114.                       festival> (car '(a d))
  1115.                       a
  1116.                       festival> (+ 34 52)
  1117.                       86
  1118.  In addition to standard Scheme commands a number of commands specific to 
  1119.  speech synthesis are included.  Although, as we will see, there are simpler 
  1120.  methods for getting Festival to speak, here are the basic underlying explicit 
  1121.  functions used in synthesizing an utterance. 
  1122.  
  1123.  Utterances can consist of various types (See Utterance types), but the 
  1124.  simplest form is plain text.  We can create an utterance and save it in a 
  1125.  variable 
  1126.  
  1127.                       festival> (set! utt1 (Utterance Text "Hello world"))
  1128.                       #<Utterance 1d08a0>
  1129.                       festival>
  1130.  The (hex) number in the return value may be different for your installation. 
  1131.  That is the print form for utterances.  Their internal structure can be very 
  1132.  large so only a token form is printed. 
  1133.  
  1134.  Although this creates an utterance it doesn't do anything else. To get a 
  1135.  waveform you must synthesize it. 
  1136.  
  1137.                       festival> (utt.synth utt1)
  1138.                       #<Utterance 1d08a0>
  1139.                       festival>
  1140.  This calls various modules, including tokenizing, duration,. intonation etc. 
  1141.  Which modules are called are defined with respect to the type of the 
  1142.  utterance, in this case Text. It is possible to individually call the modules 
  1143.  by hand but you just wanted it to talk didn't you.  So 
  1144.  
  1145.                       festival> (utt.play utt1)
  1146.                       #<Utterance 1d08a0>
  1147.                       festival>
  1148.  will send the synthesized waveform to your audio device.  You should hear 
  1149.  "Hello world" from your machine. 
  1150.  
  1151.  To make this all easier a small function doing these three steps exists. 
  1152.  SayText simply takes a string of text, synthesizes it and sends it to the 
  1153.  audio device. 
  1154.  
  1155.                       festival> (SayText "Good morning, welcome to Festival")
  1156.                       #<Utterance 1d8fd0>
  1157.                       festival>
  1158.  Of course as history and command line editing are supported c-p or up-arrow 
  1159.  will allow you to edit the above to whatever you wish. 
  1160.  
  1161.  Festival may also synthesize from files rather than simply text. 
  1162.  
  1163.                       festival> (tts "myfile" nil)
  1164.                       nil
  1165.                       festival>
  1166.  The end of file character c-d will exit from Festival and return you to the 
  1167.  shell, alternatively the command quit may be called (don't forget the 
  1168.  parentheses). 
  1169.  
  1170.  Rather than starting the command interpreter, Festival may synthesize files 
  1171.  specified on the command line 
  1172.  
  1173.                       unix$ festival --tts myfile
  1174.                       unix$
  1175.  
  1176.  Sometimes a simple waveform is required from text that is to be kept and 
  1177.  played at some later time.  The simplest way to do this with festival is by 
  1178.  using the 'text2wave' program.  This is a festival script that will take a 
  1179.  file (or text from standard input) and produce a single waveform. 
  1180.  
  1181.  An example use is 
  1182.  
  1183.                       text2wave myfile.txt -o myfile.wav
  1184.  Options exist to specify the waveform file type, for example if Sun audio 
  1185.  format is required 
  1186.  
  1187.                       text2wave myfile.txt -otype snd -o myfile.wav
  1188.  Use '-h' on 'text2wave' to see all options. 
  1189.  
  1190.  
  1191. ΓòÉΓòÉΓòÉ 8.3. Getting some help ΓòÉΓòÉΓòÉ
  1192.  
  1193.  If no audio is generated then you must check to see if audio is properly 
  1194.  initialized on your machine. See Audio output. 
  1195.  
  1196.  In the command interpreter m-h (meta-h) will give you help on the current 
  1197.  symbol before the cursor.  This will be a short description of the function or 
  1198.  variable, how to use it and what its arguments are.  A listing of all such 
  1199.  help strings appears at the end of this document.  m-s will synthesize and say 
  1200.  the same information, but this extra function is really just for show. 
  1201.  
  1202.  The lisp function manual will send the appropriate command to an already 
  1203.  running Netscape browser process.  If nil is given as an argument the browser 
  1204.  will be directed to the tables of contents of the manual.  If a non-nil value 
  1205.  is given it is assumed to be a section title and that section is searched and 
  1206.  if found displayed.  For example 
  1207.  
  1208.                       festival> (manual "Accessing an utterance")
  1209.  Another related function is manual-sym which given a symbol will check its 
  1210.  documentation string for a cross reference to a manual section and request 
  1211.  Netscape to display it.  This function is bound to m-m and will display the 
  1212.  appropriate section for the given symbol. 
  1213.  
  1214.  Note also that the TAB key can be used to find out the name of commands 
  1215.  available as can the function Help (remember the parentheses). 
  1216.  
  1217.  For more up to date information on Festival regularly check the Festival Home 
  1218.  Page at 
  1219.  
  1220.                       http://www.cstr.ed.ac.uk/projects/festival.html
  1221.  
  1222.  Further help is available by mailing questions to 
  1223.  
  1224.                       festival-help@cstr.ed.ac.uk
  1225.  Although we cannot guarantee the time required to answer you, we will do our 
  1226.  best to offer help. 
  1227.  
  1228.  Bug reports should be submitted to 
  1229.  
  1230.                       festival-bug@cstr.ed.ac.uk
  1231.  
  1232.  If there is enough user traffic a general mailing list will be created so all 
  1233.  users may share comments and receive announcements. In the mean time watch the 
  1234.  Festival Home Page for news. 
  1235.  
  1236.  
  1237. ΓòÉΓòÉΓòÉ 9. Scheme ΓòÉΓòÉΓòÉ
  1238.  
  1239.  Many people seem daunted by the fact that Festival uses Scheme as its 
  1240.  scripting language and feel they can't use Festival because they don't know 
  1241.  Scheme.  However most of those same people use Emacs everyday which also has 
  1242.  (a much more complex) Lisp system underneath.  The number of Scheme commands 
  1243.  you actually need to know in Festival is really very small and you can easily 
  1244.  just find out as you go along.  Also people use the Unix shell often but only 
  1245.  know a small fraction of actual commands available in the shell (or in fact 
  1246.  that there even is a distinction between shell builtin commands and user 
  1247.  definable ones).  So take it easy, you'll learn the commands you need fairly 
  1248.  quickly. 
  1249.  
  1250.  Scheme references             Places to learn more about Scheme 
  1251.  Scheme fundamentals           Syntax and semantics 
  1252.  Scheme Festival specifics 
  1253.  Scheme I/O 
  1254.  
  1255.  
  1256. ΓòÉΓòÉΓòÉ 9.1. Scheme references ΓòÉΓòÉΓòÉ
  1257.  
  1258.  If you wish to learn about Scheme in more detail I recommend the book 
  1259.  abelson85. 
  1260.  
  1261.  The Emacs Lisp documentation is reasonable as it is comprehensive and many of 
  1262.  the underlying uses of Scheme in Festival were influenced by Emacs.  Emacs 
  1263.  Lisp however is not Scheme so there are some differences. 
  1264.  
  1265.  Other Scheme tutorials and resources available on the Web are 
  1266.  
  1267.      The Revised Revised Revised Revised Scheme Report, the document defining 
  1268.       the language is available from 
  1269.  
  1270.                       http://tinuviel.cs.wcu.edu/res/ldp/r4rs-html/r4rs_toc.html
  1271.  
  1272.      a Scheme tutorials from the net: 
  1273.  
  1274.         -  http://www.cs.uoregon.edu/classes/cis425/schemeTutorial.html 
  1275.  
  1276.      the Scheme FAQ 
  1277.  
  1278.         -  http://www.landfield.com/faqs/scheme-faq/part1/ 
  1279.  
  1280.  
  1281. ΓòÉΓòÉΓòÉ 9.2. Scheme fundamentals ΓòÉΓòÉΓòÉ
  1282.  
  1283.  But you want more now, don't you, not just be referred to some other book.  OK 
  1284.  here goes. 
  1285.  
  1286.  Syntax: an expression is an atom or a list.  A list consists of a left paren, 
  1287.  a number of expressions and right paren.  Atoms can be symbols, numbers, 
  1288.  strings or other special types like functions, hash tables, arrays, etc. 
  1289.  
  1290.  Semantics:  All expressions can be evaluated.  Lists are evaluated as function 
  1291.  calls.  When evaluating a list all the members of the list are evaluated first 
  1292.  then the first item (a function) is called with the remaining items in the 
  1293.  list as arguments. Atoms are evaluated depending on their type: symbols are 
  1294.  evaluated as variables returning their values.  Numbers, strings, functions, 
  1295.  etc. evaluate to themselves. 
  1296.  
  1297.  Comments are started by a semicolon and run until end of line. 
  1298.  
  1299.  And that's it. There is nothing more to the language that.  But just in case 
  1300.  you can't follow the consequences of that, here are some key examples. 
  1301.  
  1302.                       festival> (+ 2 3)
  1303.                       5
  1304.                       festival> (set! a 4)
  1305.                       4
  1306.                       festival> (* 3 a)
  1307.                       12
  1308.                       festival> (define (add a b) (+ a b))
  1309.                       #<CLOSURE (a b) (+ a b)>
  1310.                       festival> (add 3 4)
  1311.                       7
  1312.                       festival> (set! alist '(apples pears bananas))
  1313.                       (apples pears bananas)
  1314.                       festival> (car alist)
  1315.                       apples
  1316.                       festival> (cdr alist)
  1317.                       (pears bananas)
  1318.                       festival> (set! blist (cons 'oranges alist))
  1319.                       (oranges apples pears bananas)
  1320.                       festival> (append alist blist)
  1321.                       (apples pears bananas oranges apples pears bananas)
  1322.                       festival> (cons alist blist)
  1323.                       ((apples pears bananas) oranges apples pears bananas)
  1324.                       festival> (length alist)
  1325.                       3
  1326.                       festival> (length (append alist blist))
  1327.                       7
  1328.  
  1329.  
  1330. ΓòÉΓòÉΓòÉ 9.3. Scheme Festival specifics ΓòÉΓòÉΓòÉ
  1331.  
  1332.  There a number of additions to SIOD that are Festival specific though still 
  1333.  part of the Lisp system rather than the synthesis functions per se. 
  1334.  
  1335.  By convention if the first statement of a function is a string, it is treated 
  1336.  as a documentation string.  The string will be printed when help is requested 
  1337.  for that function symbol. 
  1338.  
  1339.  In interactive mode if the function :backtrace is called (within parenthesis) 
  1340.  the previous stack trace is displayed.  Calling :backtrace with a numeric 
  1341.  argument will display that particular stack frame in full.  Note that any 
  1342.  command other than :backtrace will reset the trace.  You may optionally call 
  1343.  
  1344.                       (set_backtrace t)
  1345.  Which will cause a backtrace to be displayed whenever a Scheme error occurs. 
  1346.  This can be put in your '.festivalrc' if you wish.  This is especially useful 
  1347.  when running Festival in non-interactive mode (batch or script mode) so that 
  1348.  more information is printed when an error occurs. 
  1349.  
  1350.  A hook in Lisp terms is a position within some piece of code where a user may 
  1351.  specify their own customization.  The notion is used heavily in Emacs.  In 
  1352.  Festival there a number of places where hooks are used.  A hook variable 
  1353.  contains either a function or list of functions that are to be applied at some 
  1354.  point in the processing.  For example the after_synth_hooks are applied after 
  1355.  synthesis has been applied to allow specific customization such as resampling 
  1356.  or modification of the gain of the synthesized waveform.  The Scheme function 
  1357.  apply_hooks takes a hook variable as argument and an object and applies the 
  1358.  function/list of functions in turn to the object. 
  1359.  
  1360.  When an error occurs in either Scheme or within the C++ part of Festival by 
  1361.  default the system jumps to the top level, resets itself and continues.  Note 
  1362.  that errors are usually serious things, pointing to bugs in parameters or 
  1363.  code.  Every effort has been made to ensure that the processing of text never 
  1364.  causes errors in Festival. However when using Festival as a development system 
  1365.  it is often that errors occur in code. 
  1366.  
  1367.  Sometimes in writing Scheme code you know there is a potential for an error 
  1368.  but you wish to ignore that and continue on to the next thing without exiting 
  1369.  or stopping and returning to the top level.  For example you are processing a 
  1370.  number of utterances from a database and some files containing the 
  1371.  descriptions have errors in them but you want your processing to continue 
  1372.  through every utterance that can be processed rather than stopping 5 minutes 
  1373.  after you gone home after setting a big batch job for overnight. 
  1374.  
  1375.  Festival's Scheme provides the function unwind-protect which allows the 
  1376.  catching of errors and then continuing normally.  For example suppose you have 
  1377.  the function process_utt which takes a filename and does things which you know 
  1378.  might cause an error.  You can write the following to ensure you continue 
  1379.  processing even in an error occurs. 
  1380.  
  1381.                       (unwind-protect
  1382.                        (process_utt filename)
  1383.                        (begin
  1384.                         (format t "Error found in processing %s\n" filename)
  1385.                         (format t "continuing\n")))
  1386.  The unwind-protect function takes two arguments.  The first is evaluated and 
  1387.  if no error occurs the value returned from that expression is returned.  If an 
  1388.  error does occur while evaluating the first expression, the second expression 
  1389.  is evaluated.  unwind-protect may be used recursively.  Note that all files 
  1390.  opened while evaluating the first expression are closed if an error occurs. 
  1391.  All global variables outside the scope of the unwind-protect will be left as 
  1392.  they were set up until the error.  Care should be taken in using this function 
  1393.  but its power is necessary to be able to write robust Scheme code. 
  1394.  
  1395.  
  1396. ΓòÉΓòÉΓòÉ 9.4. Scheme I/O ΓòÉΓòÉΓòÉ
  1397.  
  1398.  Different Scheme's may have quite different implementations of file i/o 
  1399.  functions so in this section we will describe the basic functions in Festival 
  1400.  SIOD regarding i/o. 
  1401.  
  1402.  Simple printing to the screen may be achieved with the function print which 
  1403.  prints the given s-expression to the screen. The printed form is preceded by a 
  1404.  new line.  This is often useful for debugging but isn't really powerful enough 
  1405.  for much else. 
  1406.  
  1407.  Files may be opened and closed and referred to file descriptors in a direct 
  1408.  analogy to C's stdio library.  The SIOD functions fopen and fclose work in the 
  1409.  exactly the same way as their equivalently named partners in C. 
  1410.  
  1411.  The format command follows the command of the same name in Emacs and a number 
  1412.  of other Lisps.  C programmers can think of it as fprintf.  format takes a 
  1413.  file descriptor, format string and arguments to print.  The file description 
  1414.  may be a file descriptor as returned by the Scheme function fopen, it may also 
  1415.  be t which means the output will be directed as standard out (cf. printf).  A 
  1416.  third possibility is nil which will cause the output to printed to a string 
  1417.  which is returned (cf. sprintf). 
  1418.  
  1419.  The format string  closely follows the format strings in ANSI C, but it is not 
  1420.  the same.  Specifically the directives currently supported are, %%, %d, %x, 
  1421.  %s, %f, %g and %c.  All modifiers for these are also supported.  In addition 
  1422.  %l is provided for printing of Scheme objects as objects. 
  1423.  
  1424.  For example 
  1425.  
  1426.                       (format t "%03d %3.4f %s %l %l %l\n" 23 23 "abc" "abc" '(a b d) utt1)
  1427.  will produce 
  1428.  
  1429.                       023 23.0000 abc "abc" (a b d) #<Utterance 32f228>
  1430.  on standard output. 
  1431.  
  1432.  When large lisp expressions are printed they are difficult to read because of 
  1433.  the parentheses.  The function pprintf prints an expression to a file 
  1434.  description (or t for standard out).  It prints so the s-expression is nicely 
  1435.  lined up and indented.  This is often called pretty printing in Lisps. 
  1436.  
  1437.  For reading input from terminal or file, there is currently no equivalent to 
  1438.  scanf.  Items may only be read as Scheme expressions.  The command 
  1439.  
  1440.                       (load FILENAME t)
  1441.  will load all s-expressions in FILENAME and return them, unevaluated as a 
  1442.  list.  Without the third argument  the load function will load and evaluate 
  1443.  each s-expression in the file. 
  1444.  
  1445.  To read individual s-expressions use readfp.  For example 
  1446.  
  1447.                       (let ((fd (fopen trainfile "r"))
  1448.                          (entry)
  1449.                          (count 0))
  1450.                         (while (not (equal? (set! entry (readfp fd)) (eof-val)))
  1451.                          (if (string-equal (car entry) "home")
  1452.                           (set! count (+ 1 count))))
  1453.                         (fclose fd))
  1454.  
  1455.  To convert a symbol whose print name is a number to a number use parse-number. 
  1456.  This is the equivalent to atof in C. 
  1457.  
  1458.  Note that, all i/o from Scheme input files is assumed to be basically some 
  1459.  form of Scheme data (though can be just numbers, tokens).  For more elaborate 
  1460.  analysis of incoming data it is possible to use the text tokenization 
  1461.  functions which offer a fully programmable method of reading data. 
  1462.  
  1463.  
  1464. ΓòÉΓòÉΓòÉ 10. TTS ΓòÉΓòÉΓòÉ
  1465.  
  1466.  Festival supports text to speech for raw text files.  If you are not 
  1467.  interested in using Festival in any other way except as black box for 
  1468.  rendering text as speech, the following method is probably what you want. 
  1469.  
  1470.                       festival --tts myfile
  1471.  This will say the contents of 'myfile'.  Alternatively text may be submitted 
  1472.  on standard input 
  1473.  
  1474.                       echo hello world | festival --tts
  1475.                       cat myfile | festival --tts
  1476.  
  1477.  Festival supports the notion of text modes where the text file type may be 
  1478.  identified, allowing Festival to process the file in an appropriate way. 
  1479.  Currently only two types are considered stable: STML and raw, but other types 
  1480.  such as email, HTML, Latex, etc. are being developed and discussed below. This 
  1481.  follows the idea of buffer modes in Emacs where a file's type can be utilized 
  1482.  to best display the text.  Text mode may also be selected based on a 
  1483.  filename's extension. 
  1484.  
  1485.  Within the command interpreter the function tts is used to render files as 
  1486.  text; it takes a filename and the text mode as arguments. 
  1487.  
  1488.  Utterance chunking            From text to utterances 
  1489.  Text modes                    Mode specific text analysis 
  1490.  Example text mode             An example mode for reading email 
  1491.  
  1492.  
  1493. ΓòÉΓòÉΓòÉ 10.1. Utterance chunking ΓòÉΓòÉΓòÉ
  1494.  
  1495.  Text to speech works by first tokenizing the file and chunking the tokens into 
  1496.  utterances.  The definition of utterance breaks is determined by the utterance 
  1497.  tree in variable eou_tree.  A default version is given in 'lib/tts.scm'.  This 
  1498.  uses a decision tree to determine what signifies an utterance break. 
  1499.  Obviously blank lines are probably the most reliable, followed by certain 
  1500.  punctuation.  The confusion of the use of periods for both sentence breaks and 
  1501.  abbreviations requires some more heuristics to best guess their different use. 
  1502.  The following tree is currently used which works better than simply using 
  1503.  punctuation. 
  1504.  
  1505.                       (defvar eou_tree
  1506.                       '((n.whitespace matches ".*\n.*\n\\(.\\|\n\\)*") ;; 2 or more newlines
  1507.                        ((1))
  1508.                        ((punc in ("?" ":" "!"))
  1509.                         ((1))
  1510.                         ((punc is ".")
  1511.                         ;; This is to distinguish abbreviations vs periods
  1512.                         ;; These are heuristics
  1513.                         ((name matches "\\(.*\\┬╖┬╖*\\|[A-Z][A-Za-z]?[A-Za-z]?\\|etc\\)")
  1514.                          ((n.whitespace is " ")
  1515.                          ((0))          ;; if abbrev single space isn't enough for break
  1516.                          ((n.name matches "[A-Z].*")
  1517.                           ((1))
  1518.                           ((0))))
  1519.                          ((n.whitespace is " ")  ;; if it doesn't look like an abbreviation
  1520.                          ((n.name matches "[A-Z].*")  ;; single space and non-cap is no break
  1521.                           ((1))
  1522.                           ((0)))
  1523.                          ((1))))
  1524.                         ((0)))))
  1525.  The token items this is applied to will always (except in the end of file 
  1526.  case) include one following token, so look ahead is possible.  The "n." and 
  1527.  "p." and "p.p." prefixes allow access to the surrounding token context.  The 
  1528.  features name, whitespace and punc allow access to the contents of the token 
  1529.  itself.  At present there is no way to access the lexicon form this tree which 
  1530.  unfortunately might be useful if certain abbreviations were identified as such 
  1531.  there. 
  1532.  
  1533.  Note these are heuristics and written by hand not trained from data, though 
  1534.  problems have been fixed as they have been observed in data.  The above rules 
  1535.  may make mistakes where abbreviations appear at end of lines, and when 
  1536.  improper spacing and capitalization is used.  This is probably worth changing, 
  1537.  for modes where more casual text appears, such as email messages and USENET 
  1538.  news messages.  A possible improvement could be made by analysing a text to 
  1539.  find out its basic threshold of utterance break (i.e. if no full stop, two 
  1540.  spaces, followed by a capitalized word sequences appear and the text is of a 
  1541.  reasonable length then look for other criteria for utterance breaks). 
  1542.  
  1543.  Ultimately what we are trying to do is to chunk the text into utterances that 
  1544.  can be synthesized quickly and start to play them quickly to minimise the time 
  1545.  someone has to wait for the first sound when starting synthesis.  Thus it 
  1546.  would be better if this chunking were done on prosodic phrases rather than 
  1547.  chunks more similar to linguistic sentences.  Prosodic phrases are bounded in 
  1548.  size, while sentences are not. 
  1549.  
  1550.  
  1551. ΓòÉΓòÉΓòÉ 10.2. Text modes ΓòÉΓòÉΓòÉ
  1552.  
  1553.  We do not believe that all texts are of the same type.  Often information 
  1554.  about the general contents of file will aid synthesis greatly.  For example in 
  1555.  Latex files we do not want to here "left brace, backslash e m" before each 
  1556.  emphasized word, nor do we want to necessarily hear formating commands. 
  1557.  Festival offers a basic method for specifying customization rules depending on 
  1558.  the mode of the text.  By type we are following the notion of modes in Emacs 
  1559.  and eventually will allow customization at a similar level. 
  1560.  
  1561.  Modes are specified as the third argument to the function tts. When using the 
  1562.  Emacs interface to Festival the buffer mode is automatically passed as the 
  1563.  text mode.  If the mode is not supported a warning message is printed and the 
  1564.  raw text mode is used. 
  1565.  
  1566.  Our initial text mode implementation allows configuration both in C++ and in 
  1567.  Scheme.  Obviously in C++ almost anything can be done but it is not as easy to 
  1568.  reconfigure without recompilation.  Here we will discuss those modes which can 
  1569.  be fully configured at run time. 
  1570.  
  1571.  A text mode may contain the following 
  1572.  
  1573.  filter    A Unix shell program filter that processes the text file in some 
  1574.            appropriate way.  For example for email it might remove 
  1575.            uninteresting headers and just output the subject, from line and the 
  1576.            message body. If not specified, an identity filter is used. 
  1577.  
  1578.  init_functionThis (Scheme) function will be called before any processing will 
  1579.            be done.  It allows further set up of tokenization rules and voices 
  1580.            etc. 
  1581.  
  1582.  exit_functionThis (Scheme) function will be called at the end of any 
  1583.            processing allowing reseting of tokenization rules etc. 
  1584.  
  1585.  analysis_modeIf analysis mode is xml the file is read through the built in XML 
  1586.            parser rxp.  Alternatively if analysis mode is xxml the filter 
  1587.            should an SGML normalising parser and the output is processed in a 
  1588.            way suitable for it.  Any other value is ignored. 
  1589.  These mode specific parameters are specified in the a-list held in 
  1590.  tts_text_modes. 
  1591.  
  1592.  When using Festival in Emacs the emacs buffer mode is passed to Festival as 
  1593.  the text mode. 
  1594.  
  1595.  Note that above mechanism is not really designed to be re-entrant, this should 
  1596.  be addressed in later versions. 
  1597.  
  1598.  Following the use of auto-selection of mode in Emacs, Festival can auto-select 
  1599.  the text mode based on the filename given when no explicit mode is given.  The 
  1600.  Lisp variable auto-text-mode-alist is a list of dotted pairs of regular 
  1601.  expression and mode name.  For example to specify that the email mode is to be 
  1602.  used for files ending in '.email' we would add to the current 
  1603.  auto-text-mode-alist as follows 
  1604.  
  1605.                       (set! auto-text-mode-alist
  1606.                          (cons (cons "\\.email$" 'email)
  1607.                             auto-text-mode-alist))
  1608.  If the function tts is called with a mode other than nil that mode overrides 
  1609.  any specified by the auto-text-mode-alist. The mode fundamental is the 
  1610.  explicit "null" mode, it is used when no mode is specified in the function 
  1611.  tts, and match is found in auto-text-mode-alist or the specified mode is not 
  1612.  found. 
  1613.  
  1614.  By convention if a requested text model is not found in tts_text_modes the 
  1615.  file 'MODENAME-mode' will be required.  Therefore if you have the file 
  1616.  'MODENAME-mode.scm' in your library then it will be automatically loaded on 
  1617.  reference.  Modes may be quite large and it is not necessary have Festival 
  1618.  load them all at start up time. 
  1619.  
  1620.  Because of the auto-text-mode-alist and the auto loading of currently 
  1621.  undefined text modes you can use Festival like 
  1622.  
  1623.                       festival --tts example.email
  1624.  Festival with automatically synthesize 'example.email' in text mode email. 
  1625.  
  1626.  If you add your own personal text modes you should do the following. Suppose 
  1627.  you've written an HTML mode.  You have named it 'html-mode.scm' and put it in 
  1628.  '/home/awb/lib/festival/'.  In your '.festivalrc' first identify you're 
  1629.  personal Festival library directory by adding it to lib-path. 
  1630.  
  1631.                       (set! lib-path (cons "/home/awb/lib/festival/" lib-path))
  1632.  Then add the definition to the auto-text-mode-alist that file names ending 
  1633.  '.html' or '.htm' should be read in HTML mode. 
  1634.  
  1635.                       (set! auto-text-mode-alist
  1636.                          (cons (cons "\\.html?$" 'html)
  1637.                             auto-text-mode-alist))
  1638.  Then you may synthesize an HTML file either from Scheme 
  1639.  
  1640.                       (tts "example.html" nil)
  1641.  Or from the shell command line 
  1642.  
  1643.                       festival --tts example.html
  1644.  Anyone familiar with modes in Emacs should recognise that the process of 
  1645.  adding a new text mode to Festival is very similar to adding a new buffer mode 
  1646.  to Emacs. 
  1647.  
  1648.  
  1649. ΓòÉΓòÉΓòÉ 10.3. Example text mode ΓòÉΓòÉΓòÉ
  1650.  
  1651.  Here is a short example of a tts mode for reading email messages.  It is by no 
  1652.  means complete but is a start at showing how you can customize tts modes 
  1653.  without writing new C++ code. 
  1654.  
  1655.  The first task is to define a filter that will take a saved mail message and 
  1656.  remove extraneous headers and just leave the from line, subject and body of 
  1657.  the message.  The filter program is given a file name as its first argument 
  1658.  and should output the result on standard out.  For our purposes we will do 
  1659.  this as a shell script. 
  1660.  
  1661.                       #!/bin/sh
  1662.                       #  Email filter for Festival tts mode
  1663.                       #  usage: email_filter mail_message >tidied_mail_message
  1664.                       grep "^From: " $1
  1665.                       echo
  1666.                       grep "^Subject: " $1
  1667.                       echo
  1668.                       # delete up to first blank line (i.e. the header)
  1669.                       sed '1,/^$/ d' $1
  1670.  Next we define the email init function, which will be called when we start 
  1671.  this mode.  What we will do is save the current token to words function and 
  1672.  slot in our own new one.  We can then restore the previous one when we exit. 
  1673.  
  1674.                       (define (email_init_func)
  1675.                        "Called on starting email text mode."
  1676.                        (set! email_previous_t2w_func token_to_words)
  1677.                        (set! english_token_to_words email_token_to_words)
  1678.                        (set! token_to_words email_token_to_words))
  1679.  Note that both english_token_to_words and token_to_words should be set to 
  1680.  ensure that our new token to word function is still used when we change 
  1681.  voices. 
  1682.  
  1683.  The corresponding end function puts the token to words function back. 
  1684.  
  1685.                       (define (email_exit_func)
  1686.                        "Called on exit email text mode."
  1687.                        (set! english_token_to_words email_previous_t2w_func)
  1688.                        (set! token_to_words email_previous_t2w_func))
  1689.  Now we can define the email specific token to words function.  In this example 
  1690.  we deal with two specific cases.  First we deal with the common form of email 
  1691.  addresses so that the angle brackets are not pronounced. The second points are 
  1692.  to recognise quoted text and immediately change the the speaker to the 
  1693.  alternative speaker. 
  1694.  
  1695.                       (define (email_token_to_words token name)
  1696.                        "Email specific token to word rules."
  1697.                        (cond
  1698.  This first condition identifies the token as a bracketed email address and 
  1699.  removes the brackets and splits the token into name and IP address.  Note that 
  1700.  we recursively call the function email_previous_t2w_func on the email name and 
  1701.  IP address so that they will be pronounced properly.  Note that because that 
  1702.  function returns a list of words we need to append them together. 
  1703.  
  1704.                         ((string-matches name "<.*.*>")
  1705.                          (append
  1706.                          (email_previous_t2w_func token
  1707.                           (string-after (string-before name "@") "<"))
  1708.                          (cons
  1709.                           "at"
  1710.                           (email_previous_t2w_func token
  1711.                           (string-before (string-after name "@") ">")))))
  1712.  Our next condition deals with identifying a greater than sign being used as a 
  1713.  quote marker.  When we detect this we select the alternative speaker, even 
  1714.  though it may already be selected.  We then return no words so the quote 
  1715.  marker is not spoken.  The following condition finds greater than signs which 
  1716.  are the first token on a line. 
  1717.  
  1718.                         ((and (string-matches name ">")
  1719.                            (string-matches (item.feat token "whitespace")
  1720.                                    "[ \t\n]*\n *"))
  1721.                         (voice_don_diphone)
  1722.                         nil ;; return nothing to say
  1723.                         )
  1724.  If it doesn't match any of these we can go ahead and use the builtin token to 
  1725.  words function  Actually, we call the function that was set before we entered 
  1726.  this mode to ensure any other specific rules still remain.  But before that we 
  1727.  need to check if we've had a newline with doesn't start with a greater than 
  1728.  sign.  In that case we switch back to the primary speaker. 
  1729.  
  1730.                         (t  ;; for all other cases
  1731.                          (if (string-matches (item.feat token "whitespace")
  1732.                                    ".*\n[ \t\n]*")
  1733.                            (voice_rab_diphone))
  1734.                          (email_previous_t2w_func token name))))
  1735.  In addition to these we have to actually declare the text mode. This we do by 
  1736.  adding to any existing modes as follows. 
  1737.  
  1738.                       (set! tts_text_modes
  1739.                         (cons
  1740.                         (list
  1741.                          'email  ;; mode name
  1742.                          (list     ;; email mode params
  1743.                           (list 'init_func email_init_func)
  1744.                           (list 'exit_func email_exit_func)
  1745.                           '(filter "email_filter")))
  1746.                         tts_text_modes))
  1747.  This will now allow simple email messages to be dealt with in a mode specific 
  1748.  way. 
  1749.  
  1750.  An example mail message is included in 'examples/ex1.email'.  To hear the 
  1751.  result of the above text mode start Festival, load in the email mode 
  1752.  descriptions,  and call TTS on the example file. 
  1753.  
  1754.                       (tts "┬╖┬╖┬╖/examples/ex1.email" 'email)
  1755.  
  1756.  The above is very short of a real email mode but does illustrate how one might 
  1757.  go about building one.  It should be reiterated that text modes are new in 
  1758.  Festival and their most effective form has not been discovered yet.  This will 
  1759.  improve with time and experience. 
  1760.  
  1761.  
  1762. ΓòÉΓòÉΓòÉ 11. XML/SGML mark-up ΓòÉΓòÉΓòÉ
  1763.  
  1764.  The ideas of a general, synthesizer system nonspecific, mark-up language for 
  1765.  labelling text has been under discussion for some time.  Festival has 
  1766.  supported an SGML based markup language through multiple versions most 
  1767.  recently STML (sproat97).  This is based on the earlier SSML (Speech Synthesis 
  1768.  Markup Language) which was supported by previous versions of Festival 
  1769.  (taylor96).  With this version of Festival we support Sable a similar mark-up 
  1770.  language devised by a consortium from Bell Labls, Sub Microsystems, AT&T and 
  1771.  Edinburgh, sable98.  Unlike the previous versions which were SGML based, the 
  1772.  implementation of Sable in Festival is now XML based.  To the user they 
  1773.  different is negligable but using XML makes processing of files easier and 
  1774.  more standardized.  Also Festival now includes an XML parser thus reducing the 
  1775.  dependencies in processing Sable text. 
  1776.  
  1777.  Raw text has the problem that it cannot always easily be rendered as speech in 
  1778.  the way the author wishes.  Sable offers a well-defined way of marking up text 
  1779.  so that the synthesizer may render it appropriately. 
  1780.  
  1781.  The definition of Sable is by no means settled and is still in development. 
  1782.  In this release Festival offers people working on Sable and other XML (and 
  1783.  SGML) based markup languages a chance to quickly experiment with prototypes by 
  1784.  providing a DTD (document type descriptions) and the mapping of the elements 
  1785.  in the DTD to Festival functions.  Although we have not yet (personally) 
  1786.  investigated facilities like cascading style sheets and generalized SGML 
  1787.  specification languages like DSSSL we believe the facilities offer by Festival 
  1788.  allow rapid prototyping of speech output markup languages. 
  1789.  
  1790.  Primarily we see Sable markup text as a language that will be generated by 
  1791.  other programs, e.g. text generation systems, dialog managers etc. therefore a 
  1792.  standard, easy to parse, format is required, even if it seems overly verbose 
  1793.  for human writers. 
  1794.  
  1795.  For more information of Sable and access to the mailing list see 
  1796.  
  1797.                       http://www.cstr.ed.ac.uk/projects/sable.html
  1798.  
  1799.  Sable example                 an example of Sable with descriptions 
  1800.  Supported Sable tags          Currently supported Sable tags 
  1801.  Adding Sable tags             Adding new Sable tags 
  1802.  XML/SGML requirements         Software environment requirements for use 
  1803.  Using Sable                   Rendering Sable files as speech 
  1804.  
  1805.  
  1806. ΓòÉΓòÉΓòÉ 11.1. Sable example ΓòÉΓòÉΓòÉ
  1807.  
  1808.  Here is a simple example of Sable marked up text 
  1809.  
  1810.                       <?xml version="1.0"?>
  1811.                       <!DOCTYPE SABLE PUBLIC "-//SABLE//DTD SABLE speech mark up//EN"
  1812.                          "Sable.v0_2.dtd"
  1813.                       []>
  1814.                       <SABLE>
  1815.                       <SPEAKER NAME="male1">
  1816.                       The boy saw the girl in the park <BREAK/> with the telescope.
  1817.                       The boy saw the girl <BREAK/> in the park with the telescope.
  1818.                       Good morning <BREAK /> My name is Stuart, which is spelled
  1819.                       <RATE SPEED="-40%">
  1820.                       <SAYAS MODE="literal">stuart</SAYAS> </RATE>
  1821.                       though some people pronounce it
  1822.                       <PRON SUB="stoo art">stuart</PRON>.  My telephone number
  1823.                       is <SAYAS MODE="literal">2787</SAYAS>.
  1824.                       I used to work in <PRON SUB="Buckloo">Buccleuch</PRON> Place,
  1825.                       but no one can pronounce that.
  1826.                       By the way, my telephone number is actually
  1827.                       <AUDIO SRC="http://www.cstr.ed.ac.uk/~awb/sounds/touchtone.2.au"/>
  1828.                       <AUDIO SRC="http://www.cstr.ed.ac.uk/~awb/sounds/touchtone.7.au"/>
  1829.                       <AUDIO SRC="http://www.cstr.ed.ac.uk/~awb/sounds/touchtone.8.au"/>
  1830.                       <AUDIO SRC="http://www.cstr.ed.ac.uk/~awb/sounds/touchtone.7.au"/>.
  1831.                       </SPEAKER>
  1832.                       </SABLE>
  1833.  After the initial definition of the SABLE tags, through the file 
  1834.  'Sable.v0_2.dtd', which is distributed as part of Festival, the body is given. 
  1835.  There are tags for identifying the language and the voice.  Explicit boundary 
  1836.  markers may be given in text.  Also duration and intonation control can be 
  1837.  explicit specified as can new pronunciations of words.  The last sentence 
  1838.  specifies some external filenames to play at that point. 
  1839.  
  1840.  
  1841. ΓòÉΓòÉΓòÉ 11.2. Supported Sable tags ΓòÉΓòÉΓòÉ
  1842.  
  1843.  There is not yet a definitive set of tags but hopefully such a list will form 
  1844.  over the next few months.  As adding support for new tags is often trivial the 
  1845.  problem lies much more in defining what tags there should be than in actually 
  1846.  implementing them.   The following are based on version 0.2 of Sable as 
  1847.  described in http://www.cstr.ed.ac.uk/projects/sable_spec2.html, though some 
  1848.  aspects are not currently supported in this implementation. Further updates 
  1849.  will be announces through the Sable mailing list. 
  1850.  
  1851.  LANGUAGE  Allows the specification of the language through the ID attribute. 
  1852.            Valid values in Festival are, english, en1, spanish, en, and others 
  1853.            depending on your particular installation. For example 
  1854.  
  1855.                       <LANGUAGE id="english"> ┬╖┬╖┬╖ </LANGUAGE>
  1856.  If the language isn't supported by the particualr installation of Festival 
  1857.  "Some text in ┬╖┬╖" is said instead and the section is ommitted. 
  1858.  
  1859.  SPEAKER   Select a voice.  Accepts a parameter NAME which takes values male1, 
  1860.            male2, female1,  etc.  There is currently no definition about what 
  1861.            happens when a voice is selected which the synthesizer doesn't 
  1862.            support.  An example is 
  1863.  
  1864.                       <SPEAKER name="male1"> ┬╖┬╖┬╖ </SPEAKER>
  1865.  
  1866.  AUDIO     This allows the specification of an external waveform that is to be 
  1867.            included.  There are attributes for specifying volume and whether 
  1868.            the waveform is to be played in the background of the following text 
  1869.            or not.  Festival as yet only supports insertion. 
  1870.  
  1871.                       My telephone number is
  1872.                       <AUDIO SRC="http://www.cstr.ed.ac.uk/~awb/sounds/touchtone.2.au"/>
  1873.                       <AUDIO SRC="http://www.cstr.ed.ac.uk/~awb/sounds/touchtone.7.au"/>
  1874.                       <AUDIO SRC="http://www.cstr.ed.ac.uk/~awb/sounds/touchtone.8.au"/>
  1875.                       <AUDIO SRC="http://www.cstr.ed.ac.uk/~awb/sounds/touchtone.7.au"/>.
  1876.  
  1877.  MARKER    This allows Festival to mark when a particalur part of the text has 
  1878.            been reached.  At present the simply the value of the MARK attribute 
  1879.            is printed.  This is done some when that piece of text is analyzed. 
  1880.            not when it is played.  To use this in any real application would 
  1881.            require changes to this tags implementation. 
  1882.  
  1883.                       Move the <MARKER MARK="mouse" /> mouse to the top.
  1884.  
  1885.  BREAK     Specifies a boundary at some LEVEL.  Strength may be values Large, 
  1886.            Medium, Small or a number.  Note that this this tag is an emtpy tag 
  1887.            and must include the closing part within itsefl specification. 
  1888.  
  1889.                       <BREAK LEVEL="LARGE"/>
  1890.  
  1891.  DIV       This signals an division.  In Festival this causes an utterance 
  1892.            break.  A TYPE attribute may be specified but it is ignored by 
  1893.            Festival. 
  1894.  
  1895.  PRON      Allows pronunciation of enclosed text to be explcitily given.  It 
  1896.            supports the attributes IPA for an IPA specification (not currently 
  1897.            supported by Festival); SUB text to be substituted which can be in 
  1898.            some form of phonetic spelling, and ORIGIN where the linguistic 
  1899.            origin of the enclosed text may be identified to assist in 
  1900.            etymologically sensitive letter to sound rules. 
  1901.  
  1902.                       <PRON SUB="toe maa toe">tomato</PRON>
  1903.  
  1904.  SAYAS     Allows indeitnfication of the enclose tokens/text.  The attribute 
  1905.            MODE cand take any of the following a values: literal, date, time, 
  1906.            phone, net, postal, currency, math, fraction, measure, ordinal, 
  1907.            cardinal, or name.  Further specification of type for dates (MDY, 
  1908.            DMY etc) may be speficied through the MODETYPE attribute. 
  1909.  
  1910.                       As a test of marked-up numbers. Here we have
  1911.                       a year <SAYAS MODE="date">1998</SAYAS>,
  1912.                       an ordinal <SAYAS MODE="ordinal">1998</SAYAS>,
  1913.                       a cardinal <SAYAS MODE="cardinal">1998</SAYAS>,
  1914.                       a literal <SAYAS MODE="literal">1998</SAYAS>,
  1915.                       and phone number <SAYAS MODE="phone">1998</SAYAS>.
  1916.  
  1917.  EMPH      To specify enclose text should be emphasized, a LEVEL attribute may 
  1918.            be specified but its value is currently ignored by Festival (besides 
  1919.            the emphasis Festival generates isn't very good anyway). 
  1920.  
  1921.                       The leaders of <EMPH>Denmark</EMPH> and <EMPH>India</EMPH> meet on
  1922.                       Friday.
  1923.  
  1924.  PITCH     Allows the specification of pitch range, mid and base points. 
  1925.  
  1926.                       Without his penguin, <PITCH BASE="-20%"> which he left at home, </PITCH>
  1927.                       he could not enter the restaurant.
  1928.  
  1929.  RATE      Allows the specification of speaking rate 
  1930.  
  1931.                       The address is <RATE SPEED="-40%"> 10 Main Street </RATE>.
  1932.  
  1933.  VOLUME    Allows the specification of volume.  Note in festival this causes an 
  1934.            utetrance break before and after this tag. 
  1935.  
  1936.                       Please speak more <VOLUME LEVEL="loud">loudly</VOLUME>, except
  1937.                       when I ask you to speak <VOLUME LEVEL="quiet">in a quiet voice</VOLUME>.
  1938.  
  1939.  ENGINE    This allows specification of engine specific commands 
  1940.  
  1941.                       An example is <ENGINE ID="festival" DATA="our own festival speech
  1942.                       synthesizer"> the festival speech synthesizer</ENGINE> or
  1943.                       the Bell Labs speech synthesizer.
  1944.  
  1945.  These tags may change in name but they cover the aspects of speech mark up 
  1946.  that we wish to express.  Later additions and changes to these are expected. 
  1947.  
  1948.  See the files 'festival/examples/example.sable' and 
  1949.  'festival/examples/example2.sable' for working examples. 
  1950.  
  1951.  Note the definition of Sable is on going and there are likely to be later more 
  1952.  complete implementations of sable for Festival as independent releases consult 
  1953.  'url://www.cstr.ed.ac.uk/projects/sable.html' for the most recent updates. 
  1954.  
  1955.  
  1956. ΓòÉΓòÉΓòÉ 11.3. Adding Sable tags ΓòÉΓòÉΓòÉ
  1957.  
  1958.  We do not yet claim that there is a fixed standard for Sable tags but we wish 
  1959.  to move towards such a standard.  In the mean time we have made it easy in 
  1960.  Festival to add support for new tags without, in general, having to change any 
  1961.  of the core functions. 
  1962.  
  1963.  Two changes are necessary to add a new tags.  First, change the definition in 
  1964.  'lib/Sable.v0_2.dtd', so that Sable files may use it. The second stage is to 
  1965.  make Festival sensitive to that new tag.  The example in 
  1966.  festival/lib/sable-mode.scm shows how a new text mode may be implemented for 
  1967.  an XML/SGML-based markup language.  The basic point is that an identified 
  1968.  function will be called on finding a start tag or end tags in the document. 
  1969.  It is the tag-function's job to synthesize the given utterance if the tag 
  1970.  signals an utterance boundary. The return value from the tag-function is the 
  1971.  new status of the current utterance, which may remain unchanged or if the 
  1972.  current utterance has been synthesized nil should be returned signalling a new 
  1973.  utterance. 
  1974.  
  1975.  Note the hierarchical structure of the document is not available in this 
  1976.  method of tag-functions.  Any hierarchical state that must be preserved has to 
  1977.  be done using explicit stacks in Scheme.  This is an artifact due to the cross 
  1978.  relationship to utterances and tags (utterances may end within start and end 
  1979.  tags), and the desire to have all specification in Scheme rather than C++. 
  1980.  
  1981.  The tag-functions are defined in an elements list.  They are identified with 
  1982.  names such as "(SABLE" and ")SABLE" denoting start and end tags respectively. 
  1983.  Two arguments are passed to these tag functions, an assoc list of attributes 
  1984.  and values as specified in the document and the current utterances.  If the 
  1985.  tag denotes an utterance break, call xxml_synth on UTT and return nil. If a 
  1986.  tag (start or end) is found in the document and there is no corresponding 
  1987.  tag-function it is ignored. 
  1988.  
  1989.  New features may be added to words with a start and end tag by adding features 
  1990.  to the global xxml_word_features.  Any features in that variable will be added 
  1991.  to each word. 
  1992.  
  1993.  Note that this method may be used for both XML based lamnguages and SGML based 
  1994.  markup languages (though and external normalizing SGML parser is required in 
  1995.  the SGML case).  The type (XML vs SGML) is identified by the analysis_type 
  1996.  parameter in the tts text mode specification. 
  1997.  
  1998.  
  1999. ΓòÉΓòÉΓòÉ 11.4. XML/SGML requirements ΓòÉΓòÉΓòÉ
  2000.  
  2001.  Festival is distributed with rxp an XML parser developed by Richard Tobin of 
  2002.  the Language Technology Group, University of Edinburgh.  Sable is set up as an 
  2003.  XML text mode so no further requirements or external programs are required to 
  2004.  synthesize from Sable marked up text (unlike previous releases).  Note that 
  2005.  rxp is not a full validation parser and hence doesn't check some aspects of 
  2006.  the file (tags within tags). 
  2007.  
  2008.  Festival still supports SGML based markup but in such cases requires an 
  2009.  external SGML normalizing parser.  We have tested 'nsgmls-1.0' which is 
  2010.  available as part of the SGML tools set 'sp-1.1.tar.gz' which is available 
  2011.  from http://www.jclark.com/sp/index.html. This seems portable between many 
  2012.  platforms. 
  2013.  
  2014.  
  2015. ΓòÉΓòÉΓòÉ 11.5. Using Sable ΓòÉΓòÉΓòÉ
  2016.  
  2017.  Support in Festival for Sable is as a text mode.  In the command mode use the 
  2018.  following to process an Sable file 
  2019.  
  2020.                       (tts "file.sable" 'sable)
  2021.  
  2022.  Also the automatic selection of mode based on file type has been set up such 
  2023.  that files ending '.sable' will be automatically synthesized in this mode. 
  2024.  Thus 
  2025.  
  2026.                       festival --tts fred.sable
  2027.  Will render 'fred.sable' as speech in Sable mode. 
  2028.  
  2029.  Another way of using Sable is through the Emacs interface.  The say-buffer 
  2030.  command will send the Emacs buffer mode to Festival as its tts-mode. If the 
  2031.  Emacs mode is stml or sgml the file is treated as an sable file.  See Emacs 
  2032.  interface 
  2033.  
  2034.  Many people experimenting with Sable (and TTS in general) often want all the 
  2035.  waveform output to be saved to be played at a later date.  The simplest way to 
  2036.  do this is using the 'text2wave' script, It respects the audo mode selection 
  2037.  so 
  2038.  
  2039.                       text2wave fred.sable -o fred.wav
  2040.  Note this renders the file a single waveform (done by concatenating the 
  2041.  waveforms for each utterance in the Sable file). 
  2042.  
  2043.  If you wish the waveform for each utterance in a file saved you can cause the 
  2044.  tts process to save the waveforms during synthesis.  A call to 
  2045.  
  2046.                       festival> (save_waves_during_tts)
  2047.  Any future call to tts will cause the waveforms to be saved in a file 
  2048.  'tts_file_xxx.wav' where 'xxx' is a number.  A call to 
  2049.  (save_waves_during_tts_STOP) will stop saving the waves.  A message is printed 
  2050.  when the waveform is saved otherwise people forget about this and wonder why 
  2051.  their disk has filled up. 
  2052.  
  2053.  This is done by inserting a function in tts_hooks which saves the wave.  To do 
  2054.  other things to each utterances during TTS (such as saving the utterance 
  2055.  structure), try redefining the function save_tts_output (see 
  2056.  festival/lib/tts.scm). 
  2057.  
  2058.  
  2059. ΓòÉΓòÉΓòÉ 12. Emacs interface ΓòÉΓòÉΓòÉ
  2060.  
  2061.  One easy method of using Festival is via an Emacs interface that allows 
  2062.  selection of text regions to be sent to Festival for rendering as speech. 
  2063.  
  2064.  'festival.el' offers a new minor mode which offers an extra menu (in emacs-19 
  2065.  and 20) with options for saying a selected region, or a whole buffer, as well 
  2066.  as various general control functions.  To use this you must install 
  2067.  'festival.el' in a directory where Emacs can find it, then add to your 
  2068.  '.emacs' in your home directory the following lines. 
  2069.  
  2070.                       (autoload 'say-minor-mode "festival" "Menu for using Festival." t)
  2071.                       (say-minor-mode t)
  2072.  Successive calls to say-minor-mode will toggle the minor mode, switching the 
  2073.  'say' menu on and off. 
  2074.  
  2075.  Note that the optional voice selection offered by the language sub-menu is not 
  2076.  sensitive to actual voices supported by the your Festival installation.  Hand 
  2077.  customization is require in the 'festival.el' file.  Thus some voices may 
  2078.  appear in your menu that your Festival doesn't support and some voices may be 
  2079.  supported by your Festival that do not appear in the menu. 
  2080.  
  2081.  When the Emacs Lisp function festival-say-buffer or the menu equivalent is 
  2082.  used the Emacs major mode is passed to Festival as the text mode. 
  2083.  
  2084.  
  2085. ΓòÉΓòÉΓòÉ 13. Phonesets ΓòÉΓòÉΓòÉ
  2086.  
  2087.  The notion of phonesets is important to a number of different subsystems 
  2088.  within Festival.  Festival supports multiple phonesets simultaneously and 
  2089.  allows mapping between sets when necessary.  The lexicons, letter to sound 
  2090.  rules, waveform synthesizers, etc. all require the definition of a phoneset 
  2091.  before they will operate. 
  2092.  
  2093.  A phoneset is a set of symbols which may be further defined in terms of 
  2094.  features, such as vowel/consonant, place of articulation for consonants, type 
  2095.  of vowel etc.  The set of features and their values must be defined with the 
  2096.  phoneset.  The definition is used to ensure compatibility between sub-systems 
  2097.  as well as allowing groups of phones in various prediction systems (e.g. 
  2098.  duration) 
  2099.  
  2100.  A phoneset definition has the form 
  2101.  
  2102.                        (defPhoneSet
  2103.                          NAME
  2104.                          FEATUREDEFS
  2105.                          PHONEDEFS )
  2106.  The NAME is any unique symbol used e.g. mrpa, darpa, etc.  FEATUREDEFS is a 
  2107.  list of definitions each consisting of a feature name and its possible values. 
  2108.  For example 
  2109.  
  2110.                         (
  2111.                          (vc + -)       ;; vowel consonant
  2112.                          (vlength short long diphthong schwa 0)  ;; vowel length
  2113.                          ┬╖┬╖┬╖
  2114.                         )
  2115.  The third section is a list of phone definitions themselves.  Each phone 
  2116.  definition consists of a phone name and the values for each feature in the 
  2117.  order the features were defined in the above section. 
  2118.  
  2119.  A typical example of a phoneset definition can be found in 
  2120.  'lib/mrpa_phones.scm'. 
  2121.  
  2122.  Note the phoneset should also include a definition for any silence phones.  In 
  2123.  addition to the definition of the set the silence phone(s) themselves must 
  2124.  also be identified to the system.  This is done through the command 
  2125.  PhoneSet.silences.  In the mrpa set this is done by the command 
  2126.  
  2127.                       (PhoneSet.silences '(#))
  2128.  There may be more than one silence phone (e.g. breath, start silence etc.) in 
  2129.  any phoneset definition.  However the first phone in this set is treated 
  2130.  special and should be canonical silence.  Among other things, it is this phone 
  2131.  that is inserted by the pause prediction module. 
  2132.  
  2133.  In addition to declaring phonesets, alternate sets may be selected by the 
  2134.  command PhoneSet.select. 
  2135.  
  2136.  Phones in different sets may be automatically mapped between using their 
  2137.  features.  This mapping is not yet as general as it could be, but is useful 
  2138.  when mapping between various phonesets of the same language.  When a phone 
  2139.  needs to be mapped from one set to another the phone with matching features is 
  2140.  selected.  This allows, at least to some extent, lexicons, waveform 
  2141.  synthesizers, duration modules etc. to use different phonesets (though in 
  2142.  general this is not advised). 
  2143.  
  2144.  A list of currently defined phonesets is returned by the function 
  2145.  
  2146.                       (PhoneSet.list)
  2147.  Note phonesets are often not defined until a voice is actually loaded so this 
  2148.  list is not the list of of sets that are distributed but the list of sets that 
  2149.  are used by currently loaded voices. 
  2150.  
  2151.  The name, phones, features and silences of the current phoneset may be 
  2152.  accessedwith the function 
  2153.  
  2154.                       (PhoneSet.description nil)
  2155.  If the argument to this function is a list, only those parts of the phoneset 
  2156.  description named are returned.  For example 
  2157.  
  2158.                       (PhoneSet.description '(silences))
  2159.                       (PhoneSet.description '(silences phones))
  2160.  
  2161.  
  2162. ΓòÉΓòÉΓòÉ 14. Lexicons ΓòÉΓòÉΓòÉ
  2163.  
  2164.  A Lexicon in Festival is a subsystem that provides pronunciations for words. 
  2165.  It can consist of three distinct parts: an addenda, typically short consisting 
  2166.  of hand added words; a compiled lexicon, typically large (10,000s of words) 
  2167.  which sits on disk somewhere; and a method for dealing with words not in 
  2168.  either list. 
  2169.  
  2170.  Lexical entries               Format of lexical entries 
  2171.  Defining lexicons             Building new lexicons 
  2172.  Lookup process                Order of significance 
  2173.  Letter to sound rules         Dealing with unknown words 
  2174.  Building letter to sound rulesBuilding rules from data 
  2175.  Lexicon requirements          What should be in the lexicon 
  2176.  Available lexicons            Current available lexicons 
  2177.  Post-lexical rules            Modification of words in context 
  2178.  
  2179.  
  2180. ΓòÉΓòÉΓòÉ 14.1. Lexical entries ΓòÉΓòÉΓòÉ
  2181.  
  2182.  Lexical entries consist of three basic parts, a head word, a part of speech 
  2183.  and a pronunciation.  The headword is what you might normally think of as a 
  2184.  word e.g. 'walk', 'chairs' etc.  but it might be any token. 
  2185.  
  2186.  The part-of-speech field currently consist of a simple atom (or nil if none is 
  2187.  specified).  Of course there are many part of speech tag sets and whatever you 
  2188.  mark in your lexicon must be compatible with the subsystems that use that 
  2189.  information.  You can optionally set a part of speech tag mapping for each 
  2190.  lexicon.  The value should be a reverse assoc-list of the following form 
  2191.  
  2192.                       (lex.set.pos.map
  2193.                         '((( punc fpunc) punc)
  2194.                          (( nn nnp nns nnps ) n)))
  2195.  All part of speech tags not appearing in the left hand side of a pos map are 
  2196.  left unchanged. 
  2197.  
  2198.  The third field contains the actual pronunciation of the word.  This is an 
  2199.  arbitrary Lisp S-expression.  In many of the lexicons distributed with 
  2200.  Festival this entry has internal format, identifying syllable structure, 
  2201.  stress markigns and of course the phones themselves.  In some of our other 
  2202.  lexicons we simply list the phones with stress marking on each vowel. 
  2203.  
  2204.  Some typical example entries are 
  2205.  
  2206.                       ( "walkers" n ((( w oo ) 1) (( k @ z ) 0)) )
  2207.                       ( "present" v ((( p r e ) 0) (( z @ n t ) 1)) )
  2208.                       ( "monument" n ((( m o ) 1) (( n y u ) 0) (( m @ n t ) 0)) )
  2209.  
  2210.  Note you may have two entries with the same headword, but different part of 
  2211.  speech fields allow differentiation.  For example 
  2212.  
  2213.                       ( "lives" n ((( l ai v z ) 1)) )
  2214.                       ( "lives" v ((( l i v z ) 1)) )
  2215.  
  2216.  See Lookup process for a description of how multiple entries with the same 
  2217.  headword are used during lookup. 
  2218.  
  2219.  By current conventions, single syllable function words should have no stress 
  2220.  marking, while single syllable content words should be stressed. 
  2221.  
  2222.  NOTE: the POS field may change in future to contain more complex formats.  The 
  2223.  same lexicon mechanism (but different lexicon) is used for holding part of 
  2224.  speech tag distributions for the POS prediction module. 
  2225.  
  2226.  
  2227. ΓòÉΓòÉΓòÉ 14.2. Defining lexicons ΓòÉΓòÉΓòÉ
  2228.  
  2229.  As stated above, lexicons consist of three basic parts (compiled form, addenda 
  2230.  and unknown word method) plus some other declarations. 
  2231.  
  2232.  Each lexicon in the system has a name which allows different lexicons to be 
  2233.  selected from efficiently when switching between voices during synthesis.  The 
  2234.  basic steps involved in a lexicon definition are as follows. 
  2235.  
  2236.  First a new lexicon must be created with a new name 
  2237.  
  2238.                       (lex.create "cstrlex")
  2239.  A phone set must be declared for the lexicon, to allow both checks on the 
  2240.  entries themselves and to allow phone mapping between different phone sets 
  2241.  used in the system 
  2242.  
  2243.                       (lex.set.phoneset "mrpa")
  2244.  The phone set must be already declared in the system. 
  2245.  
  2246.  A compiled lexicon, the construction of which is described below, may be 
  2247.  optionally specified 
  2248.  
  2249.                       (lex.set.compile.file "/projects/festival/lib/dicts/cstrlex.out")
  2250.  The method for dealing with unknown words, See Letter to sound rules, may be 
  2251.  set 
  2252.  
  2253.                       (lex.set.lts.method 'lts_rules)
  2254.                       (lex.set.lts.ruleset 'nrl)
  2255.  In this case we are specifying the use of a set of letter to sound rules 
  2256.  originally developed by the U.S. Naval Research Laboratories.  The default 
  2257.  method is to give an error if a word is not found in the addenda or compiled 
  2258.  lexicon.  (This and other options are discussed more fully below.) 
  2259.  
  2260.  Finally addenda items may be added for words that are known to be common, but 
  2261.  not in the lexicon and cannot reasonably be analysed by the letter to sound 
  2262.  rules. 
  2263.  
  2264.                       (lex.add.entry
  2265.                        '( "awb" n ((( ei ) 1) ((d uh) 1) ((b @ l) 0) ((y uu) 0) ((b ii) 1))))
  2266.                       (lex.add.entry
  2267.                        '( "cstr" n ((( s ii ) 1) (( e s ) 1) (( t ii ) 1) (( aa ) 1)) ))
  2268.                       (lex.add.entry
  2269.                        '( "Edinburgh" n ((( e m ) 1) (( b r @ ) 0))) ))
  2270.  Using lex.add.entry again for the same word and part of speech will redefine 
  2271.  the current pronunciation.  Note these add entries to the current lexicon so 
  2272.  its a good idea to explicitly select the lexicon before you add addenda 
  2273.  entries, particularly if you are doing this in your own '.festivalrc' file. 
  2274.  
  2275.  For large lists, compiled lexicons are best.  The function lex.compile takes 
  2276.  two filename arguments, a file name containing a list of lexical entries and 
  2277.  an output file where the compiled lexicon will be saved. 
  2278.  
  2279.  Compilation can take some time and may require lots of memory, as all entries 
  2280.  are loaded in, checked and then sorted before being written out again.  During 
  2281.  compilation if some entry is malformed the reading process halts with a not so 
  2282.  useful message.  Note that if any of your entries include quote or double 
  2283.  quotes the entries will probably be misparsed and cause such a weird error. 
  2284.  In such cases try setting 
  2285.  
  2286.                       (debug_output t)
  2287.  before compilation.  This will print out each entry as it is read in which 
  2288.  should help to narrow down where the error is. 
  2289.  
  2290.  
  2291. ΓòÉΓòÉΓòÉ 14.3. Lookup process ΓòÉΓòÉΓòÉ
  2292.  
  2293.  When looking up a word, either through the C++ interface, or Lisp interface, a 
  2294.  word is identified by its headword and part of speech.  If no part of speech 
  2295.  is specified, nil is assumed which matches any part of speech tag. 
  2296.  
  2297.  The lexicon look up process first checks the addenda, if there is a full match 
  2298.  (head word plus part of speech) it is returned.  If there is an addenda entry 
  2299.  whose head word matches and whose part of speech is nil that entry is 
  2300.  returned. 
  2301.  
  2302.  If no match is found in the addenda, the compiled lexicon, if present, is 
  2303.  checked.  Again a match is when both head word and part of speech tag match, 
  2304.  or either the word being searched for has a part of speech nil or an entry has 
  2305.  its tag as nil.  Unlike the addenda, if no full head word and part of speech 
  2306.  tag match is found, the first word in the lexicon whose head word matches is 
  2307.  returned.  The rationale is that the letter to sound rules (the next defence) 
  2308.  are unlikely to be better than an given alternate pronunciation for a the word 
  2309.  but different part of speech.  Even more so given that as there is an entry 
  2310.  with the head word but a different part of speech this word may have an 
  2311.  unusual pronunciation that the letter to sound rules will have no chance in 
  2312.  producing. 
  2313.  
  2314.  Finally if the word is not found in the compiled lexicon it is passed to 
  2315.  whatever method is defined for unknown words.  This is most likely a letter to 
  2316.  sound module.  See Letter to sound rules. 
  2317.  
  2318.  Optional pre- and post-lookup hooks can be specified for a lexicon. As a 
  2319.  single (or list of) Lisp functions.  The pre-hooks will be called with two 
  2320.  arguments (word and features) and should return a pair (word and features). 
  2321.  The post-hooks will be given a lexical entry and should return a lexical 
  2322.  entry.  The pre- and post-hooks do nothing by default. 
  2323.  
  2324.  Compiled lexicons may be created from lists of lexical entries. A compiled 
  2325.  lexicon is much more efficient for look up than the addenda.  Compiled 
  2326.  lexicons use a binary search method while the addenda is searched linearly. 
  2327.  Also it would take a prohibitively long time to load in a typical full lexicon 
  2328.  as an addenda.  If you have more than a few hundred entries in your addenda 
  2329.  you should seriously consider adding them to your compiled lexicon. 
  2330.  
  2331.  Because many publicly available lexicons do not have syllable markings for 
  2332.  entries the compilation method supports automatic syllabification. Thus for 
  2333.  lexicon entries for compilation, two forms for the pronunciation field are 
  2334.  supported: the standard full syllabified and stressed form and a simpler 
  2335.  linear form found in at least the BEEP and CMU lexicons.  If the pronunciation 
  2336.  field is a flat atomic list it is assumed syllabification is required. 
  2337.  
  2338.  Syllabification is done by finding the minimum sonorant position between 
  2339.  vowels.  It is not guaranteed to be accurate but does give a solution that is 
  2340.  sufficient for many purposes.  A little work would probably improve this 
  2341.  significantly.  Of course syllabification requires the entry's phones to be in 
  2342.  the current phone set.  The sonorant values are calculated from the vc, ctype, 
  2343.  and cvox features for the current phoneset.  See 
  2344.  'src/arch/festival/Phone.cc:ph_sonority()' for actual definition. 
  2345.  
  2346.  Additionally in this flat structure vowels (atoms starting with a, e, i, o or 
  2347.  u) may have 1 2 or 0 appended marking stress.  This is again following the 
  2348.  form found in the BEEP and CMU lexicons. 
  2349.  
  2350.  Some example entries in the flat form (taken from BEEP) are 
  2351.  
  2352.                       ("table" nil (t ei1 b l))
  2353.                       ("suspicious" nil (s @ s p i1 sh @ s))
  2354.  
  2355.  Also if syllabification is required there is an opportunity to run a set of 
  2356.  "letter-to-sound"-rules on the input (actually an arbitrary re-write rule 
  2357.  system).  If the variable lex_lts_set is set, the lts ruleset of that name is 
  2358.  applied to the flat input before syllabification.  This allows simple 
  2359.  predictable changes such as conversion of final r into longer vowel for 
  2360.  English RP from American labelled lexicons. 
  2361.  
  2362.  A list of all matching entries in the addenda and the compiled lexicon may be 
  2363.  found by the function lex.lookup_all.  This function takes a word and returns 
  2364.  all matching entries irrespective of part of speech. 
  2365.  
  2366.  
  2367. ΓòÉΓòÉΓòÉ 14.4. Letter to sound rules ΓòÉΓòÉΓòÉ
  2368.  
  2369.  Each lexicon may define what action to take when a word cannot be found in the 
  2370.  addenda or the compiled lexicon.  There are a number of options which will 
  2371.  hopefully be added to as more general letter to sound rule systems are added. 
  2372.  
  2373.  The method is set by the command 
  2374.  
  2375.                       (lex.set.lts.method METHOD)
  2376.  Where METHOD can be any of the following 
  2377.  
  2378.  'Error'   Throw an error when an unknown word is found (default). 
  2379.  
  2380.  'lts_rules'Use externally specified set of letter to sound rules (described 
  2381.            below).  The name of the rule set to use is defined with the 
  2382.            lex.lts.ruleset function.  This method runs one set of rules on an 
  2383.            exploded form of the word and assumes the rules return a list of 
  2384.            phonemes (in the appropriate set).  If multiple instances of rules 
  2385.            are required use the function method described next. 
  2386.  
  2387.  'none'    This returns an entry with a nil pronunciation field.  This will 
  2388.            only be valid in very special circumstances. 
  2389.  
  2390.  'FUNCTIONNAME'Call this as a LISP function function name.   This function is 
  2391.            given two arguments: the word and the part of speech.  It should 
  2392.            return a valid lexical entry. 
  2393.  
  2394.  The basic letter to sound rule system is very simple but is powerful enough to 
  2395.  build reasonably complex letter to sound rules. Although we've found trained 
  2396.  LTS rules better than hand written ones (for complex languages) where no data 
  2397.  is available and rules must be hand written the following rule formalism is 
  2398.  much easier to use than that generated by the LTS training system (described 
  2399.  in the next section). 
  2400.  
  2401.  The basic form of a rule is as follows 
  2402.  
  2403.                       ( LEFTCONTEXT [ ITEMS ] RIGHTCONTEXT = NEWITEMS )
  2404.  This interpretation is that if ITEMS appear in the specified right and left 
  2405.  context then the output string is to contain NEWITEMS. Any of LEFTCONTEXT, 
  2406.  RIGHTCONTEXT or NEWITEMS may be empty.  Note that NEWITEMS is written to a 
  2407.  different "tape" and hence cannot feed further rules (within this ruleset). 
  2408.  An example is 
  2409.  
  2410.                       ( # [ c h ] C = k )
  2411.  The special character # denotes a word boundary, and the symbol C denotes the 
  2412.  set of all consonants, sets are declared before rules.  This rule states that 
  2413.  a ch at the start of a word followed by a consonant is to be rendered as the k 
  2414.  phoneme. Symbols in contexts may be followed by the symbol * for zero or more 
  2415.  occurrences, or + for one or more occurrences. 
  2416.  
  2417.  The symbols in the rules are treated as set names if they are declared as such 
  2418.  or as symbols in the input/output alphabets.  The symbols may be more than one 
  2419.  character long and the names are case sensitive. 
  2420.  
  2421.  The rules are tried in order until one matches the first (or more) symbol of 
  2422.  the tape.  The rule is applied adding the right hand side to the output tape. 
  2423.  The rules are again applied from the start of the list of rules. 
  2424.  
  2425.  The function used to apply a set of rules if given an atom will explode it 
  2426.  into a list of single characters, while if given a list will use it as is. 
  2427.  This reflects the common usage of wishing to re-write the individual letters 
  2428.  in a word to phonemes but without excluding the possibility of using the 
  2429.  system for more complex manipulations, such as multi-pass LTS systems and 
  2430.  phoneme conversion. 
  2431.  
  2432.  From lisp there are three basic access functions, there are corresponding 
  2433.  functions in the C/C++ domain. 
  2434.  
  2435.  (lts.ruleset NAME SETS RULES) Define a new set of lts rules.  Where NAME is 
  2436.            the name for this rule, SETS is a list of set definitions of the 
  2437.            form (SETNAME e0 e1 ┬╖┬╖┬╖)  and RULES are a list of rules as described 
  2438.            above. 
  2439.  
  2440.  (lts.apply WORD RULESETNAME)Apply the set of rules named RULESETNAME to WORD. 
  2441.            If WORD is a symbol it is exploded into a list of the individual 
  2442.            characters in its print name.  If WORD is a list it is used as is. 
  2443.            If the rules cannot be successfully applied an error is given.  The 
  2444.            result of (successful) application is returned in a list. 
  2445.  
  2446.  (lts.check_alpha WORD RULESETNAME)The symbols in WORD are checked against the 
  2447.            input alphabet of the rules named RULESETNAME.  If they are all 
  2448.            contained in that alphabet t is returned, else nil.  Note this does 
  2449.            not necessarily mean the rules will successfully apply (contexts may 
  2450.            restrict the application of the rules), but it allows general 
  2451.            checking like numerals, punctuation etc, allowing application of 
  2452.            appropriate rule sets. 
  2453.  
  2454.  The letter to sound rule system may be used directly from Lisp and can easily 
  2455.  be used to do relatively complex operations for analyzing words without 
  2456.  requiring modification of the C/C++ system.  For example the Welsh letter to 
  2457.  sound rule system consists or three rule sets, first to explicitly identify 
  2458.  epenthesis, then identify stressed vowels, and finally rewrite this augmented 
  2459.  letter string to phonemes.  This is achieved by the following function 
  2460.  
  2461.  
  2462.                       (define (welsh_lts word features)
  2463.                        (let (epen str wel)
  2464.                         (set! epen (lts.apply (downcase word) 'newepen))
  2465.                         (set! str (lts.apply epen 'newwelstr))
  2466.                         (set! wel (lts.apply str 'newwel))
  2467.                         (list word
  2468.                            nil
  2469.                            (lex.syllabify.phstress wel))))
  2470.  The LTS method for the Welsh lexicon is set to welsh_lts, so this function is 
  2471.  called when a word is not found in the lexicon.  The above function first 
  2472.  downcases the word and then applies the rulesets in turn, finally calling the 
  2473.  syllabification process and returns a constructed lexically entry. 
  2474.  
  2475.  
  2476. ΓòÉΓòÉΓòÉ 14.5. Building letter to sound rules ΓòÉΓòÉΓòÉ
  2477.  
  2478.  As writing letter to sound rules by hand is hard and very time consuming, an 
  2479.  alternative method is also available where a latter to sound system may be 
  2480.  built from a lexicon of the language.  This technique has successfully been 
  2481.  used from English (British and American), French and German.  The difficulty 
  2482.  and appropriateness of using letter to sound rules is very language dependent, 
  2483.  
  2484.  The following outlines the processes involved in building a letter to sound 
  2485.  model for a language given a large lexicon of pronunciations. This technique 
  2486.  is likely to work for most European languages (including Russian) but doesn't 
  2487.  seem particularly suitable for very language alphabet languages like Japanese 
  2488.  and Chinese.  The process described here is not (yet) fully automatic but the 
  2489.  hand intervention required is small and may easily be done even by people with 
  2490.  only a very little knowledge of the language being dealt with. 
  2491.  
  2492.  The process involves the following steps 
  2493.  
  2494.      Pre-processing lexicon into suitable training set 
  2495.  
  2496.      Defining the set of allowable pairing of letters to phones.  (We intend 
  2497.       to do this fully automatically in future versions). 
  2498.  
  2499.      Constructing the probabilities of each letter/phone pair. 
  2500.  
  2501.      Aligning letters to an equal set of phones/_epsilons_. 
  2502.  
  2503.      Extracting the data by letter suitable for training. 
  2504.  
  2505.      Building CART models for predicting phone from letters (and context). 
  2506.  
  2507.      Building additional lexical stress assignment model (if necessary). 
  2508.  All except the first two stages of this are fully automatic. 
  2509.  
  2510.  Before building a model its wise to think a little about what you want it to 
  2511.  do.  Ideally the model is an auxiluary to the lexicon so only words not found 
  2512.  in the lexicon will require use of the letter to sound rules.  Thus only 
  2513.  unusual forms are likely to require the rules.  More precisely the most common 
  2514.  words, often having the most non-standard pronunciations, should probably be 
  2515.  explicitly listed always.  It is possible to reduce the size of the lexicon 
  2516.  (sometimes drastically) by removing all entries that the training LTS model 
  2517.  correctly predicts. 
  2518.  
  2519.  Before starting it is wise to consider removing some entries from the lexicon 
  2520.  before training, I typically will remove words under 4 letters and if part of 
  2521.  speech information is available I remove all function words, ideally only 
  2522.  training from nouns verbs and adjectives as these are the most likely forms to 
  2523.  be unknown in text.  It is useful to have morphologically inflected and 
  2524.  derived forms in the training set as it is often such variant forms that not 
  2525.  found in the lexicon even though their root morpheme is.  Note that in many 
  2526.  forms of text, proper names are the most common form of unknown word and even 
  2527.  the technique presented here may not adequately cater for that form of unknown 
  2528.  words (especially if they unknown words are non-native names).  This is all 
  2529.  stating that this may or may not be appropriate for your task but the rules 
  2530.  generated by this learning process have in the examples we've done been much 
  2531.  better than what we could produce by hand writing rules of the form described 
  2532.  in the previous section. 
  2533.  
  2534.  First preprocess the lexicon into a file of lexical entries to be used for 
  2535.  training, removing functions words and changing the head words to all lower 
  2536.  case (may be language dependent).  The entries should be of the form used for 
  2537.  input for Festival's lexicon compilation.  Specifical the pronunciations 
  2538.  should be simple lists of phones (no syllabification).  Depending on the 
  2539.  language, you may wish to remve the stressing---for examples here we have 
  2540.  though later tests suggest that we should keep it in even for English.  Thus 
  2541.  the training set should look something like 
  2542.  
  2543.                       ("table" nil (t ei b l))
  2544.                       ("suspicious" nil (s @ s p i sh @ s))
  2545.  It is best to split the data into a training set and a test set if you wish to 
  2546.  know how well your training has worked.  In our tests we remove every tenth 
  2547.  entry and put it in a test set.  Note this will mean our test results are 
  2548.  probably better than if we removed say the last ten in every hundred. 
  2549.  
  2550.  The second stage is to define the set of allowable letter to phone mappings 
  2551.  irrespective of context.  This can sometimes be initially done by hand then 
  2552.  checked against the training set.  Initially constract a file of the form 
  2553.  
  2554.                       (require 'lts_build)
  2555.                       (set! allowables
  2556.                          '((a _epsilon_)
  2557.                           (b _epsilon_)
  2558.                           (c _epsilon_)
  2559.                           ┬╖┬╖┬╖
  2560.                           (y _epsilon_)
  2561.                           (z _epsilon_)
  2562.                           (# #)))
  2563.  All letters that appear in the alphabet should (at least) map to _epsilon_, 
  2564.  including any accented characters that appear in that language.  Note the last 
  2565.  two hashes.  These are used by to denote beginning and end of word and are 
  2566.  automatically added during training, they must appear in the list and should 
  2567.  only map to themselves. 
  2568.  
  2569.  To incrementally add to this allowable list run festival as 
  2570.  
  2571.                       festival allowables.scm
  2572.  and at the prompt type 
  2573.  
  2574.                       festival> (cummulate-pairs "oald.train")
  2575.  with your train file.  This will print out each lexical entry that couldn't be 
  2576.  aligned with the current set of allowables.  At the start this will be every 
  2577.  entry.  Looking at these entries add to the allowables to make alignment work. 
  2578.  For example if the following word fails 
  2579.  
  2580.                       ("abate" nil (ah b ey t))
  2581.  Add ah to the allowables for letter a, b to b, ey to a and t to letter t. 
  2582.  After doing that restart festival and call cummulate-pairs again. 
  2583.  Incrementally add to the allowable pairs until the number of failures becomes 
  2584.  accceptable.  Often there are entries for which there is no real relationship 
  2585.  between the letters and the pronunciation such as in abbreviations and foreign 
  2586.  words (e.g. "aaa" as "t r ih p ax l ey").  For the lexicons I've used the 
  2587.  technique on less than 10 per thousand fail in this way. 
  2588.  
  2589.  It is worth while being consistent on defining your set of allowables. (At 
  2590.  least) two mappings are possible for the letter sequence ch---having letter c 
  2591.  go to phone ch and letter h go to _epsilon_ and also letter c go to phone 
  2592.  _epsilon_ and letter h goes to ch.  However only one should be allowed, we 
  2593.  preferred c to ch. 
  2594.  
  2595.  It may also be the case that some letters give rise to more than one phone. 
  2596.  For example the letter x in English is often pronunced as the phone 
  2597.  combination k and s.  To allow this, use the multiphone k-s.  Thus the 
  2598.  multiphone k-s will be predicted for x in some context and the model will 
  2599.  separate it into two phones while it also ignoring any predicted _epsilons_. 
  2600.  Note that multiphone units are relatively rare but do occur.  In English, 
  2601.  letter x give rise to a few, k-s in taxi, g-s in example, and sometimes g-zh 
  2602.  and k-sh in luxury.  Others are w-ah in one, t-s in pizza, y-uw in new 
  2603.  (British), ah-m in -ism etc.  Three phone multiphone are much rarer but may 
  2604.  exist, they are not supported by this code as is, but such entries should 
  2605.  probably be ignored.  Note the - sign in the multiphone examples is 
  2606.  significant and is used to indentify multiphones. 
  2607.  
  2608.  The allowables for OALD end up being 
  2609.  
  2610.                       (set! allowables
  2611.                           '
  2612.                          ((a _epsilon_ ei aa a e@ @ oo au o i ou ai uh e)
  2613.                           (b _epsilon_ b )
  2614.                           (c _epsilon_ k s ch sh @-k s t-s)
  2615.                           (d _epsilon_ d dh t jh)
  2616.                           (e _epsilon_ @ ii e e@ i @@ i@ uu y-uu ou ei aa oi y y-u@ o)
  2617.                           (f _epsilon_ f v )
  2618.                           (g _epsilon_ g jh zh th f ng k t)
  2619.                           (h _epsilon_ h @ )
  2620.                           (i _epsilon_ i@ i @ ii ai @@ y ai-@ aa a)
  2621.                           (j _epsilon_ h zh jh i y )
  2622.                           (k _epsilon_ k ch )
  2623.                           (l _epsilon_ l @-l l-l)
  2624.                           (m _epsilon_ m @-m n)
  2625.                           (n _epsilon_ n ng n-y )
  2626.                           (o _epsilon_ @ ou o oo uu u au oi i @@ e uh w u@ w-uh y-@)
  2627.                           (p _epsilon_ f p v )
  2628.                           (q _epsilon_ k )
  2629.                           (r _epsilon_ r @@ @-r)
  2630.                           (s _epsilon_ z s sh zh )
  2631.                           (t _epsilon_ t th sh dh ch d )
  2632.                           (u _epsilon_ uu @ w @@ u uh y-uu u@ y-u@ y-u i y-uh y-@ e)
  2633.                           (v _epsilon_ v f )
  2634.                           (w _epsilon_ w uu v f u)
  2635.                           (x _epsilon_ k-s g-z sh z k-sh z g-zh )
  2636.                           (y _epsilon_ i ii i@ ai uh y @ ai-@)
  2637.                           (z _epsilon_ z t-s s zh )
  2638.                           (# #)
  2639.                           ))
  2640.  Note this is an exhaustive list and (deliberately) says nothing about the 
  2641.  contexts or frequency that these letter to phone pairs appear. That 
  2642.  information will be generated automatically from the training set. 
  2643.  
  2644.  Once the number of failed matches is signficantly low enough let 
  2645.  cummulate-pairs run to completion.  This counts the number of times each 
  2646.  letter/phone pair occurs in allowable alignments. 
  2647.  
  2648.  Next call 
  2649.  
  2650.                       festival> (save-table "oald-")
  2651.  with the name of your lexicon.  This changes the cummulation table into 
  2652.  probabilities and saves it. 
  2653.  
  2654.  Restart festival loading this new table 
  2655.  
  2656.                       festival allowables.scm oald-pl-table.scm
  2657.  Now each word can be aligned to an equally-lengthed string of phones, epsilon 
  2658.  and multiphones. 
  2659.  
  2660.                       festival> (aligndata "oald.train" "oald.train.align")
  2661.  Do this also for you test set. 
  2662.  
  2663.  This will produce entries like 
  2664.  
  2665.                       aaronson _epsilon_ aa r ah n s ah n
  2666.                       abandon ah b ae n d ah n
  2667.                       abate ah b ey t _epsilon_
  2668.                       abbe ae b _epsilon_ iy
  2669.  
  2670.  The next stage is to build features suitable for 'wagon' to build models. 
  2671.  This is done by 
  2672.  
  2673.                       festival> (build-feat-file "oald.train.align" "oald.train.feats")
  2674.  Again the same for the test set. 
  2675.  
  2676.  Now you need to constructrure a description file for 'wagon' for the given 
  2677.  data.  The can be done using the script 'make_wgn_desc' provided with the 
  2678.  speech tools 
  2679.  
  2680.  Here is an example script for building the models, you will need to modify it 
  2681.  for your particualr database but it shows the basic processes 
  2682.  
  2683.                       for i in a b c d e f g h i j k l m n o p q r s t u v w x y z
  2684.                       do
  2685.                         # Stop value for wagon
  2686.                         STOP=2
  2687.                         echo letter $i STOP $STOP
  2688.                         # Find training set for letter $i
  2689.                         cat oald.train.feats |
  2690.                         awk '{if ($6 == "'$i'") print $0}' >ltsdataTRAIN.$i.feats
  2691.                         # split training set to get heldout data for stepwise testing
  2692.                         traintest ltsdataTRAIN.$i.feats
  2693.                         # Extract test data for letter $i
  2694.                         cat oald.test.feats |
  2695.                         awk '{if ($6 == "'$i'") print $0}' >ltsdataTEST.$i.feats
  2696.                         # run wagon to predict model
  2697.                         wagon -data ltsdataTRAIN.$i.feats.train -test ltsdataTRAIN.$i.feats.test \
  2698.                            -stepwise -desc ltsOALD.desc -stop $STOP -output lts.$i.tree
  2699.                         # Test the resulting tree against
  2700.                         wagon_test -heap 2000000 -data ltsdataTEST.$i.feats -desc ltsOALD.desc \
  2701.                              -tree lts.$i.tree
  2702.                       done
  2703.  The script 'traintest' splits the given file 'X' into 'X.train' and 'X.test' 
  2704.  with every tenth line in 'X.test' and the rest in 'X.train'. 
  2705.  
  2706.  This script can take a significnat amount of time to run, about 6 hours on a 
  2707.  Sun Ultra 140. 
  2708.  
  2709.  Once the models are created the must be collected together into a single list 
  2710.  structure.  The trees generated by 'wagon' contain fully probability 
  2711.  distributions at each leaf, at this time this information can be removed as 
  2712.  only the most probable will actually be predicted.  This substantially reduces 
  2713.  the size of the tress. 
  2714.  
  2715.                       (merge_models 'oald_lts_rules "oald_lts_rules.scm")
  2716.  (merge_models is defined within 'lts_build.scm') The given file will contain a 
  2717.  set! for the given variable name to an assoc list of letter to trained tree. 
  2718.  Note the above function naively assumes that the letters in the alphabet are 
  2719.  the 26 lower case letters of the English alphabet, you will need to edit this 
  2720.  adding accented letters if required.  Note that adding "'" (single quote) as a 
  2721.  letter is a little tricky in scheme but can be done---the command (intern "'") 
  2722.  will give you the symbol for single quote. 
  2723.  
  2724.  To test a set of lts models load the saved model and call the following 
  2725.  function with the test align file 
  2726.  
  2727.                       festival oald-table.scm oald_lts_rules.scm
  2728.                       festival> (lts_testset "oald.test.align" oald_lts_rules)
  2729.  The result (after showing all the failed ones), will be a table showing the 
  2730.  results for each letter, for all letters and for complete words. The failed 
  2731.  entries may give some notion of how good or bad the result is, sometimes it 
  2732.  will be simple vowel diferences, long versus short, schwa versus full vowel, 
  2733.  other times it may be who consonants missing. Remember the ultimate quality of 
  2734.  the letter sound rules is how adequate they are at providing acceptable 
  2735.  pronunciations rather than how good the numeric score is. 
  2736.  
  2737.  For some languages (e.g. English) it is necessary to also find a stree pattern 
  2738.  for unknown words.  Ultimately for this to work well you need to know the 
  2739.  morphological decomposition of the word. At present we provide a CART trained 
  2740.  system to predict stress patterns for English.  If does get 94.6% correct for 
  2741.  an unseen test set but that isn't really very good.  Later tests suggest that 
  2742.  predicting stressed and unstressed phones directly is actually better for 
  2743.  getting whole words correct even though the models do slightly worse on a per 
  2744.  phone basis black98. 
  2745.  
  2746.  As the lexicon may be a large part of the system we have also experimented 
  2747.  with removing entries from the lexicon if the letter to sound rules system 
  2748.  (and stree assignment system) can correct predict them.  For OALD this allows 
  2749.  us to half the size of the lexicon, it could possibly allow more if a certain 
  2750.  amount of fuzzy acceptance was allowed (e.g. with schwa).  For other languages 
  2751.  the gain here can be very signifcant, for German and French we can reduce the 
  2752.  lexicon by over 90%. The function reduce_lexicon in 
  2753.  'festival/lib/lts_build.scm' was used to do this.  A diccussion of using the 
  2754.  above technique as a dictionary compression method is discussed in pagel98.  A 
  2755.  morphological decomposition algorithm, like that described in black91, may 
  2756.  even help more. 
  2757.  
  2758.  The technique described in this section and its relative merits with respect 
  2759.  to a number of languages/lexicons and tasks is dicussed more fully in black98. 
  2760.  
  2761.  
  2762. ΓòÉΓòÉΓòÉ 14.6. Lexicon requirements ΓòÉΓòÉΓòÉ
  2763.  
  2764.  For English there are a number of assumptions made about the lexicon which are 
  2765.  worthy of explicit mention.  If you are basically going to use the existing 
  2766.  token rules you should try to include at least the following in any lexicon 
  2767.  that is to work with them. 
  2768.  
  2769.      The letters of the alphabet, when a token is identified as an acronym it 
  2770.       is spelled out.  The tokenization assumes that the individual letters of 
  2771.       the alphabet are in the lexicon with their pronunciations.  They should 
  2772.       be identified as nouns.  (This is to distinguish a as a determiner which 
  2773.       can be schwa'd from a as a letter which cannot.)  The part of speech 
  2774.       should be nn by default, but the value of the variable token.letter_pos 
  2775.       is used and may be changed if this is not what is required. 
  2776.  
  2777.      One character symbols such as dollar, at-sign, percent etc.  Its 
  2778.       difficult to get a complete list and to know what the pronunciation of 
  2779.       some of these are (e.g hash or pound sign).  But the letter to sound 
  2780.       rules cannot deal with them so they need to be explicitly listed.  See 
  2781.       the list in the function mrpa_addend in 
  2782.       'festival/lib/dicts/oald/oaldlex.scm'.  This list should also contain the 
  2783.       control characters and eight bit characters. 
  2784.  
  2785.      The possessive 's should be in your lexicon as schwa and voiced fricative 
  2786.       (z).  It should be in twice, once as part speech type pos and once as n 
  2787.       (used in plurals of numbers acronyms etc. e.g 1950's).  's is treated as 
  2788.       a word and is separated from the tokens it appears with.  The 
  2789.       post-lexical rule (the function postlex_apos_s_check) will delete the 
  2790.       schwa and devoice the z in appropriate contexts.  Note this post-lexical 
  2791.       rule brazenly assumes that the unvoiced fricative in the phoneset is s. 
  2792.       If it is not in your phoneset copy the function (it is in 
  2793.       'festival/lib/postlex.scm') and change it for your phoneset and use your 
  2794.       version as a post-lexical rule. 
  2795.  
  2796.      Numbers as digits (e.g. "1", "2", "34", etc.) should normally not be in 
  2797.       the lexicon.  The number conversion routines convert numbers to words 
  2798.       (i.e. "one", "two", "thirty four", etc.). 
  2799.  
  2800.      The word "unknown" or whatever is in the variable 
  2801.       token.unknown_word_name.  This is used in a few obscure cases when there 
  2802.       just isn't anything that can be said (e.g. single characters which aren't 
  2803.       in the lexicon).  Some people have suggested it should be possible to 
  2804.       make this a sound rather than a word.  I agree, but Festival doesn't 
  2805.       support that yet. 
  2806.  
  2807.  
  2808. ΓòÉΓòÉΓòÉ 14.7. Available lexicons ΓòÉΓòÉΓòÉ
  2809.  
  2810.  Currently Festival supports a number of different lexicons.  They are all 
  2811.  defined in the file 'lib/lexicons.scm' each with a number of common extra 
  2812.  words added to their addendas.  They are 
  2813.  
  2814.  'CUVOALD' The Computer Users Version of Oxford Advanced Learner's Dictionary 
  2815.            is available from the Oxford Text Archive 
  2816.            ftp://ota.ox.ac.uk/pub/ota/public/dicts/710.  It contains about 
  2817.            70,000 entries and is a part of the BEEP lexicon.  It is more 
  2818.            consistent in its marking of stress though its syllable marking is 
  2819.            not what works best for our synthesis methods.  Many syllabic 'l''s, 
  2820.            'n''s, and 'm''s, mess up the syllabification algorithm, making 
  2821.            results sometimes appear over reduced.  It is however our current 
  2822.            default lexicon.  It is also the only lexicon with part of speech 
  2823.            tags that can be distributed (for non-commercial use). 
  2824.  
  2825.  'CMU'     This is automatically constructed from 'cmu_dict-0.4' available from 
  2826.            many places on the net (see comp.speech archives).  It is not in the 
  2827.            mrpa phone set because it is American English pronunciation. 
  2828.            Although mappings exist between its phoneset ('darpa') and 'mrpa' 
  2829.            the results for British English speakers are not very good. However 
  2830.            this is probably the biggest, most carefully specified lexicon 
  2831.            available.  It contains just under 100,000 entries.  Our 
  2832.            distribution has been modified to include part of speech tags on 
  2833.            words we know to be homographs. 
  2834.  
  2835.  'mrpa'    A version of the CSTR lexicon which has been floating about for 
  2836.            years. It contains about 25,000 entries.  A new updated free version 
  2837.            of this is due to be released soon. 
  2838.  
  2839.  'BEEP'    A British English rival for the 'cmu_lex'.  BEEP has been made 
  2840.            available by Tony Robinson at Cambridge and is available in many 
  2841.            archives.  It contains 163,000 entries and has been converted to the 
  2842.            'mrpa' phoneset (which was a trivial mapping).  Although large, it 
  2843.            suffers from a certain randomness in its stress markings, making use 
  2844.            of it for synthesis dubious. 
  2845.  
  2846.  All of the above lexicons have some distribution restrictions (though mostly 
  2847.  pretty light), but as they are mostly freely available we provide programs 
  2848.  that can convert the originals into Festival's format. 
  2849.  
  2850.  The MOBY lexicon has recently been released into the public domain and will be 
  2851.  converted into our format soon. 
  2852.  
  2853.  
  2854. ΓòÉΓòÉΓòÉ 14.8. Post-lexical rules ΓòÉΓòÉΓòÉ
  2855.  
  2856.  It is the lexicon's job to produce a pronunciation of a given word. However in 
  2857.  most languages the most natural pronunciation of a word cannot be found in 
  2858.  isolation from the context in which it is to be spoken.  This includes such 
  2859.  phenomena as reduction, phrase final devoicing and r-insertion.  In Festival 
  2860.  this is done by post-lexical rules. 
  2861.  
  2862.  PostLex is a module which is run after accent assignment but before duration 
  2863.  and F0 generation.  This is because knowledge of accent position is necessary 
  2864.  for vowel reduction and other post lexical phenomena and changing the 
  2865.  segmental items will affect durations. 
  2866.  
  2867.  The PostLex first applies a set of built in rules (which could be done in 
  2868.  Scheme but for historical reasons are still in C++).  It then applies the 
  2869.  functions set in the hook postlex_rules_hook.  These should be a set of 
  2870.  functions that take an utterance and apply appropriate rules.  This should be 
  2871.  set up on a per voice basis. 
  2872.  
  2873.  Although a rule system could be devised for post-lexical sound rules it is 
  2874.  unclear what the scope of them should be, so we have left it completely open. 
  2875.  Our vowel reduction model uses a CART decision tree to predict which syllables 
  2876.  should be reduced, while the "'s" rule is very simple (shown in 
  2877.  'festival/lib/postlex.scm'). 
  2878.  
  2879.  The 's in English may be pronounced in a number of different ways depending on 
  2880.  the preceding context.  If the preceding consonant is a fricative or 
  2881.  affricative and not a palatal labio-dental or dental a schwa is required (e.g. 
  2882.  bench's) otherwise no schwa is required (e.g. John's).  Also if the previous 
  2883.  phoneme is unvoiced the "s" is rendered as an "s" while in all other cases it 
  2884.  is rendered as a "z". 
  2885.  
  2886.  For our English voices we have a lexical entry for "'s" as a schwa followed by 
  2887.  a "z".  We use a post lexical rule function called postlex_apos_s_check to 
  2888.  modify the basic given form when required.  After lexical lookup the segment 
  2889.  relation contains the concatenation of segments directly from lookup in the 
  2890.  lexicon. Post lexical rules are applied after that. 
  2891.  
  2892.  In the following rule we check each segment to see if it is part of a word 
  2893.  labelled "'s", if so we check to see if are we currently looking at the schwa 
  2894.  or the z part, and test if modification is required 
  2895.  
  2896.                       (define (postlex_apos_s_check utt)
  2897.                        "(postlex_apos_s_check UTT)
  2898.                       Deal with possesive s for English (American and British).  Delete
  2899.                       schwa of 's if previous is not a fricative or affricative, and
  2900.                       change voiced to unvoiced s if previous is not voiced."
  2901.                        (mapcar
  2902.                         (lambda (seg)
  2903.                          (if (string-equal "'s" (item.feat
  2904.                                      seg "R:SylStructure.parent.parent.name"))
  2905.                            (if (string-equal "a" (item.feat seg 'ph_vlng))
  2906.                              (if (and (member_string (item.feat seg 'p.ph_ctype)
  2907.                                          '(f a))
  2908.                                  (not (member_string
  2909.                                     (item.feat seg "p.ph_cplace")
  2910.                                     '(d b g))))
  2911.                                t;; don't delete schwa
  2912.                                (item.delete seg))
  2913.                              (if (string-equal "-" (item.feat seg "p.ph_cvox"))
  2914.                                (item.set_name seg "s")))));; from "z"
  2915.                         (utt.relation.items utt 'Segment))
  2916.                        utt)
  2917.  
  2918.  
  2919. ΓòÉΓòÉΓòÉ 15. Utterances ΓòÉΓòÉΓòÉ
  2920.  
  2921.  The utterance structure lies at the heart of Festival.  This chapter describes 
  2922.  its basic form and the functions available to manipulate it. 
  2923.  
  2924.  Utterance structure           internal structure of utterances 
  2925.  Utterance types               Type defined synthesis actions 
  2926.  Example utterance types       Some example utterances 
  2927.  Utterance modules 
  2928.  Accessing an utterance        getting the data from the structure 
  2929.  Features                      Features and features names 
  2930.  Utterance I/O                 Saving and loading utterances 
  2931.  
  2932.  
  2933. ΓòÉΓòÉΓòÉ 15.1. Utterance structure ΓòÉΓòÉΓòÉ
  2934.  
  2935.  Festival's basic object for synthesis is the utterance.  An represents some 
  2936.  chunk of text that is to be rendered as speech.  In general you may think of 
  2937.  it as a sentence but in many cases it wont actually conform to the standard 
  2938.  linguistic syntactic form of a sentence.  In general the process of text to 
  2939.  speech is to take an utterance which contaisn a simple string of characters 
  2940.  and convert it step by step, filling out the utterance structure with more 
  2941.  information until a waveform is built that says what the text contains. 
  2942.  
  2943.  The processes involved in convertion are, in general, as follows 
  2944.  
  2945.  Tokenization Converting the string of characters into a list of tokens. 
  2946.            Typically this means whitespace separated tokesn of the original 
  2947.            text string. 
  2948.  
  2949.  Token identificationidentification of general types for the tokens, usually 
  2950.            this is trivial but requires some work to identify tokens of digits 
  2951.            as years, dates, numbers etc. 
  2952.  
  2953.  Token to wordConvert each tokens to zero or more words, expanding numbers, 
  2954.            abbreviations etc. 
  2955.  
  2956.  Part of speechIdentify the syntactic part of speech for the words. 
  2957.  
  2958.  Prosodic phrasingChunk utterance into prosodic phrases. 
  2959.  
  2960.  Lexical lookupFind the pronucnation of each word from a lexicon/letter to 
  2961.            sound rule system including phonetic and syllable structure. 
  2962.  
  2963.  Intonational accentsAssign intonation accents to approrpiate syllables. 
  2964.  
  2965.  Assign durationAssign duration to each phone in the utterance. 
  2966.  
  2967.  Generate F0 contour (tune)Generate tune based on accents etc. 
  2968.  
  2969.  Render waveformRender waveform from phones, duration and F) target values, 
  2970.            this itself may take several steps including unit selection (be they 
  2971.            diphones or other sized units), imposition of dsesired prosody 
  2972.            (duration and F0) and waveform reconstruction. 
  2973.  The number of steps and what actually happens may vary and is dependent on the 
  2974.  particular voice selected and the utterance's type, see below. 
  2975.  
  2976.  Each of these steps in Festival is achived by a module which will typically 
  2977.  add new information to the utterance structure. 
  2978.  
  2979.  An utterance structure consists of a set of items which may be part of one or 
  2980.  more relations.  Items represent things like words and phones, though may also 
  2981.  be used to represent less concrete objects like noun phrases, and nodes in 
  2982.  metrical trees.  An item contains a set of features, (name and value). 
  2983.  Relations are typically simple lists of items or trees of items.  For example 
  2984.  the the Word relation is a simple list of items each of which represent a word 
  2985.  in the utternace. Those words will also be in other relations, such as the 
  2986.  SylStructure relation where the word will be the top of a tree structure 
  2987.  containing its syllables and segments. 
  2988.  
  2989.  Unlike previous versions of the system items (then called stream items) are 
  2990.  not in any particular relations (or stream).  And are merely part of the 
  2991.  relations they are within.  Importantly this allows much more general 
  2992.  relations to be made over items that was allowed in the previous system.  This 
  2993.  new architecture is the continuation of our goal of providing a general 
  2994.  efficient structure for representing complex interrelated utterance objects. 
  2995.  
  2996.  The architecture is fully general and new items and relations may be defined 
  2997.  at run time, such that new modules may use any relations they wish. However 
  2998.  within our standard English (and other voices) we have used a specific set of 
  2999.  relations ass follows. 
  3000.  
  3001.  Token     a list of trees.  This is first formed as a list of tokens found in 
  3002.            a character text string.  Each root's daughters are the Word's that 
  3003.            the token is related to. 
  3004.  
  3005.  Word      a list of words.  These items will also appear as daughters (leaf 
  3006.            nodes) of the Token relation.  They may also appear in the Syntax 
  3007.            relation (as leafs) if the parser is used.  They will also be leafs 
  3008.            of the Phrase relation. 
  3009.  
  3010.  Phrase    a list of trees.  This is a list of phrase roots whose daughters are 
  3011.            the Word's within those phrases. 
  3012.  
  3013.  Syntax    a single tree.  This, if the probabilistic parser is called, is a 
  3014.            syntactic binary branching tree over the members of the Word 
  3015.            relation. 
  3016.  
  3017.  SylStructurea list of trees.  This links the Word, Syllable and Segment 
  3018.            relations.  Each Word is the root of a tree whose immediate 
  3019.            daughters are its syllables and their daughters in turn as its 
  3020.            segments. 
  3021.  
  3022.  Syllable  a list of syllables.  Each member will also be in a the SylStructure 
  3023.            relation.  In that relation its parent will be the word it is in and 
  3024.            its daughters will be the segments that are in it. Syllables are 
  3025.            also in the Intonation relation giving links to their related 
  3026.            intonation events. 
  3027.  
  3028.  Segment   a list of segments (phones).  Each member (except silences) will be 
  3029.            leaf nodes in the SylStructure relation.  These may also be in the 
  3030.            Target relation linking them to F0 target points. 
  3031.  
  3032.  IntEvent  a list of intonation events (accents and bounaries).  These are 
  3033.            related to syllables through the Intonation relation as leafs on 
  3034.            that relation.  Thus their parent in the Intonation relation is the 
  3035.            syllable these events are attached to. 
  3036.  
  3037.  Intonationa list of trees relating syllables to intonation events.  Roots of 
  3038.            the trees in Intonation are Syllables and their daughters are 
  3039.            IntEvents. 
  3040.  
  3041.  Wave      a single item with a feature called wave whose value is the 
  3042.            generated waveform. 
  3043.  This is a non-exhaustive list some modules may add other relations and not all 
  3044.  utterance may have all these relations, but the above is the general case. 
  3045.  
  3046.  
  3047. ΓòÉΓòÉΓòÉ 15.2. Utterance types ΓòÉΓòÉΓòÉ
  3048.  
  3049.  The primary purpose of types is to define which modules are to be applied to 
  3050.  an utterance.  UttTypes are defined in 'lib/synthesis.scm'.  The function 
  3051.  defUttType defines which modules are to be applied to an utterance of that 
  3052.  type.  The function utt.synth is called applies this list of module to an 
  3053.  utterance before waveform synthesis is called. 
  3054.  
  3055.  For example when a Segment type Utterance is synthesized it needs only have 
  3056.  its values loaded into a Segment relation and a Target relation, then the low 
  3057.  level waveform synthesis module Wave_Synth is called.  This is defined as 
  3058.  follows 
  3059.  
  3060.                       (defUttType Segments
  3061.                        (Initialize utt)
  3062.                        (Wave_Synth utt))
  3063.  A more complex type is Text type utterance which requires many more modules to 
  3064.  be called before a waveform can be synthesized 
  3065.  
  3066.                       (defUttType Text
  3067.                        (Initialize utt)
  3068.                        (Text utt)
  3069.                        (Token utt)
  3070.                        (POS utt)
  3071.                        (Phrasify utt)
  3072.                        (Word utt)
  3073.                        (Intonation utt)
  3074.                        (Duration utt)
  3075.                        (Int_Targets utt)
  3076.                        (Wave_Synth utt)
  3077.                       )
  3078.  The Initialize module should normally be called for all types.  It loads the 
  3079.  necessary relations from the input form and deletes all other relations (if 
  3080.  any exist) ready for synthesis. 
  3081.  
  3082.  Modules may be directly defined as C/C++ functions and declared with a Lisp 
  3083.  name or simple functions in Lisp that check some global parameter before 
  3084.  calling a specific module (e.g. choosing between different intonation 
  3085.  modules). 
  3086.  
  3087.  These types are used when calling the function utt.synth and individual 
  3088.  modules may be called explicitly by hand if required. 
  3089.  
  3090.  Because we expect waveform synthesis methods to themselves become complex with 
  3091.  a defined set of functions to select, join, and modify units we now support an 
  3092.  addition notion of SynthTypes like UttTypes these define a set of functions to 
  3093.  apply to an utterance.  These may be defined using the defSynthType function. 
  3094.  For example 
  3095.  
  3096.                       (defSynthType Festival
  3097.                        (print "synth method Festival")
  3098.  
  3099.                        (print "select")
  3100.                        (simple_diphone_select utt)
  3101.                        (print "join")
  3102.                        (cut_unit_join utt)
  3103.                        (print "impose")
  3104.                        (simple_impose utt)
  3105.                        (simple_power utt)
  3106.                        (print "synthesis")
  3107.                        (frames_lpc_synthesis utt)
  3108.                        )
  3109.  A SynthType is selected by naming as the value of the parameter Synth_Method. 
  3110.  
  3111.  Duration the application of the function utt.synth there are three hooks 
  3112.  applied.  This allows addition control of the synthesis process. 
  3113.  before_synth_hooks is applied before any modules are applied. 
  3114.  after_analysis_hooks is applied at the start of Wave_Synth when all text, 
  3115.  linguistic and prosodic processing have been done.  after_synth_hooks is 
  3116.  applied after all modules have been applied.  These are useful for things such 
  3117.  as, altering the volume of a voice that happens to be quieter than others, or 
  3118.  for example outputing information for a talking head before waveform synthesis 
  3119.  occurs so preparation of the facial frames and synthesizing the waveform may 
  3120.  be done in parallel.  (see 'festival/examples/th-mode.scm' for an example use 
  3121.  of these hooks for a talking head text mode.) 
  3122.  
  3123.  
  3124. ΓòÉΓòÉΓòÉ 15.3. Example utterance types ΓòÉΓòÉΓòÉ
  3125.  
  3126.  A number of utterance types are currently supported.  It is easy to add new 
  3127.  ones but the standard distribution includes the following. 
  3128.  
  3129.  Text      Raw text as a string. 
  3130.  
  3131.                       (Utterance Text "This is an example")
  3132.  
  3133.  Words     A list of words 
  3134.  
  3135.                       (Utterance Words (this is an example))
  3136.  Words may be atomic or lists if further features need to be specified. For 
  3137.  example to specify a word and its part of speech you can use 
  3138.  
  3139.                       (Utterance Words (I (live (pos v)) in (Reading (pos n) (tone H-H%))))
  3140.  Note: the use of the tone feature requires an intonation mode that supports 
  3141.  it. 
  3142.  
  3143.  Any feature and value named in the input will be added to the Word item. 
  3144.  
  3145.  Phrase    This allows explicit phrasing and features on Tokens to be 
  3146.            specified. The input consists of a list of phrases each contains a 
  3147.            list of tokens. 
  3148.  
  3149.                       (Utterance
  3150.                        Phrase
  3151.                        ((Phrase ((name B))
  3152.                         I saw the man
  3153.                         (in ((EMPH 1)))
  3154.                         the park)
  3155.                        (Phrase ((name BB))
  3156.                         with the telescope)))
  3157.  ToBI tones and accents may also be specified on Tokens but these will only 
  3158.  take effect if the selected intonation method uses them. 
  3159.  
  3160.  Segments  This allows specification of segments, durations and F0 target 
  3161.            values. 
  3162.  
  3163.                       (Utterance
  3164.                        Segments
  3165.                        ((# 0.19 )
  3166.                        (h 0.055 (0 115))
  3167.                        (@ 0.037 (0.018 136))
  3168.                        (l 0.064 )
  3169.                        (ou 0.208 (0.0 134) (0.100 135) (0.208 123))
  3170.                        (# 0.19)))
  3171.  Note the times are in seconds NOT milliseconds.  The format of each segment 
  3172.  entry is segment name, duration in seconds, and list of target values.  Each 
  3173.  target value consists of a pair of point into the segment (in seconds) and F0 
  3174.  value in Hz. 
  3175.  
  3176.  Phones    This allows a simple specification of a list of phones.  Synthesis 
  3177.            specifies fixed durations (specified in FP_duration, default 100 ms) 
  3178.            and monotone intonation (specified in FP_F0, default 120Hz). This 
  3179.            may be used for simple checks for waveform synthesizers etc. 
  3180.  
  3181.                       (Utterance Phones (# h @ l ou #))
  3182.  Note the function SayPhones allows synthesis and playing of lists of phones 
  3183.  through this utterance type. 
  3184.  
  3185.  Wave      A waveform file.  Synthesis here simply involves loading the file. 
  3186.  
  3187.                       (Utterance Wave fred.wav)
  3188.  
  3189.  Others are supported, as defined in 'lib/synthesis.scm' but are used 
  3190.  internally by various parts of the system.  These include Tokens used in TTS 
  3191.  and SegF0 used by utt.resynth. 
  3192.  
  3193.  
  3194. ΓòÉΓòÉΓòÉ 15.4. Utterance modules ΓòÉΓòÉΓòÉ
  3195.  
  3196.  The module is the basic unit that does the work of synthesis.  Within Festival 
  3197.  there are duration modules, intonation modules, wave synthesis modules etc. 
  3198.  As stated above the utterance type defines the set of modules which are to be 
  3199.  applied to the utterance.  These modules in turn will create relations and 
  3200.  items so that ultimately a waveform is generated, if required. 
  3201.  
  3202.  Many of the chapters in this manual are solely concerned with particular 
  3203.  modules in the system.  Note that many modules have internal choices, such as 
  3204.  which duration method to use or which intonation method to use.  Such general 
  3205.  choices are often done through the Parameter system.  Parameters may be set 
  3206.  for different features like Duration_Method, Synth_Method etc.  Formerly the 
  3207.  values for these parameters were atomic values but now they may be the 
  3208.  functions themselves.  For example, to select the Klatt duration rules 
  3209.  
  3210.                       (Parameter.set 'Duration_Method Duration_Klatt)
  3211.  This allows new modules to be added without requiring changes to the central 
  3212.  Lisp functions such as Duration, Intonation, and Wave_Synth. 
  3213.  
  3214.  
  3215. ΓòÉΓòÉΓòÉ 15.5. Accessing an utterance ΓòÉΓòÉΓòÉ
  3216.  
  3217.  There are a number of standard functions that allow one to access parts of an 
  3218.  utterance and traverse through it. 
  3219.  
  3220.  Functions exist in Lisp (and of course C++) for accessing an utterance. The 
  3221.  Lisp access functions are 
  3222.  
  3223.  '(utt.relationnames UTT)' returns a list of the names of the relations 
  3224.            currently created in UTT. 
  3225.  
  3226.  '(utt.relation.items UTT RELATIONNAME)'returns a list of all items in 
  3227.            RELATIONNAME in UTT.  This is nil if no relation of that name 
  3228.            exists.  Note for tree relation will give the items in pre-order. 
  3229.  
  3230.  '(utt.relation_tree UTT RELATIONNAME)'A Lisp tree presentation of the items 
  3231.            RELATIONNAME in UTT. The Lisp bracketing reflects the tree structure 
  3232.            in the relation. 
  3233.  
  3234.  '(utt.relation.leafs UTT RELATIONNAME)'A list of all the leafs of the items in 
  3235.            RELATIONNAME in UTT.  Leafs are defined as those items with no 
  3236.            daughters within that relation.  For simple list relations 
  3237.            utt.relation.leafs and utt.relation.items will return the same 
  3238.            thing. 
  3239.  
  3240.  '(utt.relation.first UTT RELATIONNAME)'returns the first item in RELATIONNAME. 
  3241.            Returns nil if this relation contains no items 
  3242.  
  3243.  '(utt.relation.last UTT RELATIONNAME)'returns the last (the most next) item in 
  3244.            RELATIONNAME.  Returns nil if this relation contains no items 
  3245.  
  3246.  '(item.feat ITEM FEATNAME)'returns the value of feature FEATNAME in ITEM. 
  3247.            FEATNAME may be a feature name, feature function name, or pathname 
  3248.            (see below). allowing reference to other parts of the utterance this 
  3249.            item is in. 
  3250.  
  3251.  '(item.features ITEM)'Returns an assoc list of feature-value pairs of all 
  3252.            local features on this item. 
  3253.  
  3254.  '(item.name ITEM)'Returns the name of this ITEM.  This could also be accessed 
  3255.            as (item.feat ITEM 'name). 
  3256.  
  3257.  '(item.set_name ITEM NEWNAME)'Sets name on ITEM to be NEWNAME.  This is 
  3258.            equivalent to (item.set_feat ITEM 'name NEWNAME) 
  3259.  
  3260.  '(item.set_feat ITEM FEATNAME FEATVALUE)'set the value of FEATNAME to 
  3261.            FEATVALUE in ITEM. FEATNAME should be a simple name and not refer to 
  3262.            next, previous or other relations via links. 
  3263.  
  3264.  '(item.relation ITEM RELATIONNAME)'Return the item as viewed from 
  3265.            RELATIONNAME, or nil if ITEM is not in that relation. 
  3266.  
  3267.  '(item.relationnames ITEM)'Return a list of relation names that this item is 
  3268.            in. 
  3269.  
  3270.  '(item.relationname ITEM)'Return the relation name that this item is currently 
  3271.            being viewed as. 
  3272.  
  3273.  '(item.next ITEM)'Return the next item in ITEM's current relation, or nil if 
  3274.            there is no next. 
  3275.  
  3276.  '(item.prev ITEM)'Return the previous item in ITEM's current relation, or nil 
  3277.            if there is no previous. 
  3278.  
  3279.  '(item.parent ITEM)'Return the parent of ITEM in ITEM's current relation, or 
  3280.            nil if there is no parent. 
  3281.  
  3282.  '(item.daughter1 ITEM)'Return the first daughter of ITEM in ITEM's current 
  3283.            relation, or nil if there are no daughters. 
  3284.  
  3285.  '(item.daughter2 ITEM)'Return the second daughter of ITEM in ITEM's current 
  3286.            relation, or nil if there is no second daughter. 
  3287.  
  3288.  '(item.daughtern ITEM)'Return the last daughter of ITEM in ITEM's current 
  3289.            relation, or nil if there are no daughters. 
  3290.  
  3291.  '(item.leafs ITEM)'Return a list of all lefs items (those with no daughters) 
  3292.            dominated by this item. 
  3293.  
  3294.  '(item.next_leaf ITEM)'Find the next item in this relation that has no 
  3295.            daughters.  Note this may traverse up the tree from this point to 
  3296.            search for such an item. 
  3297.  
  3298.  As from 1.2 the utterance structure may be fully manipulated from Scheme. 
  3299.  Relations and items may be created and deleted, as easily as they can in C++; 
  3300.  
  3301.  '(utt.relation.present UTT RELATIONNAME)' returns t if relation named 
  3302.            RELATIONNAME is present, nil otherwise. 
  3303.  
  3304.  '(utt.relation.create UTT RELATIONNAME)'Creates a new relation called 
  3305.            RELATIONNAME.  If this relation already exists it is deleted first 
  3306.            and items in the relation are derefenced from it (deleting the items 
  3307.            if they are no longer referenced by any relation).  Thus create 
  3308.            relation guarantees an empty relation. 
  3309.  
  3310.  '(utt.relation.delete UTT RELATIONNAME)'Deletes the relation called 
  3311.            RELATIONNAME in utt.  All items in that relation are derefenced from 
  3312.            the relation and if they are no longer in any relation the items 
  3313.            themselves are deleted. 
  3314.  
  3315.  '(utt.relation.append UTT RELATIONNAME ITEM)'Append ITEM to end of relation 
  3316.            named RELATIONNAME in UTT.  Returns nil if there is not relation 
  3317.            named RELATIONNAME in UTT otherwise returns the item appended.  This 
  3318.            new item becomes the last in the top list. ITEM item may be an item 
  3319.            itself (in this or another relation) or a LISP description of an 
  3320.            item, which consist of a list containing a name and a set of feature 
  3321.            vale pairs.  It ITEM is nil or inspecified an new empty item is 
  3322.            added.  If ITEM is already in this relation it is dereferenced from 
  3323.            its current position (and an emtpy item re-inserted). 
  3324.  
  3325.  '(item.insert ITEM1 ITEM2 DIRECTION)'Insert ITEM2 into ITEM1's relation in the 
  3326.            direction specified by DIRECTION.  DIRECTION may take the value, 
  3327.            before, after, above and below. If unspecified, after is assumed. 
  3328.            Note it is not recommended to insert above and below and the 
  3329.            functions item.insert_parent and item.append_daughter should 
  3330.            normally be used for tree building. Inserting using before and after 
  3331.            within daughters is perfectly safe. 
  3332.  
  3333.  '(item.append_daughter PARENT DAUGHTER)'Append DAUGHTER, an item or a 
  3334.            description of an item to the item PARENT in the PARENT's relation. 
  3335.  
  3336.  '(item.insert_parent DAUGHTER NEWPARENT)'Insert a new parent above DAUGHTER. 
  3337.            NEWPARENT may be a item or the description of an item. 
  3338.  
  3339.  '(item.delete ITEM)'Delete this item from all relations it is in.  All 
  3340.            daughters of this item in each relations are also removed from the 
  3341.            relation (which may in turn cause them to be deleted if they cease 
  3342.            to be referenced by any other relation. 
  3343.  
  3344.  '(item.relation.remove ITEM)'Remove this item from this relation, and any of 
  3345.            its daughters.  Other relations this item are in remain untouched. 
  3346.  
  3347.  '(item.move_tree FROM TO)'Move the item FROM to the position of TO in TO's 
  3348.            relation.  FROM will often be in the same relation as TO but that 
  3349.            isn't necessary.  The contents of TO are dereferenced. its daughters 
  3350.            are saved then descendants of FROM are recreated under the new TO, 
  3351.            then TO's previous daughters are derefenced.  The order of this is 
  3352.            important as FROM may be part of TO's descendants.  Note that if TO 
  3353.            is part of FROM's descendants no moving occurs and nil is returned. 
  3354.            For example to remove all punction terminal nodes in the Syntax 
  3355.            relation the call would be something like 
  3356.  
  3357.                       (define (syntax_relation_punc p)
  3358.                        (if (string-equal "punc" (item.feat (item.daughter2 p) "pos"))
  3359.                          (item.move_tree (item.daughter1 p) p)
  3360.                        (mapcar syntax_remove_punc (item.daughters p))))
  3361.  
  3362.  '(item.exchange_trees ITEM1 ITEM2)'Exchange ITEM1 and ITEM2 and their 
  3363.            descendants in ITEM2's relation.  If ITEM1 is within ITEM2's 
  3364.            descendents or vice versa nil is returns and no exchange takes 
  3365.            place.  If ITEM1 is not in ITEM2's relation, no exchange takes 
  3366.            place. 
  3367.  
  3368.  Daughters of a node are actually represented as a list whose first daughter is 
  3369.  double linked to the parent.  Although being aware of this structure may be 
  3370.  useful it is recommended that all access go through the tree specific 
  3371.  functions *.parent and *.daughter* which properly deal with the structure, 
  3372.  thus is the internal structure ever changes in the future only these tree 
  3373.  access function need be updated. 
  3374.  
  3375.  With the above functions quite elaborate utterance manipulations can be 
  3376.  performed.  For example in post-lexical rules where modifications to the 
  3377.  segments are required based on the words and their context. See Post-lexical 
  3378.  rules for an example of using various utterance access functions. 
  3379.  
  3380.  
  3381. ΓòÉΓòÉΓòÉ 15.6. Features ΓòÉΓòÉΓòÉ
  3382.  
  3383.  In previous versions items had a number of predefined features.  This is no 
  3384.  longer the case and all features are optional.  Particularly the start and end 
  3385.  features are no longer fixed, though those names are still used in the 
  3386.  relations where yjeu are appropriate. Specific functions are provided for the 
  3387.  name feature but they are just short hand for normal feature access.  Simple 
  3388.  features directly access the features in the underlying EST_Feature class in 
  3389.  an item. 
  3390.  
  3391.  In addition to simple features there is a mechanism for relating functions to 
  3392.  names, thus accessing a feature may actually call a function.  For example the 
  3393.  features num_syls is defined as a feature function which will count the number 
  3394.  of syllables in the given word, rather than simple access a pre-existing 
  3395.  feature.  Feature functions are usually dependent on the particular realtion 
  3396.  the item is in, e.g. some feature functions are only appropriate for items in 
  3397.  the Word relation, or only appropriate for those in the IntEvent relation. 
  3398.  
  3399.  The third aspect of feature names is a path component.  These are parts of the 
  3400.  name (preceding in .) that indicated some trversal of the utterance structure. 
  3401.  For example the features name will access the name feature on the given item. 
  3402.  The feature n.name will return the name feature on the next item (in that 
  3403.  item's relation).  A number of basic direction operators are defined. 
  3404.  
  3405.  n.        next 
  3406.  
  3407.  p.        previous 
  3408.  
  3409.  nn.       next next 
  3410.  
  3411.  pp.       previous 
  3412.  
  3413.   parent.
  3414.  
  3415.  daughter1.first daughter 
  3416.  
  3417.  daughter2.second daughter 
  3418.  
  3419.  daughtern.last daughter 
  3420.  
  3421.  first.    most previous item 
  3422.  
  3423.  last.     most next item 
  3424.  Also you may specific traversal to another relation relation, though the 
  3425.  R:<relationame>. operator.  For example given an Item in the syllable relation 
  3426.  R:SylStructure.parent.name would give the name of word the syllable is in. 
  3427.  
  3428.  Some more complex examples are as follows, assuming we are starting form an 
  3429.  item in the Syllable relation. 
  3430.  
  3431.  'stress'  This item's lexical stress 
  3432.  
  3433.  'n.stress'The next syllable's lexical stress 
  3434.  
  3435.  'p.stress'The previous syllable's lexical stress 
  3436.  
  3437.  'R:SylStructure.parent.name'The word this syllable is in 
  3438.  
  3439.  'R:SylStructure.parent.R:Word.n.name'The word next to the word this syllable 
  3440.            is in 
  3441.  
  3442.  'n.R:SylStructure.parent.name'The word the next syllable is in 
  3443.  
  3444.  'R:SylStructure.daughtern.ph_vc'The phonetic feature vc of the final segment 
  3445.            in this syllable. 
  3446.  A list of all feature functions is given in an appendix of this document. See 
  3447.  Feature functions.  New functions may also be added in Lisp. 
  3448.  
  3449.  In C++ feature values are of class EST_Val which may be a string, int, or a 
  3450.  float (or any arbitrary object).  In Scheme this distinction cannot not always 
  3451.  be made and sometimes when you expect an int you actually get a string.  Care 
  3452.  should be take to ensure the right matching functions are use in Scheme.  It 
  3453.  is recommended you use string-append or string-match as they will always work. 
  3454.  
  3455.  If a pathname does not identify a valid path for the particular item (e.g. 
  3456.  there is no next) "0" is returned. 
  3457.  
  3458.  When collecting data from speech databases it is often useful to collect a 
  3459.  whole set of features from all utterances in a database.  These features can 
  3460.  then be used for building various models (both CART tree models and linear 
  3461.  regression modules use these feature names), 
  3462.  
  3463.  A number of functions exist to help in this task.  For example 
  3464.  
  3465.                       (utt.features utt1 'Word '(name pos p.pos n.pos))
  3466.  will return a list of word, and part of speech context for each word in the 
  3467.  utterance. 
  3468.  
  3469.  See Extracting features for an example of extracting sets of features from a 
  3470.  database for use in building stochastic models. 
  3471.  
  3472.  
  3473. ΓòÉΓòÉΓòÉ 15.7. Utterance I/O ΓòÉΓòÉΓòÉ
  3474.  
  3475.  A number of functions are available to allow an utterance's structure to be 
  3476.  made available for other programs. 
  3477.  
  3478.  The whole structure, all relations, items and features may be saved in an 
  3479.  ascii format using the function utt.save.  This file may be reloaded using the 
  3480.  utt.load function.  Note the waveform is not saved using the form. 
  3481.  
  3482.  Individual aspects of an utterance may be selectively saved.  The waveform 
  3483.  itself may be saved using the function utt.save.wave. This will save the 
  3484.  waveform in the named file in the format specified in the Parameter 
  3485.  Wavefiletype.  All formats supported by the Edinburgh Speech Tools are valid 
  3486.  including nist, esps, sun, riff, aiff, raw and ulaw.  Note the functions 
  3487.  utt.wave.rescale and utt.wave.resample may be used to change the gain and 
  3488.  sample frequency of the waveform before saving it.  A waveform may be imported 
  3489.  into an existing utterance with the function utt.import.wave.  This is 
  3490.  specifically designed to allow external methods of waveform synthesis. 
  3491.  However if you just wish to play an external wave or make it into an utterance 
  3492.  you should consider the utterance Wave type. 
  3493.  
  3494.  The segments of an utterance may be saved in a file using the function 
  3495.  utt.save.segs which saves the segments of the named utterance in xlabel 
  3496.  format.  Any other stream may also be saved using the more general 
  3497.  utt.save.relation which takes the additional argument of a relation name.  The 
  3498.  names of each item and the end feature of each item are saved in the named 
  3499.  file, again in Xlabel format, other features are saved in extra fields.  For 
  3500.  more elaborated saving methods you can easily write a Scheme function to save 
  3501.  data in an utterance in whatever format is required.  See the file 
  3502.  'lib/mbrola.scm' for an example. 
  3503.  
  3504.  A simple function to allow the displaying of an utterance in Entropic's Xwaves 
  3505.  tool is provided by the function display. It simply saves the waveform and the 
  3506.  segments and sends appropriate commands to (the already running) Xwaves and 
  3507.  xlabel programs. 
  3508.  
  3509.  A function to synthesize an externally specified utterance is provided for by 
  3510.  utt.resynth which takes two filename arguments, an xlabel segment file and an 
  3511.  F0 file.  This function loads, synthesizes and plays an utterance synthesized 
  3512.  from these files.  The loading is provided by the underlying function 
  3513.  utt.load.segf0. 
  3514.  
  3515.  
  3516. ΓòÉΓòÉΓòÉ 16. Text analysis ΓòÉΓòÉΓòÉ
  3517.  
  3518.  Tokenizing                    Splitting text into tokens 
  3519.  Token to word rules 
  3520.  Homograph disambiguation      "Wed 5 may wind US Sen up" 
  3521.  
  3522.  
  3523. ΓòÉΓòÉΓòÉ 16.1. Tokenizing ΓòÉΓòÉΓòÉ
  3524.  
  3525.  A crucial stage in text processing is the initial tokenization of text. A 
  3526.  token in Festival is an atom separated with whitespace from a text file (or 
  3527.  string).  If punctuation for the current language is defined, characters 
  3528.  matching that punctuation are removed from the beginning and end of a token 
  3529.  and held as features of the token.  The default list of characters to be 
  3530.  treated as white space is defined as 
  3531.  
  3532.                       (defvar token.whitespace " \t\n\r")
  3533.  While the default set of punctuation characters is 
  3534.  
  3535.                       (defvar token.punctuation "\"'`.,:;!?(){}[]")
  3536.                       (defvar token.prepunctuation "\"'`({[")
  3537.  These are declared in 'lib/token.scm' but may be changed for different 
  3538.  languages, text modes etc. 
  3539.  
  3540.  
  3541. ΓòÉΓòÉΓòÉ 16.2. Token to word rules ΓòÉΓòÉΓòÉ
  3542.  
  3543.  Tokens are further analysed into lists of words.  A word is an atom that can 
  3544.  be given a pronunciation by the lexicon (or letter to sound rules).  A token 
  3545.  may give rise to a number of words or none at all. 
  3546.  
  3547.  For example the basic tokens 
  3548.  
  3549.                       This pocket-watch was made in 1983.
  3550.  would give a word relation of 
  3551.  
  3552.                       this pocket watch was made in nineteen eighty three
  3553.  
  3554.  Becuase the relationship between tokens and word in some cases is complex, a 
  3555.  user function may be specified for translating tokens into words.  This is 
  3556.  designed to deal with things like numbers, email addresses, and other 
  3557.  non-obvious pronunciations of tokens as zero or more words.  Currently a 
  3558.  builtin function builtin_english_token_to_words offers much of the necessary 
  3559.  functionality for English but a user may further customize this. 
  3560.  
  3561.  If the user defines a function token_to_words which takes two arguments: a 
  3562.  token item and a token name, it will be called by the Token_English and 
  3563.  Token_Any modules.  A substantial example is given as english_token_to_words 
  3564.  in 'festival/lib/token.scm'. 
  3565.  
  3566.  An example of this function is in 'lib/token.scm'.  It is quite elaborate and 
  3567.  covers most of the common multi-word tokens in English including, numbers, 
  3568.  money symbols, Roman numerals, dates, times, plurals of symbols, number 
  3569.  ranges, telephone number and various other symbols. 
  3570.  
  3571.  Let us look at the treatment of one particular phenomena which shows the use 
  3572.  of these rules.  Consider the expression "$12 million" which should be 
  3573.  rendered as the words "twelve million dollars".  Note the word "dollars" which 
  3574.  is introduced by the "$" sign, ends up after the end of the expression.  There 
  3575.  are two cases we need to deal with as there are two tokens.  The first 
  3576.  condition in the cond checks if the current token name is a money symbol, 
  3577.  while the second condition check that following word is a magnitude (million, 
  3578.  billion, trillion, zillion etc.)  If that is the case the "$" is removed and 
  3579.  the remaining numbers are pronounced, by calling the builtin token to word 
  3580.  function.  The second condition deals with the second token.  It confirms the 
  3581.  previous is a money value (the same regular expression as before) and then 
  3582.  returns the word followed by the word "dollars".  If it is neither of these 
  3583.  forms then the builtin function is called. 
  3584.  
  3585.                       (define (token_to_words token name)
  3586.                       "(token_to_words TOKEN NAME)
  3587.                       Returns a list of words for NAME from TOKEN."
  3588.                        (cond
  3589.                        ((and (string-matches name "\\$[0-9,]+\\(\\.[0-9]+\\)?")
  3590.                           (string-matches (item.feat token "n.name") ".*illion.?"))
  3591.                         (builtin_english_token_to_words token (string-after name "$")))
  3592.                        ((and (string-matches (item.feat token "p.name")
  3593.                                    "\\$[0-9,]+\\(\\.[0-9]+\\)?")
  3594.                           (string-matches name ".*illion.?"))
  3595.                         (list
  3596.                         name
  3597.                         "dollars"))
  3598.                        (t
  3599.                         (builtin_english_token_to_words token name))))
  3600.  It is valid to make some conditions return no words, though some care should 
  3601.  be taken with that, as punctuation information may no longer be available to 
  3602.  later processing if there are no words related to a token. 
  3603.  
  3604.  
  3605. ΓòÉΓòÉΓòÉ 16.3. Homograph disambiguation ΓòÉΓòÉΓòÉ
  3606.  
  3607.  Not all tokens can be rendered as words easily.  Their context may affect the 
  3608.  way they are to be pronounced.  For example in the utterance 
  3609.  
  3610.                       On May 5 1985, 1985 people moved to Livingston.
  3611.  the tokens "1985" should be pronounced differently, the first as a year, 
  3612.  "nineteen eighty five" while the second as a quantity "one thousand nine 
  3613.  hundred and eighty five".  Numbers may also be pronounced as ordinals as in 
  3614.  the "5" above, it should be "fifth" rather than "five". 
  3615.  
  3616.  Also, the pronunciation of certain words cannot simply be found from their 
  3617.  orthographic form alone.  Linguistic part of speech tags help to disambiguate 
  3618.  a large class of homographs, e.g. "lives".  A part of speech tagger is 
  3619.  included in Festival and discussed in POS tagging.  But even part of speech 
  3620.  isn't sufficient in a number of cases.  Words such as "bass", "wind", "bow" 
  3621.  etc cannot by distinguished by part of speech alone, some semantic information 
  3622.  is also required.  As full semantic analysis of text is outwith the realms of 
  3623.  Festival's capabilities some other method for disambiguation is required. 
  3624.  
  3625.  Following the work of yarowsky96 we have included a method for identified 
  3626.  tokens to be further labelled with extra tags to help identify their type. 
  3627.  Yarowsky uses decision lists to identify different types for homographs. 
  3628.  Decision lists are a restricted form of decision trees which have some 
  3629.  advantages over full trees, they are easier to build and Yarowsky has shown 
  3630.  them to be adequate for typical homograph resolution. 
  3631.  
  3632.  
  3633. ΓòÉΓòÉΓòÉ 16.3.1. Using disambiguators ΓòÉΓòÉΓòÉ
  3634.  
  3635.  Festival offers a method for assigning a token_pos feature to each token.  It 
  3636.  does so using Yarowsky-type disambiguation techniques. A list of 
  3637.  disambiguators can be provided in the variable token_pos_cart_trees.  Each 
  3638.  disambiguator consists of a regular expression and a CART tree (which may be a 
  3639.  decision list as they have the same format).  If a token matches the regular 
  3640.  expression the CART tree is applied to the token and the resulting class is 
  3641.  assigned to the token via the feature token_pos.  This is done by the 
  3642.  Token_POS module. 
  3643.  
  3644.  For example, the follow disambiguator distinguishes "St" (street and saint) 
  3645.  and "Dr" (doctor and drive). 
  3646.  
  3647.                         ("\\([dD][Rr]\\|[Ss][tT]\\)"
  3648.                         ((n.name is 0)
  3649.                          ((p.cap is 1)
  3650.                          ((street))
  3651.                          ((p.name matches "[0-9]*\\(1[sS][tT]\\|2[nN][dD]\\|3[rR][dD]\\|[0-9][tT][hH]\\)")
  3652.                           ((street))
  3653.                           ((title))))
  3654.                          ((punc matches ".*,.*")
  3655.                          ((street))
  3656.                          ((p.punc matches ".*,.*")
  3657.                           ((title))
  3658.                           ((n.cap is 0)
  3659.                           ((street))
  3660.                           ((p.cap is 0)
  3661.                            ((p.name matches "[0-9]*\\(1[sS][tT]\\|2[nN][dD]\\|3[rR][dD]\\|[0-9][tT][hH]\\)")
  3662.                            ((street))
  3663.                            ((title)))
  3664.                            ((pp.name matches "[1-9][0-9]+")
  3665.                            ((street))
  3666.                            ((title)))))))))
  3667.  Note that these only assign values for the feature token_pos and do nothing 
  3668.  more.  You must have a related token to word rule that interprets this feature 
  3669.  value and does the required translation.  For example the corresponding token 
  3670.  to word rule for the above disambiguator is 
  3671.  
  3672.                        ((string-matches name "\\([dD][Rr]\\|[Ss][tT]\\)")
  3673.                         (if (string-equal (item.feat token "token_pos") "street")
  3674.                           (if (string-matches name "[dD][rR]")
  3675.                             (list "drive")
  3676.                             (list "street"))
  3677.                           (if (string-matches name "[dD][rR]")
  3678.                             (list "doctor")
  3679.                             (list "saint"))))
  3680.  
  3681.  
  3682. ΓòÉΓòÉΓòÉ 16.3.2. Building disambiguators ΓòÉΓòÉΓòÉ
  3683.  
  3684.  Festival offers some support for building disambiguation trees.  The basic 
  3685.  method is to find all occurrences of a homographic token in a large text 
  3686.  database, label each occurrence into classes, extract appropriate context 
  3687.  features for these tokens and finally build an classification tree or decision 
  3688.  list based on the extracted features. 
  3689.  
  3690.  The extraction and building of trees is not yet a fully automated process in 
  3691.  Festival but the file 'festival/examples/toksearch.scm' shows some basic 
  3692.  Scheme code we use for extracting tokens from very large collections of text. 
  3693.  
  3694.  The function extract_tokens does the real work.  It reads the given file, 
  3695.  token by token into a token stream.  Each token is tested against the desired 
  3696.  tokens and if there is a match the named features are extracted.  The token 
  3697.  stream will be extended to provide the necessary context.  Note that only some 
  3698.  features will make any sense in this situation.  There is only a token 
  3699.  relation so referring to words, syllables etc. is not productive. 
  3700.  
  3701.  In this example databases are identified by a file that lists all the files in 
  3702.  the text databases.  Its name is expected to be 'bin/DBNAME.files' where 
  3703.  DBNAME is the name of the database.  The file should contain a list of 
  3704.  filenames in the database e.g for the Gutenberg texts the file 
  3705.  'bin/Gutenberg.files' contains 
  3706.  
  3707.                       gutenberg/etext90/bill11.txt
  3708.                       gutenberg/etext90/const11.txt
  3709.                       gutenberg/etext90/getty11.txt
  3710.                       gutenberg/etext90/jfk11.txt
  3711.                       ┬╖┬╖┬╖
  3712.  
  3713.  Extracting the tokens is typically done in two passes.  The first pass 
  3714.  extracts the context (I've used 5 tokens either side).  It extracts the file 
  3715.  and position, so the token is identified, and the word in context. 
  3716.  
  3717.  Next those examples should be labelled with a small set of classes which 
  3718.  identify the type of the token.  For example for a token like "Dr" whether it 
  3719.  is a person's title or a street identifier. Note that hand-labelling can be 
  3720.  laborious, though it is surprising how few tokens of particular types actually 
  3721.  exist in 62 million words. 
  3722.  
  3723.  The next task is to extract the tokens with the features that will best 
  3724.  distinguish the particular token.  In our "Dr" case this will involve 
  3725.  punctuation around the token, capitalisation of surrounding tokens etc. After 
  3726.  extracting the distinguishing tokens you must line up the labels with these 
  3727.  extracted features.  It would be easier to extract both the context and the 
  3728.  desired features at the same time but experience shows that in labelling, more 
  3729.  appropriate features come to mind that will distinguish classes better and you 
  3730.  don't want to have to label twice. 
  3731.  
  3732.  Once a set of features consisting of the label and features is created it is 
  3733.  easy to use 'wagon' to create the corresponding decision tree or decision 
  3734.  list.  'wagon' supports both decision trees and decision lists, it may be 
  3735.  worth experimenting to find out which give the best results on some held out 
  3736.  test data.  It appears that decision trees are typically better, but are often 
  3737.  much larger, and the size does not always justify the the sometimes only 
  3738.  slightly better results. 
  3739.  
  3740.  
  3741. ΓòÉΓòÉΓòÉ 17. POS tagging ΓòÉΓòÉΓòÉ
  3742.  
  3743.  Part of speech tagging is a fairly well-defined process.  Festival includes a 
  3744.  part of speech tagger following the HMM-type taggers as found in the Xerox 
  3745.  tagger and others (e.g. DeRose88).  Part of speech tags are assigned, based on 
  3746.  the probability distribution of tags given a word, and from ngrams of tags. 
  3747.  These models are externally specified and a Viterbi decoder is used to assign 
  3748.  part of speech tags at run time. 
  3749.  
  3750.  So far this tagger has only been used for English but there is nothing 
  3751.  language specific about it.  The module POS assigns the tags.  It accesses the 
  3752.  following variables for parameterization. 
  3753.  
  3754.  pos_lex_name The name of a "lexicon" holding reverse probabilities of words 
  3755.            given a tag (indexed by word).  If this is unset or has the value 
  3756.            NIL no part of speech tagging takes place. 
  3757.  
  3758.  pos_ngram_nameThe name of a loaded ngram model of part of speech tags (loaded 
  3759.            by ngram.load). 
  3760.  
  3761.  pos_p_start_tagThe name of the most likely tag before the start of an 
  3762.            utterance. This is typically the tag for sentence final punctuation 
  3763.            marks. 
  3764.  
  3765.  pos_pp_start_tagThe name of the most likely tag two before the start of an 
  3766.            utterance. For English the is typically a simple noun, but for other 
  3767.            languages it might be a verb.  If the ngram model is bigger than 
  3768.            three this tag is effectively repeated for the previous left 
  3769.            contexts. 
  3770.  
  3771.  pos_map   We have found that it is often better to use a rich tagset for 
  3772.            prediction of part of speech tags but that in later use (phrase 
  3773.            breaks and dictionary lookup) a much more constrained tagset is 
  3774.            better.  Thus mapping of the predicted tagset to a different tagset 
  3775.            is supported. pos_map should be a a list of pairs consisting of a 
  3776.            list of tags to be mapped and the new tag they are to be mapped to. 
  3777.  
  3778.  Note is it important to have the part of speech tagger match the tags used in 
  3779.  later parts of the system, particularly the lexicon.  Only two of our lexicons 
  3780.  used so far have (mappable) part of speech labels. 
  3781.  
  3782.  An example of the part of speech tagger for English can be found in 
  3783.  'lib/pos.scm'. 
  3784.  
  3785.  
  3786. ΓòÉΓòÉΓòÉ 18. Phrase breaks ΓòÉΓòÉΓòÉ
  3787.  
  3788.  There are two methods for predicting phrase breaks in Festival, one simple and 
  3789.  one sophisticated.  These two methods are selected through the parameter 
  3790.  Phrase_Method and phrasing is achieved by the module Phrasify. 
  3791.  
  3792.  The first method is by CART tree.  If parameter Phrase_Method is cart_tree, 
  3793.  the CART tree in the variable phrase_cart_tree is applied to each word to see 
  3794.  if a break should be inserted or not. The tree should predict categories BB 
  3795.  (for big break), B (for break) or NB (for no break).  A simple example of a 
  3796.  tree to predict phrase breaks is given in the file 'lib/phrase.scm'. 
  3797.  
  3798.                       (set! simple_phrase_cart_tree
  3799.                       '
  3800.                       ((R:Token.parent.punc in ("?" "." ":"))
  3801.                        ((BB))
  3802.                        ((R:Token.parent.punc in ("'" "\"" "," ";"))
  3803.                         ((B))
  3804.                         ((n.name is 0)
  3805.                         ((BB))
  3806.                         ((NB))))))
  3807.  
  3808.  The second and more elaborate method of phrase break prediction is used when 
  3809.  the parameter Phrase_Method is prob_models.  In this case a probabilistic 
  3810.  model using probabilities of a break after a word based on the part of speech 
  3811.  of the neighbouring words and the previous word.  This is combined with a 
  3812.  ngram model of the distribution of breaks and non-breaks using a Viterbi 
  3813.  decoder to find the optimal phrasing of the utterance.  The results using this 
  3814.  technique are good and even show good results on unseen data from other 
  3815.  researchers' phrase break tests (see black97b).  However sometimes it does 
  3816.  sound wrong, suggesting there is still further work required. 
  3817.  
  3818.  Parameters for this module are set through the feature list held in the 
  3819.  variable phr_break_params, and example of which for English is set in 
  3820.  english_phr_break_params in the file 'lib/phrase.scm'.  The features names and 
  3821.  meaning are 
  3822.  
  3823.  pos_ngram_name The name of a loaded ngram that gives probability distributions 
  3824.            of B/NB given previous, current and next part of speech. 
  3825.  
  3826.  pos_ngram_filenameThe filename containing pos_ngram_name. 
  3827.  
  3828.  break_ngram_nameThe name of a loaded ngram of B/NB distributions.  This is 
  3829.            typically a 6 or 7-gram. 
  3830.  
  3831.  break_ngram_filenameThe filename containing break_ngram_name. 
  3832.  
  3833.  gram_scale_sA weighting factor for breaks in the break/non-break ngram. 
  3834.            Increasing the value insertes more breaks, reducing it causes less 
  3835.            breaks to be inserted. 
  3836.  
  3837.  phrase_type_treeA CART tree that is used to predict type of break given the 
  3838.            predict break position.  This (rather crude) technique is current 
  3839.            used to distinguish major and minor breaks. 
  3840.  
  3841.  break_tagsA list of the break tags (typically (B NB)). 
  3842.  
  3843.  pos_map   A part of speech map used to map the pos feature of words into a 
  3844.            smaller tagset used by the phrase predictor. 
  3845.  
  3846.  
  3847. ΓòÉΓòÉΓòÉ 19. Intonation ΓòÉΓòÉΓòÉ
  3848.  
  3849.  A number of different intonation modules are available with varying levels of 
  3850.  control.  In general intonation is generated in two steps. 
  3851.  
  3852.    1. Prediction of accents (and/or end tones) on a per syllable basis. 
  3853.  
  3854.    2. Prediction of F0 target values, this must be done afterdurations are 
  3855.       predicted. 
  3856.  
  3857.  Reflecting this split there are two main intonation modules that call 
  3858.  sub-modules depending on the desired intonation methods.  The Intonation and 
  3859.  Int_Targets modules are defined in Lisp ('lib/intonation.scm') and call 
  3860.  sub-modules which are (so far) in C++. 
  3861.  
  3862.  Default intonation            Effectively none at all. 
  3863.  Simple intonation             Accents and hats. 
  3864.  Tree intonation               Accents and Tones, and F0 prediction by LR 
  3865.  Tilt intonation               Using the Tilt intonation model 
  3866.  General intonation            A programmable intonation module 
  3867.  Using ToBI                    A ToBI by rule example 
  3868.  
  3869.  
  3870. ΓòÉΓòÉΓòÉ 19.1. Default intonation ΓòÉΓòÉΓòÉ
  3871.  
  3872.  This is the simplest form of intonation and offers the modules 
  3873.  Intonation_Default and Intonation_Targets_Default.  The first of which 
  3874.  actually does nothing at all. Intonation_Targets_Default simply creates a 
  3875.  target at the start of the utterance, and one at the end.  The values of 
  3876.  which, by default are 130 Hz and 110 Hz.  These values may be set through the 
  3877.  parameter duffint_params for example the following will general a monotone at 
  3878.  150Hz. 
  3879.  
  3880.                       (set! duffint_params '((start 150) (end 150)))
  3881.                       (Parameter.set 'Int_Method 'DuffInt)
  3882.                       (Parameter.set 'Int_Target_Method Int_Targets_Default)
  3883.  
  3884.  
  3885. ΓòÉΓòÉΓòÉ 19.2. Simple intonation ΓòÉΓòÉΓòÉ
  3886.  
  3887.  This module uses the CART tree in int_accent_cart_tree to predict if each 
  3888.  syllable is accented or not.  A predicted value of NONE means no accent is 
  3889.  generated by the corresponding Int_Targets_Simple function.  Any other 
  3890.  predicted value will cause a `hat' accent to be put on that syllable. 
  3891.  
  3892.  A default int_accent_cart_tree is available in the value 
  3893.  simple_accent_cart_tree in 'lib/intonation.scm'.  It simply predicts accents 
  3894.  on the stressed syllables on content words in poly-syllabic words, and on the 
  3895.  only syllable in single syllable content words.  Its form is 
  3896.  
  3897.                       (set! simple_accent_cart_tree
  3898.                        '
  3899.                        ((R:SylStructure.parent.gpos is content)
  3900.                         ((stress is 1)
  3901.                         ((Accented))
  3902.                         ((position_type is single)
  3903.                          ((Accented))
  3904.                          ((NONE))))
  3905.                         ((NONE))))
  3906.  
  3907.  The function Int_Targets_Simple uses parameters in the a-list in variable 
  3908.  int_simple_params.  There are two interesting parameters f0_mean which gives 
  3909.  the mean F0 for this speaker (default 110 Hz) and f0_std is the standard 
  3910.  deviation of F0 for this speaker (default 25 Hz).  This second value is used 
  3911.  to determine the amount of variation to be put in the generated targets. 
  3912.  
  3913.  For each Phrase in the given utterance an F0 is generated starting at 
  3914.  f0_code+(f0_std*0.6) and declines f0_std Hz over the length of the phrase 
  3915.  until the last syllable whose end is set to f0_code-f0_std.  An imaginary line 
  3916.  called baseline is drawn from start to the end (minus the final extra fall), 
  3917.  For each syllable that is accented (i.e. has an IntEvent related to it) three 
  3918.  targets are added.  One at the start, one in mid vowel, and one at the end. 
  3919.  The start and end are at position baseline Hz (as declined for that syllable) 
  3920.  and the mid vowel is set to baseline+f0_std. 
  3921.  
  3922.  Note this model is not supposed to be complex or comprehensive but it offers a 
  3923.  very quick and easy way to generate something other than a fixed line F0. 
  3924.  Something similar to this has been for Spanish and Welsh without (too many) 
  3925.  people complaining.  However it is not designed as a serious intonation 
  3926.  module. 
  3927.  
  3928.  
  3929. ΓòÉΓòÉΓòÉ 19.3. Tree intonation ΓòÉΓòÉΓòÉ
  3930.  
  3931.  This module is more flexible.  Two different CART trees can be used to predict 
  3932.  `accents' and `endtones'.  Although at present this module is used for an 
  3933.  implementation of the ToBI intonation labelling system it could be used for 
  3934.  many different types of intonation system. 
  3935.  
  3936.  The target module for this method uses a Linear Regression model to predict 
  3937.  start mid-vowel and end targets for each syllable using arbitrarily specified 
  3938.  features.  This follows the work described in black96.  The LR models are held 
  3939.  as as described below See Linear regression.  Three models are used in the 
  3940.  variables f0_lr_start, f0_lr_mid and f0_lr_end. 
  3941.  
  3942.  
  3943. ΓòÉΓòÉΓòÉ 19.4. Tilt intonation ΓòÉΓòÉΓòÉ
  3944.  
  3945.  Tilt description to be inserted. 
  3946.  
  3947.  
  3948. ΓòÉΓòÉΓòÉ 19.5. General intonation ΓòÉΓòÉΓòÉ
  3949.  
  3950.  As there seems to be a number of intonation theories that predict F0 contours 
  3951.  by rule (possibly using trained parameters) this module aids the external 
  3952.  specification of such rules for a wide class of intonation theories (through 
  3953.  primarily those that might be referred to as the ToBI group).  This is 
  3954.  designed to be multi-lingual and offer a quick way to port often pre-existing 
  3955.  rules into Festival without writing new C++ code. 
  3956.  
  3957.  The accent prediction part uses the same mechanisms as the Simple intonation 
  3958.  method described above, a decision tree for accent prediction, thus the tree 
  3959.  in the variable int_accent_cart_tree is used on each syllable to predict an 
  3960.  IntEvent. 
  3961.  
  3962.  The target part calls a specified Scheme function which returns a list of 
  3963.  target points for a syllable.  In this way any arbitrary tests may be done to 
  3964.  produce the target points.  For example here is a function which returns three 
  3965.  target points for each syllable with an IntEvent related to it (i.e. accented 
  3966.  syllables). 
  3967.  
  3968.                       (define (targ_func1 utt syl)
  3969.                        "(targ_func1 UTT STREAMITEM)
  3970.                       Returns a list of targets for the given syllable."
  3971.                        (let ((start (item.feat syl 'syllable_start))
  3972.                           (end (item.feat syl 'syllable_end)))
  3973.                         (if (equal? (item.feat syl "R:Intonation.daughter1.name") "Accented")
  3974.                           (list
  3975.                            (list start 110)
  3976.                            (list (/ (+ start end) 2.0) 140)
  3977.                            (list end 100)))))
  3978.  This function may be identified as the function to call by the following setup 
  3979.  parameters. 
  3980.  
  3981.                       (Parameter.set 'Int_Method 'General)
  3982.                       (Parameter.set 'Int_Target_Method Int_Targets_General)
  3983.                       (set! int_general_params
  3984.                          (list
  3985.                           (list 'targ_func targ_func1)))
  3986.  
  3987.  
  3988. ΓòÉΓòÉΓòÉ 19.6. Using ToBI ΓòÉΓòÉΓòÉ
  3989.  
  3990.  An example implementation of a ToBI to F0 target module is included in 
  3991.  'lib/tobi_rules.scm' based on the rules described in jilka96. This uses the 
  3992.  general intonation method discussed in the previous section.  This is designed 
  3993.  to be useful to people who are experimenting with ToBI (silverman92), rather 
  3994.  than general text to speech. 
  3995.  
  3996.  To use this method you need to load 'lib/tobi_rules.scm' and call 
  3997.  setup_tobi_f0_method.  The default is in a male's pitch range, i.e. for 
  3998.  voice_rab_diphone.  You can change it for other pitch ranges by changing the 
  3999.  folwoing variables. 
  4000.  
  4001.                       (Parameter.set 'Default_Topline 110)
  4002.                       (Parameter.set 'Default_Start_Baseline 87)
  4003.                       (Parameter.set 'Default_End_Baseline 83)
  4004.                       (Parameter.set 'Current_Topline (Parameter.get 'Default_Topline))
  4005.                       (Parameter.set 'Valley_Dip 75)
  4006.  
  4007.  An example using this from STML is given in 'examples/tobi.stml'. But it can 
  4008.  also be used from Scheme.  For example before defining an utterance you should 
  4009.  execute the following either from teh command line on in some setup file 
  4010.  
  4011.                       (voice_rab_diphone)
  4012.                       (require 'tobi_rules)
  4013.                       (setup_tobi_f0_method)
  4014.  In order to allow specification of accents, tones, and break levels you must 
  4015.  use an utterance type that allows such specification.  For example 
  4016.  
  4017.                       (Utterance
  4018.                        Words
  4019.                        (boy
  4020.                        (saw ((accent H*)))
  4021.                         the
  4022.                         (girl ((accent H*)))
  4023.                         in the
  4024.                         (park ((accent H*) (tone H-)))
  4025.                         with the
  4026.                         (telescope ((accent H*) (tone H-H%)))))
  4027.                       (Utterance Words
  4028.                        (The
  4029.                        (boy ((accent L*)))
  4030.                        saw
  4031.                        the
  4032.                        (girl ((accent H*) (tone L-)))
  4033.                        with
  4034.                        the
  4035.                        (telescope ((accent H*) (tone H-H%))))))
  4036.  You can display the the synthesized form of these utterance in Xwaves.  Start 
  4037.  an Xwaves and an Xlabeller and call the function display on the synthesized 
  4038.  utterance. 
  4039.  
  4040.  
  4041. ΓòÉΓòÉΓòÉ 20. Duration ΓòÉΓòÉΓòÉ
  4042.  
  4043.  A number of different duration prediction modules are available with varying 
  4044.  levels of sophistication. 
  4045.  
  4046.  Segmental duration prediction is done by the module Duration which calls 
  4047.  different actual methods depending on the parameter Duration_Method. 
  4048.  
  4049.  All of the following duration methods may be further affected by both a global 
  4050.  duration stretch and a per word one. 
  4051.  
  4052.  If the parameter Duration_Stretch is set, all absolute durations predicted by 
  4053.  any of the duration methods described here are multiplied by the parameter's 
  4054.  value.  For example 
  4055.  
  4056.                       (Parameter.set 'Duration_Stretch 1.2)
  4057.  will make everything speak more slowly. 
  4058.  
  4059.  In addition to the global stretch method, if the feature dur_stretch on the 
  4060.  related Token is set it will also be used as a multiplicative factor on the 
  4061.  duration produced by the selected method.  That is 
  4062.  R:Syllable.parent.parent.R:Token.parent.dur_stretch. There is a lisp function 
  4063.  duration_find_stretch wchi will return the combined gloabel and local duration 
  4064.  stretch factor for a given segment item. 
  4065.  
  4066.  Note these global and local methods of affecting the duration produced by 
  4067.  models are crude and should be considered hacks.  Uniform modification of 
  4068.  durations is not what happens in real speech.  These parameters are typically 
  4069.  used when the underlying duration method is lacking in some way.  However 
  4070.  these can be useful. 
  4071.  
  4072.  Note it is quite easy to implement new duration methods in Scheme directly. 
  4073.  
  4074.  Default durations             Fixed length durations 
  4075.  Average durations 
  4076.  Klatt durations               Klatt rules from book. 
  4077.  CART durations                Tree based durations 
  4078.  
  4079.  
  4080. ΓòÉΓòÉΓòÉ 20.1. Default durations ΓòÉΓòÉΓòÉ
  4081.  
  4082.  If parameter Duration_Method is set to Default, the simplest duration model is 
  4083.  used.  All segments are 100 milliseconds (this can be modified by 
  4084.  Duration_Stretch, and/or the localised Token related dur_stretch feature). 
  4085.  
  4086.  
  4087. ΓòÉΓòÉΓòÉ 20.2. Average durations ΓòÉΓòÉΓòÉ
  4088.  
  4089.  If parameter Duration_Method is set to Averages then segmental durations are 
  4090.  set to their averages.  The variable phoneme_durations should be an a-list of 
  4091.  phones and averages in seconds.  The file 'lib/mrpa_durs.scm' has an example 
  4092.  for the mrpa phoneset. 
  4093.  
  4094.  If a segment is found that does not appear in the list a default duration of 
  4095.  0.1 seconds is assigned, and a warning message generated. 
  4096.  
  4097.  
  4098. ΓòÉΓòÉΓòÉ 20.3. Klatt durations ΓòÉΓòÉΓòÉ
  4099.  
  4100.  If parameter Duration_Method is set to Klatt the duration rules from the Klatt 
  4101.  book (allen87, chapter 9).  This method requires minimum and inherent 
  4102.  durations for each phoneme in the phoneset.  This information is held in the 
  4103.  variable duration_klatt_params.  Each member of this list is a three-tuple, of 
  4104.  phone name, inherent duration and minimum duration.  An example for the mrpa 
  4105.  phoneset is in 'lib/klatt_durs.scm'. 
  4106.  
  4107.  
  4108. ΓòÉΓòÉΓòÉ 20.4. CART durations ΓòÉΓòÉΓòÉ
  4109.  
  4110.  Two very similar methods of duration prediction by CART tree are supported. 
  4111.  The first, used when parameter Duration_Method is Tree simply predicts 
  4112.  durations directly for each segment. The tree is set in the variable 
  4113.  duration_cart_tree. 
  4114.  
  4115.  The second, which seems to give better results, is used when parameter 
  4116.  Duration_Method is Tree_ZScores. In this second model the tree predicts 
  4117.  zscores (number of standard deviations from the mean) rather than duration 
  4118.  directly.  (This follows campbell91, but we don't deal in syllable durations 
  4119.  here.)  This method requires means and standard deviations for each phone. 
  4120.  The variable duration_cart_tree should contain the zscore prediction tree and 
  4121.  the variable duration_ph_info should contain a list of phone, mean duration, 
  4122.  and standard deviation for each phone in the phoneset. 
  4123.  
  4124.  An example tree trained from 460 sentences spoken by Gordon is in 
  4125.  'lib/gswdurtreeZ'.  Phone means and standard deviations are in 
  4126.  'lib/gsw_durs.scm'. 
  4127.  
  4128.  After prediction the segmental duration is calculated by the simple formula 
  4129.  
  4130.                       duration = mean + (zscore * standard deviation)
  4131.  
  4132.  For some other duration models that affect an inherent duration by some factor 
  4133.  this method has been used.  If the tree predicts factors rather than zscores 
  4134.  and the duration_ph_info entries are phone, 0.0, inherent duration. The above 
  4135.  formula will generate the desired result.  Klatt and Klatt-like rules can be 
  4136.  implemented in the this way without adding a new method. 
  4137.  
  4138.  
  4139. ΓòÉΓòÉΓòÉ 21. UniSyn synthesizer ΓòÉΓòÉΓòÉ
  4140.  
  4141.  Since 1.3 a new general synthesizer module has been included.  This designed 
  4142.  to replace the older diphone synthesizer described in the next chapter.  A 
  4143.  redesign was made in order to have a generalized waveform synthesizer, singla 
  4144.  processing module that could be used even when the units being concatenated 
  4145.  are not diphones.  Also at this stage the full diphone (or other) database 
  4146.  pre-processing functions were added to the Speech Tool library. 
  4147.  
  4148.  
  4149. ΓòÉΓòÉΓòÉ 21.1. UniSyn database format ΓòÉΓòÉΓòÉ
  4150.  
  4151.  The Unisyn synthesis modules can use databases in two basic formats, separate 
  4152.  and grouped.  Separate is when all files (signal, pitchmark and coefficient 
  4153.  files) are accessed individually during synthesis.  This is the standard use 
  4154.  during databse development.  Group format is when a database is collected 
  4155.  together into a single special file containing all information necessary for 
  4156.  waveform synthesis.  This format is designed to be used for distribution and 
  4157.  general use of the database. 
  4158.  
  4159.  A database should consist of a set of waveforms, (which may be translated into 
  4160.  a set of coefficients if the desired the signal processing method requires 
  4161.  it), a set of pitchmarks and an index.  The pitchmarks are necessary as most 
  4162.  of our current signal processing are pitch synchronous. 
  4163.  
  4164.  
  4165. ΓòÉΓòÉΓòÉ 21.1.1. Generating pitchmarks ΓòÉΓòÉΓòÉ
  4166.  
  4167.  Pitchmarks may be derived from laryngograph files using the our proved program 
  4168.  'pitchmark' distributed with the speech tools.  The actual parameters to this 
  4169.  program are still a bit of an art form.  The first major issue is which 
  4170.  direction the lar files.  We have seen both, though it does seem to be CSTR's 
  4171.  ones are most often upside down while others (e.g. OGI's) are the right way 
  4172.  up.  The -inv argument to 'pitchmark' is specifically provided to cater for 
  4173.  this.  There other issues in getting the pitchmarks aligned.  The basic 
  4174.  command for generating pitchmarks is 
  4175.  
  4176.                       pitchmark -inv lar/file001.lar -o pm/file001.pm -otype est \
  4177.                          -min 0.005 -max 0.012 -fill -def 0.01 -wave_end
  4178.  The '-min', '-max' and '-def' (fill values for unvoiced regions), may need to 
  4179.  be changed depending on the speaker pitch range.  The above is suitable for a 
  4180.  male speaker.  The '-fill' option states that unvoiced sections should be 
  4181.  filled with equally spaced pitchmarks. 
  4182.  
  4183.  
  4184. ΓòÉΓòÉΓòÉ 21.1.2. Generating LPC coefficients ΓòÉΓòÉΓòÉ
  4185.  
  4186.  LPC coefficients are generated using the 'sig2fv' command.  Two stages are 
  4187.  required, generating the LPC coefficients and generating the residual.  The 
  4188.  prototypical commands for these are 
  4189.  
  4190.                       sig2fv wav/file001.wav -o lpc/file001.lpc -otype est -lpc_order 16 \
  4191.                         -coefs "lpc" -pm pm/file001.pm -preemph 0.95 -factor 3 \
  4192.                         -window_type hamming
  4193.                       sigfilter wav/file001.wav -o lpc/file001.res -otype nist \
  4194.                         -lpcfilter lpc/file001.lpc -inv_filter
  4195.  For some databases you may need to normalize the power.  Properly normalizing 
  4196.  power is difficult but we provide a simple function which may do the jobs 
  4197.  acceptably.  You should do this on the waveform before lpc analysis (and 
  4198.  ensure you also do the residual extraction on the normalized waveform rather 
  4199.  than the original. 
  4200.  
  4201.                       ch_wave -scaleN 0.5 wav/file001.wav -o file001.Nwav
  4202.  This normalizes the power by maximizing the signal first then multiplying it 
  4203.  by the given factor.  If the database waveforms are clean (i.e. no clicks) 
  4204.  this can give reasonable results. 
  4205.  
  4206.  
  4207. ΓòÉΓòÉΓòÉ 21.2. Generating a diphone index ΓòÉΓòÉΓòÉ
  4208.  
  4209.  The diphone index consists of a short header following by an ascii list of 
  4210.  each diphone, the file it comes from followed by its start middle and end 
  4211.  times in seconds.  For most databases this files needs to be generated by some 
  4212.  database specific script. 
  4213.  
  4214.  An example header is 
  4215.  
  4216.                       EST_File index
  4217.                       DataType ascii
  4218.                       NumEntries 2005
  4219.                       IndexName rab_diphone
  4220.                       EST_Header_End
  4221.  The most notable part is the number of entries, which you should note can get 
  4222.  out of sync with the actual number of entries if you hand edit entries.  I.e. 
  4223.  if you add an entry and the system still can't find it check that the number 
  4224.  of entries is right. 
  4225.  
  4226.  The entries themselves may take on one of two forms, full entries or index 
  4227.  entries.  Full entries consist of a diphone name, where the phones are 
  4228.  separated by "-"; a file name which is used to index into the pitchmark, LPC 
  4229.  and waveform file; and the start, middle (change over point between phones) 
  4230.  and end of the phone in the file in seconds of the diphone.  For example 
  4231.  
  4232.                       r-uh   edx_1001     0.225  0.261  0.320
  4233.                       r-e   edx_1002     0.224  0.273  0.326
  4234.                       r-i   edx_1003     0.240  0.280  0.321
  4235.                       r-o   edx_1004     0.212  0.253  0.320
  4236.  The second form of entry is an index entry which simply states that reference 
  4237.  to that diphone should actually be made to another.  For example 
  4238.  
  4239.                       aa-ll  &aa-l
  4240.  This states that the diphone aa-ll should actually use the diphone aa-l.  Note 
  4241.  they are a number of ways to specify alternates for missing diphones an this 
  4242.  method is best used for fixing single or small classes of missing or broken 
  4243.  diphones.  Index entries may appear anywhere in the file but can't be nested. 
  4244.  
  4245.  Some checks are made one reading this index to ensure times etc are reasonable 
  4246.  but multiple entries for the same diphone are not, in that case the later one 
  4247.  will be selected. 
  4248.  
  4249.  
  4250. ΓòÉΓòÉΓòÉ 21.3. Database declaration ΓòÉΓòÉΓòÉ
  4251.  
  4252.  There two major types of database grouped and ungrouped. Grouped databases 
  4253.  come as a single file containing the diphone index, coeficinets and residuals 
  4254.  for the diphones.  This is the standard way databases are distributed as 
  4255.  voices in Festoval.  Ungrouped access diphones from individual files and is 
  4256.  designed as a method for debugging and testing databases before distribution. 
  4257.  Using ungrouped dataabse is slower but allows quicker changes to the index, 
  4258.  and associated coefficient files and residuals without rebuilding the group 
  4259.  file. 
  4260.  
  4261.  A database is declared to the system through the command us_diphone_init. 
  4262.  This function takes a parameter list of various features used for setting up a 
  4263.  database.  The features are 
  4264.  
  4265.  name      An atomic name for this database, used in selecting it from the 
  4266.            current set of laded database. 
  4267.  
  4268.  index_fileA filename name containing either a diphone index, as descripbed 
  4269.            above, or a group file.  The feature grouped defines the distinction 
  4270.            between this being a group of simple index file. 
  4271.  
  4272.  grouped   Takes the value "true" or "false".  This defined simple index or if 
  4273.            the index file is a grouped file. 
  4274.  
  4275.  coef_dir  The directory containing the coefficients, (LPC or just pitchmarks 
  4276.            in the PSOLA case). 
  4277.  
  4278.  sig_dir   The directory containing the signal files (residual for LPC, full 
  4279.            waveforms for PSOLA). 
  4280.  
  4281.  coef_ext  The extention for coefficient files, typically ".lpc" for LPC file 
  4282.            and ".pm" for pitchmark files. 
  4283.  
  4284.  sig_ext   The extention for signal files, typically ".res" for LPC residual 
  4285.            files and ".wav" for waveform files. 
  4286.  
  4287.  default_diphoneThe diphone to be used when the requested one doesn't exist. 
  4288.            No matter how careful you are you should always include a default 
  4289.            diphone for distributed diphone database.  Synthesis will throw an 
  4290.            error if no diphone is found and there is no default.  Although it 
  4291.            is usually an error when this is required its better to fill in 
  4292.            something than stop synthesizing.  Typical values for this are 
  4293.            silence to silence or schwa to schwa. 
  4294.  
  4295.  alternates_leftA list of pairs showing the alternate phone names for the left 
  4296.            phone in a diphone pair.  This is list is used to rewrite the 
  4297.            diphone name when the directly requested one doesn't exist.  This is 
  4298.            the recommended method for dealing with systematic holes in a 
  4299.            diphone database. 
  4300.  
  4301.  alternates_rightA list of pairs showing the alternate phone names for the 
  4302.            right phone in a diphone pair.  This is list is used to rewrite the 
  4303.            diphone name when the directly requested one doesn't exist.  This is 
  4304.            the recommended method for dealing with systematic holes in a 
  4305.            diphone database. 
  4306.  
  4307.  An example database definition is 
  4308.  
  4309.                       (set! rab_diphone_dir "/projects/festival/lib/voices/english/rab_diphone")
  4310.                       (set! rab_lpc_group
  4311.                          (list
  4312.                           '(name "rab_lpc_group")
  4313.                           (list 'index_file
  4314.                              (path-append rab_diphone_dir "group/rablpc16k.group"))
  4315.                           '(alternates_left ((i ii) (ll l) (u uu) (i@ ii) (uh @) (a aa)
  4316.                                        (u@ uu) (w @) (o oo) (e@ ei) (e ei)
  4317.                                        (r @)))
  4318.                           '(alternates_right ((i ii) (ll l) (u uu) (i@ ii)
  4319.                                        (y i) (uh @) (r @) (w @)))
  4320.                           '(default_diphone @-@@)
  4321.                           '(grouped "true")))
  4322.                       (us_dipohone_init rab_lpc_group)
  4323.  
  4324.  
  4325. ΓòÉΓòÉΓòÉ 21.4. Making groupfiles ΓòÉΓòÉΓòÉ
  4326.  
  4327.  The function us_make_group_file will make a group file of the currently 
  4328.  selected US diphone database.  It loads in all diphone sin the dtabaase and 
  4329.  saves them in the named file.  An optional second argument allows 
  4330.  specification of how the group file will be saved.  These options are as a 
  4331.  feature list.  There are three possible options 
  4332.  
  4333.  track_file_format The format for the coefficient files.  By default this is 
  4334.            est_binary, currently the only other alternative is est_ascii. 
  4335.  
  4336.  sig_file_formatThe format for the signal parts of the of the database.  By 
  4337.            default this is snd (Sun's Audio format).  This was choosen as it 
  4338.            has the smallest header and supports various sample formats.  Any 
  4339.            format supported by the Edinburgh Speech Tools is allowed. 
  4340.  
  4341.  sig_sample_formatThe format for the samples in the signal files.  By default 
  4342.            this is mulaw.  This is suitable when the signal files are LPC 
  4343.            residuals.  LPC residuals have a much smaller dynamic range that 
  4344.            plain PCM files.  Because mulaw representation is half the size (8 
  4345.            bits) of standard PCM files (16bits) this significantly reduces the 
  4346.            size of the group file while only marginally altering the quality of 
  4347.            synthesis (and from experiments the effect is not perceptible). 
  4348.            However when saving group files where the signals are not LPC 
  4349.            residuals (e.g. in PSOLA) using this default mulaw is not 
  4350.            recommended and short should probably be used. 
  4351.  
  4352.  
  4353. ΓòÉΓòÉΓòÉ 21.5. UniSyn module selection ΓòÉΓòÉΓòÉ
  4354.  
  4355.  In a voice selection a UniSyn database may be selected as follows 
  4356.  
  4357.                        (set! UniSyn_module_hooks (list rab_diphone_const_clusters ))
  4358.                        (set! us_abs_offset 0.0)
  4359.                        (set! window_factor 1.0)
  4360.                        (set! us_rel_offset 0.0)
  4361.                        (set! us_gain 0.9)
  4362.                        (Parameter.set 'Synth_Method 'UniSyn)
  4363.                        (Parameter.set 'us_sigpr 'lpc)
  4364.                        (us_db_select rab_db_name)
  4365.  The UniSyn_module_hooks are run before synthesis, see the next selection about 
  4366.  diphone name selection.  At present only lpc is supported by the UniSyn 
  4367.  module, though potentially there may be others. 
  4368.  
  4369.  An optional implementation of TD-PSOLA moulines90 has been written but fear of 
  4370.  legal problems unfortunately prevents it being in the public distribution, but 
  4371.  this policy should not be taken as acknowledging or not acknowledging any 
  4372.  alleged patent violation. 
  4373.  
  4374.  
  4375. ΓòÉΓòÉΓòÉ 21.6. Diphone selection ΓòÉΓòÉΓòÉ
  4376.  
  4377.  Diphone names are constructed for each phone-phone pair in the Segment 
  4378.  relation in an utterance.  If a segment has the feature in forming a diphone 
  4379.  name UniSyn first checks for the feature us_diphone_left (or us_diphone_right 
  4380.  for the right hand part of the diphone) then if that doesn't exist the feature 
  4381.  us_diphone then if that doesn't exist the feature name.  Thus is is possible 
  4382.  to specify diphone names which are not simply the concatenation of two segment 
  4383.  names. 
  4384.  
  4385.  This feature is used to specify consonant cluster diphone names for our 
  4386.  English voices.  The hook UniSyn_module_hooks is run before selection and we 
  4387.  specify a function to add us_diphone_* features as appropriate.  See the 
  4388.  function rab_diphone_fix_phone_name in 
  4389.  'lib/voices/english/rab_diphone/festvox/rab_diphone.scm' for an example. 
  4390.  
  4391.  Once the diphone name is created it is used to select the diphone from the 
  4392.  database.  If it is not found the name is converted using the list of 
  4393.  alternates_left and alternates_right as specified in the database declaration. 
  4394.  If that doesn't specify a diphone in the database.  The default_diphone is 
  4395.  selected, and a warning is printed.  If no default diphone is specified or the 
  4396.  default diphone doesn't exist in the database an error is thrown. 
  4397.  
  4398.  
  4399. ΓòÉΓòÉΓòÉ 22. Diphone synthesizer ΓòÉΓòÉΓòÉ
  4400.  
  4401.  NOTE: use of this diphone synthesis is depricated and it will probably be 
  4402.  removed from future versions, all of its functionality has been replaced by 
  4403.  the UniSyn synthesizer.  It is not compiled by default, if required add 
  4404.  ALSO_INCLUDE += diphone to your 'festival/config/config' file. 
  4405.  
  4406.  A basic diphone synthesizer offers a method for making speech from segments, 
  4407.  durations and intonation targets.  This module was mostly written by Alistair 
  4408.  Conkie but the base diphone format is compatible with previous CSTR diphone 
  4409.  synthesizers. 
  4410.  
  4411.  The synthesizer offers residual excited LPC based synthesis (hunt89) and PSOLA 
  4412.  (TM) (moulines90) (PSOLA is not available for distribution). 
  4413.  
  4414.  Diphone database format       Format of basic dbs 
  4415.  LPC databases                 Building and using LPC files. 
  4416.  Group files                   Efficient binary formats 
  4417.  Diphone_Init                  Loading diphone databases 
  4418.  Access strategies             Various access methods 
  4419.  Diphone selection             Mapping phones to special diphone names 
  4420.  
  4421.  
  4422. ΓòÉΓòÉΓòÉ 22.1. Diphone database format ΓòÉΓòÉΓòÉ
  4423.  
  4424.  A diphone database consists of a dictionary file, a set of waveform files, and 
  4425.  a set of pitch mark files.  These files are the same format as the previous 
  4426.  CSTR (Osprey) synthesizer. 
  4427.  
  4428.  The dictionary file consist of one entry per line.  Each entry consists of 
  4429.  five fields: a diphone name of the form P1-P2, a filename (without extension), 
  4430.  a floating point start position in the file in milliseconds, a mid position in 
  4431.  milliseconds (change in phone), and an end position in milliseconds.  Lines 
  4432.  starting with a semi-colon and blank lines are ignored.  The list may be in 
  4433.  any order. 
  4434.  
  4435.  For example a partial list of phones may look like. 
  4436.  
  4437.                       ch-l  r021  412.035  463.009  518.23
  4438.                       jh-l  d747  305.841  382.301  446.018
  4439.                       h-l  d748  356.814  403.54  437.522
  4440.                       #-@  d404  233.628  297.345  331.327
  4441.                       @-#  d001  836.814  938.761  1002.48
  4442.  
  4443.  Waveform files may be in any form, as long as every file is the same type, 
  4444.  headered or unheadered as long as the format is supported the speech tools 
  4445.  wave reading functions.  These may be standard linear PCM waveform files in 
  4446.  the case of PSOLA or LPC coefficients and residual when using the residual LPC 
  4447.  synthesizer. LPC databases 
  4448.  
  4449.  Pitch mark files consist a simple list of positions in milliseconds (plus 
  4450.  places after the point) in order, one per line of each pitch mark in the file. 
  4451.  For high quality diphone synthesis these should be derived from laryngograph 
  4452.  data.  During unvoiced sections pitch marks should be artificially created at 
  4453.  reasonable intervals (e.g. 10 ms).  In the current format there is no way to 
  4454.  determine the "real" pitch marks from the "unvoiced" pitch marks. 
  4455.  
  4456.  It is normal to hold a diphone database in a directory with a number of 
  4457.  sub-directories namely 'dic/' contain the dictionary file, 'wave/' for the 
  4458.  waveform files, typically of whole nonsense words (sometimes this directory is 
  4459.  called 'vox/' for historical reasons) and 'pm/' for the pitch mark files.  The 
  4460.  filename in the dictionary entry should be the same for waveform file and the 
  4461.  pitch mark file (with different extensions). 
  4462.  
  4463.  
  4464. ΓòÉΓòÉΓòÉ 22.2. LPC databases ΓòÉΓòÉΓòÉ
  4465.  
  4466.  The standard method for diphone resynthesis in the released system is residual 
  4467.  excited LPC (hunt89).  The actual method of resynthesis isn't important to the 
  4468.  database format, but if residual LPC synthesis is to be used then it is 
  4469.  necessary to make the LPC coefficient files and their corresponding residuals. 
  4470.  
  4471.  Previous versions of the system used a "host of hacky little scripts" to this 
  4472.  but now that the Edinburgh Speech Tools supports LPC analysis we can provide a 
  4473.  walk through for generating these. 
  4474.  
  4475.  We assume that the waveform file of nonsense words are in a directory called 
  4476.  'wave/'.  The LPC coefficients and residuals will be, in this example, stored 
  4477.  in 'lpc16k/' with extensions '.lpc' and '.res' respectively. 
  4478.  
  4479.  Before starting it is worth considering power normalization.  We have found 
  4480.  this important on all of the databases we have collected so far. The ch_wave 
  4481.  program, part of the speech tools, with the optional -scaleN 0.4 may be used 
  4482.  if a more complex method is not available. 
  4483.  
  4484.  The following shell command generates the files 
  4485.  
  4486.                       for i in wave/*.wav
  4487.                       do
  4488.                         fname=`basename $i .wav`
  4489.                         echo $i
  4490.                         lpc_analysis -reflection -shift 0.01 -order 18 -o lpc16k/$fname.lpc \
  4491.                           -r lpc16k/$fname.res -otype htk -rtype nist $i
  4492.                       done
  4493.  It is said that the LPC order should be sample rate divided by one thousand 
  4494.  plus 2.  This may or may not be appropriate and if you are particularly 
  4495.  worried about the database size it is worth experimenting. 
  4496.  
  4497.  The program 'lpc_analysis', found in 'speech_tools/bin', can be used to 
  4498.  generate the lpc coefficients and residual.  Note these should be reflection 
  4499.  coefficients so they may be quantised (as they are in group files). 
  4500.  
  4501.  The coefficients and residual files produced by different LPC analysis 
  4502.  programs may start at different offsets.  For example the Entropic's ESPS 
  4503.  functions generate LPC coefficients that are offset by one frame shift (e.g. 
  4504.  0.01 seconds).  Our own 'lpc_analysis' routine has no offset. The Diphone_Init 
  4505.  parameter list allows these offsets to be specified.  Using the above function 
  4506.  to generate the LPC files the description parameters should include 
  4507.  
  4508.                        (lpc_frame_offset 0)
  4509.                        (lpc_res_offset 0.0)
  4510.  While when generating using ESPS routines the description should be 
  4511.  
  4512.                        (lpc_frame_offset 1)
  4513.                        (lpc_res_offset 0.01)
  4514.  The defaults actually follow the ESPS form, that is lpc_frame_offset is 1 and 
  4515.  lpc_res_offset is equal to the frame shift, if they are not explicitly 
  4516.  mentioned. 
  4517.  
  4518.  Note the biggest problem we have in implementing the residual excited LPC 
  4519.  resynthesizer was getting the right part of the residual to line up with the 
  4520.  right LPC coefficients describing the pitch mark.  Making errors in this 
  4521.  degrades the synthesized waveform notably, but not seriously, making it 
  4522.  difficult to determine if it is an offset problem or some other bug. 
  4523.  
  4524.  Although we have started investigating if extracting pitch synchronous LPC 
  4525.  parameters rather than fixed shift parameters gives better performance, we 
  4526.  haven't finished this work.  'lpc_analysis' supports pitch synchronous 
  4527.  analysis but the raw "ungrouped" access method does not yet.  At present the 
  4528.  LPC parameters are extracted at a particular pitch mark by interpolating over 
  4529.  the closest LPC parameters.  The "group" files hold these interpolated 
  4530.  parameters pitch synchronously. 
  4531.  
  4532.  The American English voice 'kd' was created using the speech tools 
  4533.  'lpc_analysis' program and its set up should be looked at if you are going to 
  4534.  copy it.  The British English voice 'rb' was constructed using ESPS routines. 
  4535.  
  4536.  
  4537. ΓòÉΓòÉΓòÉ 22.3. Group files ΓòÉΓòÉΓòÉ
  4538.  
  4539.  Databases may be accessed directly but this is usually too inefficient for any 
  4540.  purpose except debugging.  It is expected that group files will be built which 
  4541.  contain a binary representation of the database.  A group file is a compact 
  4542.  efficient representation of the diphone database.  Group files are byte order 
  4543.  independent, so may be shared between machines of different byte orders and 
  4544.  word sizes. Certain information in a group file may be changed at load time so 
  4545.  a database name, access strategy etc. may be changed from what was set 
  4546.  originally in the group file. 
  4547.  
  4548.  A group file contains the basic parameters, the diphone index, the signal 
  4549.  (original waveform or LPC residual), LPC coefficients, and the pitch marks. 
  4550.  It is all you need for a run-time synthesizer. Various compression mechanisms 
  4551.  are supported to allow smaller databases if desired.  A full English LPC plus 
  4552.  residual database at 8k ulaw is about 3 megabytes, while a full 16 bit version 
  4553.  at 16k is about 8 megabytes. 
  4554.  
  4555.  Group files are created with the Diphone.group command which takes a database 
  4556.  name and an output filename as an argument.  Making group files can take some 
  4557.  time especially if they are large.  The group_type parameter specifies raw or 
  4558.  ulaw for encoding signal files.  This can significantly reduce the size of 
  4559.  databases. 
  4560.  
  4561.  Group files may be partially loaded (see access strategies) at run time for 
  4562.  quicker start up and to minimise run-time memory requirements. 
  4563.  
  4564.  
  4565. ΓòÉΓòÉΓòÉ 22.4. Diphone_Init ΓòÉΓòÉΓòÉ
  4566.  
  4567.  The basic method for describing a database is through the Diphone_Init 
  4568.  command.  This function takes a single argument, a list of pairs of parameter 
  4569.  name and value.  The parameters are 
  4570.  
  4571.  name      An atomic name for this database. 
  4572.  
  4573.  group_fileThe filename of a group file, which may itself contain parameters 
  4574.            describing itself 
  4575.  
  4576.  type      The default value is pcm, but for distributed voices this is always 
  4577.            lpc. 
  4578.  
  4579.  index_fileA filename containing the diphone dictionary. 
  4580.  
  4581.  signal_dirA directory (slash terminated) containing the pcm waveform files. 
  4582.  
  4583.  signal_extA dot prefixed extension for the pcm waveform files. 
  4584.  
  4585.  pitch_dir A directory (slash terminated) containing the pitch mark files. 
  4586.  
  4587.  pitch_ext A dot prefixed extension for the pitch files 
  4588.  
  4589.  lpc_dir   A directory (slash terminated) containing the LPC coefficient files 
  4590.            and residual files. 
  4591.  
  4592.  lpc_ext   A dot prefixed extension for the LPC coefficient files 
  4593.  
  4594.  lpc_type  The type of LPC file (as supported by the speech tools) 
  4595.  
  4596.  lpc_frame_offsetThe number of frames "missing" from the beginning of the file. 
  4597.            Often LPC parameters are offset by one frame. 
  4598.  
  4599.  lpc_res_extA dot prefixed extension for the residual files 
  4600.  
  4601.  lpc_res_typeThe type of the residual files, this is a standard waveform type 
  4602.            as supported by the speech tools. 
  4603.  
  4604.  lpc_res_offsetNumber of seconds "missing" from the beginning of the residual 
  4605.            file. Some LPC analysis technique do not generate a residual until 
  4606.            after one frame. 
  4607.  
  4608.  samp_freq Sample frequency of signal files 
  4609.  
  4610.  phoneset  Phoneset used, must already be declared. 
  4611.  
  4612.  num_diphonesTotal number of diphones in database.  If specified this must be 
  4613.            equal or bigger than the number of entries in the index file. If it 
  4614.            is not specified the square of the number of phones in the phoneset 
  4615.            is used. 
  4616.  
  4617.  sig_band  number of sample points around actual diphone to take from file. 
  4618.            This should be larger than any windowing used on the signal, and/or 
  4619.            up to the pitch marks outside the diphone signal. 
  4620.  
  4621.  alternates_afterList of pairs of phones stating replacements for the second 
  4622.            part of diphone when the basic diphone is not found in the diphone 
  4623.            database. 
  4624.  
  4625.  alternates_beforeList of pairs of phones stating replacements for the first 
  4626.            part of diphone when the basic diphone is not found in the diphone 
  4627.            database. 
  4628.  
  4629.  default_diphoneWhen unexpected combinations occur and no appropriate diphone 
  4630.            can be found this diphone should be used.  This should be specified 
  4631.            for all diphone databases that are to be robust.  We usually us the 
  4632.            silence to silence diphone.  No mater how carefully you designed 
  4633.            your diphone set, conditions when an unknown diphone occur seem to 
  4634.            always happen. If this is not set and a diphone is requested that is 
  4635.            not in the database an error occurs and synthesis will stop. 
  4636.  
  4637.  Examples of both general set up, making group files and general use are in 
  4638.  
  4639.                       'lib/voices/english/rab_diphone/festvox/rab_diphone.scm'
  4640.  
  4641.  
  4642. ΓòÉΓòÉΓòÉ 22.5. Access strategies ΓòÉΓòÉΓòÉ
  4643.  
  4644.  Three basic accessing strategies are available when using diphone databases. 
  4645.  They are designed to optimise access time, start up time and space 
  4646.  requirements. 
  4647.  
  4648.  direct     Load all signals at database init time. This is the slowest startup 
  4649.            but the fastest to access.  This is ideal for servers.  It is also 
  4650.            useful for small databases that can be loaded quickly.  It is 
  4651.            reasonable for many group files. 
  4652.  
  4653.  dynamic   Load signals as they are required.  This has much faster start up 
  4654.            and will only gradually use up memory as the diphones are actually 
  4655.            used.  Useful for larger databases, and for non-group file access. 
  4656.  
  4657.  ondemand  Load the signals as they are requested but free them if they are not 
  4658.            required again immediately.  This is slower access but requires low 
  4659.            memory usage.  In group files the re-reads are quite cheap as the 
  4660.            database is well cached and a file description is already open for 
  4661.            the file. 
  4662.  Note that in group files pitch marks (and LPC coefficients) are always fully 
  4663.  loaded (cf. direct), as they are typically smaller.  Only signals (waveform 
  4664.  files or residuals) are potentially dynamically loaded. 
  4665.  
  4666.  
  4667. ΓòÉΓòÉΓòÉ 22.6. Diphone selection ΓòÉΓòÉΓòÉ
  4668.  
  4669.  The appropriate diphone is selected based on the name of the phone identified 
  4670.  in the segment stream.  However for better diphone synthesis it is useful to 
  4671.  augment the diphone database with other diphones in addition to the ones 
  4672.  directly from the phoneme set.  For example dark and light l's, distinguishing 
  4673.  consonants from their consonant cluster form and their isolated form.  There 
  4674.  are however two methods to identify this modification from the basic name. 
  4675.  
  4676.  When the diphone module is called the hook diphone_module_hooks is applied. 
  4677.  That is a function of list of functions which will be applied to the 
  4678.  utterance.  Its main purpose is to allow the conversion of the basic name into 
  4679.  an augmented one.  For example converting a basic l into a dark l, denoted by 
  4680.  ll.  The functions given in diphone_module_hooks may set the feature 
  4681.  diphone_phone_name which if set will be used rather than the name of the 
  4682.  segment. 
  4683.  
  4684.  For example suppose we wish to use a dark l (ll) rather than a normal l for 
  4685.  all l's that appear in the coda of a syllable. First we would define a 
  4686.  function to which identifies this condition and adds the addition feature 
  4687.  diphone_phone_name identify the name change.  The following function would 
  4688.  achieve this 
  4689.  
  4690.                       (define (fix_dark_ls utt)
  4691.                       "(fix_dark_ls UTT)
  4692.                       Identify ls in coda position and relabel them as ll."
  4693.                        (mapcar
  4694.                         (lambda (seg)
  4695.                          (if (and (string-equal "l" (item.name seg))
  4696.                              (string-equal "+" (item.feat seg "p.ph_vc"))
  4697.                              (item.relation.prev seg "SylStructure"))
  4698.                          (item.set_feat seg "diphone_phone_name" "ll")))
  4699.                         (utt.relation.items utt 'Segment))
  4700.                        utt)
  4701.  Then when we wish to use this for a particular voice we need to add 
  4702.  
  4703.                       (set! diphone_module_hooks (list fix_dark_ls))
  4704.  in the voice selection function. 
  4705.  
  4706.  For a more complex example including consonant cluster identification see the 
  4707.  American English voice 'ked' in 
  4708.  'festival/lib/voices/english/ked/festvox/kd_diphone.scm'.  The function 
  4709.  ked_diphone_fix_phone_name carries out a number of mappings. 
  4710.  
  4711.  The second method for changing a name is during actual look up of a diphone in 
  4712.  the database.  The list of alternates is given by the Diphone_Init function. 
  4713.  These are used when the specified diphone can't be found.  For example we 
  4714.  often allow mappings of dark l, ll to l as sometimes the dark l diphone 
  4715.  doesn't actually exist in the database. 
  4716.  
  4717.  
  4718. ΓòÉΓòÉΓòÉ 23. Other synthesis methods ΓòÉΓòÉΓòÉ
  4719.  
  4720.  Festival supports a number of other synthesis systems 
  4721.  
  4722.  LPC diphone synthesizer       A small LPC synthesizer (Donovan diphones) 
  4723.  MBROLA                        Interface to MBROLA 
  4724.  Synthesizers in development 
  4725.  
  4726.  
  4727. ΓòÉΓòÉΓòÉ 23.1. LPC diphone synthesizer ΓòÉΓòÉΓòÉ
  4728.  
  4729.  A very simple, and very efficient LPC diphone synthesizer using the "donovan" 
  4730.  diphones is also supported.  This synthesis method is primarily the work of 
  4731.  Steve Isard and later Alistair Conkie. The synthesis quality is not as good as 
  4732.  the residual excited LPC diphone synthesizer but has the advantage of being 
  4733.  much smaller. The donovan diphone database is under 800k. 
  4734.  
  4735.  The diphones are loaded through the Donovan_Init function which takes the name 
  4736.  of the dictionary file and the diphone file as arguments, see the following 
  4737.  for details 
  4738.  
  4739.                       lib/voices/english/don_diphone/festvox/don_diphone.scm
  4740.  
  4741.  
  4742. ΓòÉΓòÉΓòÉ 23.2. MBROLA ΓòÉΓòÉΓòÉ
  4743.  
  4744.  As an example of how Festival may use a completely external synthesis method 
  4745.  we support the free system MBROLA.  MBROLA is both a diphone synthesis 
  4746.  technique and an actual system that constructs waveforms from segment, 
  4747.  duration and F0 target information.  For details see the MBROLA home page at 
  4748.  http://tcts.fpms.ac.be/synthesis/mbrola.html.  MBROLA already supports a 
  4749.  number of diphone sets including French, Spanish, German and Romanian. 
  4750.  
  4751.  Festival support for MBROLA is in the file 'lib/mbrola.scm'. It is all in 
  4752.  Scheme.  The function MBROLA_Synth is called when parameter Synth_Method is 
  4753.  MBROLA.  The function simply saves the segment, duration and target 
  4754.  information from the utterance, calls the external 'mbrola' program with the 
  4755.  selected diphone database, and reloads the generated waveform back into the 
  4756.  utterance. 
  4757.  
  4758.  An MBROLA-ized version of the Roger diphoneset is available from the MBROLA 
  4759.  site.  The simple Festival end is distributed as part of the system in 
  4760.  'festvox_en1.tar.gz'. The following variables are used by the process 
  4761.  
  4762.  mbrola_progname the pathname of the mbrola executable. 
  4763.  
  4764.  mbrola_databasethe name of the database to use.  This variable is switched 
  4765.            between different speakers. 
  4766.  
  4767.  
  4768. ΓòÉΓòÉΓòÉ 23.3. Synthesizers in development ΓòÉΓòÉΓòÉ
  4769.  
  4770.  In addition to the above synthesizers Festival also supports CSTR's older 
  4771.  PSOLA synthesizer written by Paul Taylor. But as the newer diphone synthesizer 
  4772.  produces similar quality output and is a newer (and hence a cleaner) 
  4773.  implementation further development of the older module is unlikely. 
  4774.  
  4775.  An experimental unit seleciton synthesis module is included in 
  4776.  'modules/clunits/' it is an implementation of black97c.  It is included for 
  4777.  people wishing to continue reserach in the area rather than as a fully usable 
  4778.  waveform synthesis engine.  Although it sometimes gives excellent results it 
  4779.  also sometimes gives amazingly bad ones too. We included this as an example of 
  4780.  one possible framework for selection-based synthesis. 
  4781.  
  4782.  As one of our funded projects is to specifically develop new selection based 
  4783.  synthesis algorithms we expect to include more models within later versions of 
  4784.  the system. 
  4785.  
  4786.  Also, now that Festival has been released other groups are working on new 
  4787.  synthesis techniques in the system.  Many of these will become available and 
  4788.  where possible we will give pointers from the Festival home page to them. 
  4789.  Particularly there is an alternative residual excited LPC module implemented 
  4790.  at the Center for Spoken Language Understanding (CSLU) at the Oregon Graduate 
  4791.  Institute (OGI). 
  4792.  
  4793.  
  4794. ΓòÉΓòÉΓòÉ 24. Audio output ΓòÉΓòÉΓòÉ
  4795.  
  4796.  If you have never heard any audio ever on your machine then you must first 
  4797.  work out if you have the appropriate hardware.  If you do, you also need the 
  4798.  appropriate software to drive it.  Festival can directly interface with a 
  4799.  number of audio systems or use external methods for playing audio. 
  4800.  
  4801.  The currently supported audio methods are 
  4802.  
  4803.  'NAS'     NCD's NAS, is a network transparent audio system (formerly called 
  4804.            netaudio).  If you already run servers on your machines you simply 
  4805.            need to ensure your AUDIOSERVER environment variable is set (or your 
  4806.            DISPLAY variable if your audio output device is the same as your X 
  4807.            Windows display). You may set NAS as your audio output method by the 
  4808.            command 
  4809.  
  4810.                       (Parameter.set 'Audio_Method 'netaudio)
  4811.  
  4812.  '/dev/audio'On many systems '/dev/audio' offers a simple low level method for 
  4813.            audio output.  It is limited to mu-law encoding at 8KHz.  Some 
  4814.            implementations of '/dev/audio' allow other sample rates and sample 
  4815.            types but as that is non-standard this method only uses the common 
  4816.            format.  Typical systems that offer these are Suns, Linux and 
  4817.            FreeBSD machines.  You may set direct '/dev/audio' access as your 
  4818.            audio method by the command 
  4819.  
  4820.                       (Parameter.set 'Audio_Method 'sunaudio)
  4821.  
  4822.  '/dev/audio (16bit)'Later Sun Microsystems workstations support 16 bit linear 
  4823.            audio at various sample rates.  Support for this form of audio 
  4824.            output is supported.  It is a compile time option (as it requires 
  4825.            include files that only exist on Sun machines.  If your installation 
  4826.            supports it (check the members of the list *modules*) you can select 
  4827.            16 bit audio output on Suns by the command 
  4828.  
  4829.                       (Parameter.set 'Audio_Method 'sun16audio)
  4830.  Note this will send it to the local machine where the festival binary is 
  4831.  running, this might not be the one you are sitting next to---that's why we 
  4832.  recommend netaudio.  A hacky solution to playing audio on a local machine from 
  4833.  a remote machine without using netaudio is described in Installation 
  4834.  
  4835.  '/dev/dsp (voxware)'Both FreeBSD and Linux have a very similar audio interface 
  4836.            through '/dev/dsp'.  There is compile time support for these in the 
  4837.            speech tools and when compiled with that option Festival may utilise 
  4838.            it. Check the value of the variable *modules* to see which audio 
  4839.            devices are directly supported.  On FreeBSD, if supported, you may 
  4840.            select local 16 bit linear audio by the command 
  4841.  
  4842.                       (Parameter.set 'Audio_Method 'freebsd16audio)
  4843.  While under Linux, if supported, you may use the command 
  4844.  
  4845.                       (Parameter.set 'Audio_Method 'linux16audio)
  4846.  Some earlier (and smaller machines) only have 8bit audio even though they 
  4847.  include a '/dev/dsp' (Soundblaster PRO for example).  This was not dealt with 
  4848.  properly in earlier versions of the system but now the support automatically 
  4849.  checks to see the sample width supported and uses it accordingly.  8 bit at 
  4850.  higher frequencies that 8K sounds better than straight 8k ulaw so this feature 
  4851.  is useful. 
  4852.  
  4853.  'mplayer' Under Windows NT or 95 you can use the 'mplayer' command which we 
  4854.            have found requires special treatement to get its parameters right. 
  4855.            Rather than using Audio_Command you can select this on Windows 
  4856.            machine with the following command 
  4857.  
  4858.                       (Parameter.set 'Audio_Method 'mplayeraudio)
  4859.  Alternatively built-in audio output is available with 
  4860.  
  4861.                       (Parameter.set 'Audio_Method 'win32audio)
  4862.  
  4863.  'SGI IRIX'Builtin audio output is now available for SGI's IRIX 6.2 using the 
  4864.            command 
  4865.  
  4866.                       (Parameter.set 'Audio_Method 'irixaudio)
  4867.  
  4868.  'Audio Command'Alternatively the user can provide a command that can play an 
  4869.            audio file.  Festival will execute that command in an environment 
  4870.            where the shell variables SR is set to the sample rate (in Hz) and 
  4871.            FILE which, by default, is the name of an unheadered raw, 16bit file 
  4872.            containing the synthesized waveform in the byte order of the machine 
  4873.            Festival is running on.  You can specify your audio play command and 
  4874.            that you wish Festival to execute that command through the following 
  4875.            command 
  4876.  
  4877.                       (Parameter.set 'Audio_Command "sun16play -f $SR $FILE")
  4878.                       (Parameter.set 'Audio_Method 'Audio_Command)
  4879.  On SGI machines under IRIX the equivalent would be 
  4880.  
  4881.                       (Parameter.set 'Audio_Command
  4882.                             "sfplay -i integer 16 2scomp rate $SR end $FILE")
  4883.                       (Parameter.set 'Audio_Method 'Audio_Command)
  4884.  
  4885.  The Audio_Command method of playing waveforms Festival supports two additional 
  4886.  audio parameters. Audio_Required_Rate allows you to use Festival's internal 
  4887.  sample rate conversion function to any desired rate.  Note this may not be as 
  4888.  good as playing the waveform at the sample rate it is originally created in, 
  4889.  but as some hardware devices are restrictive in what sample rates they 
  4890.  support, or have naive resample functions this could be optimal.  The second 
  4891.  additional audio parameter is Audio_Required_Format which can be used to 
  4892.  specify the desired output forms of the file.  The default is unheadered raw, 
  4893.  but this may be any of the values supported by the speech tools (including 
  4894.  nist, esps, snd, riff, aiff, audlab, raw and, if you really want it, ascii). 
  4895.  For example suppose you have a program that only plays sun headered files at 
  4896.  16000 KHz you can set up audio output as 
  4897.  
  4898.                       (Parameter.set 'Audio_Method 'Audio_Command)
  4899.                       (Parameter.set 'Audio_Required_Rate 16000)
  4900.                       (Parameter.set 'Audio_Required_Format 'snd)
  4901.                       (Parameter.set 'Audio_Command "sunplay $FILE")
  4902.  
  4903.  If Netaudio is not available and you need to play audio on a machine different 
  4904.  from teh one Festival is running on we have had reports that 'snack' 
  4905.  (http://www.speech.kth.se/snack/) is a possible solution.  It allows remote 
  4906.  play but importnatly also supports Windows 95/NT based clients. 
  4907.  
  4908.  Because you do not want to wait for a whole file to be synthesized before you 
  4909.  can play it, Festival also offers an audio spooler that allows the playing of 
  4910.  audio files while continuing to synthesize the following utterances.  On 
  4911.  reasonable workstations this allows the breaks between utterances to be as 
  4912.  short as your hardware allows them to be. 
  4913.  
  4914.  The audio spooler may be started by selecting asynchronous mode 
  4915.  
  4916.                       (audio_mode async)
  4917.  This is switched on by default be the function tts. You may put Festival back 
  4918.  into synchronous mode (i.e. the utt.play command will wait until the audio has 
  4919.  finished playing before returning). by the command 
  4920.  
  4921.                       (audio_mode sync)
  4922.  Additional related commands are 
  4923.  
  4924.  (audio_mode ' close) Close the audio server down but wait until it is cleared. 
  4925.            This is useful in scripts etc. when you wish to only exit when all 
  4926.            audio is complete. 
  4927.  
  4928.  (audio_mode 'shutup)Close the audio down now, stopping the current file being 
  4929.            played and any in the queue.  Note that this may take some time to 
  4930.            take effect depending on which audio method you use.  Sometimes 
  4931.            there can be 100s of milliseconds of audio in the device itself 
  4932.            which cannot be stopped. 
  4933.  
  4934.  (audio_mode 'query)Lists the size of each waveform currently in the queue. 
  4935.  
  4936.  
  4937. ΓòÉΓòÉΓòÉ 25. Voices ΓòÉΓòÉΓòÉ
  4938.  
  4939.  This chapter gives some general suggestions about adding new voices to 
  4940.  Festival.  Festival attempts to offer an environment where new voices and 
  4941.  languages can easily be slotted in to the system. 
  4942.  
  4943.  Current voices                Currently available voices 
  4944.  Building a new voice          Building a new voice 
  4945.  Defining a new voice          Defining a new voice 
  4946.  
  4947.  
  4948. ΓòÉΓòÉΓòÉ 25.1. Current voices ΓòÉΓòÉΓòÉ
  4949.  
  4950.  Currently there are a number of voices available in Festival and we expect 
  4951.  that number to increase. Each is elected via a function of the name 'voice_*' 
  4952.  which sets up the waveform synthesizer, phone set, lexicon, duration and 
  4953.  intonation models (and anything else necessary) for that speaker.  These voice 
  4954.  setup functions are defined in 'lib/voices.scm'. 
  4955.  
  4956.  The current voice functions are 
  4957.  
  4958.  voice_rab_diphone A British English male RP speaker, Roger.  This uses the 
  4959.            UniSyn residual excited LPC diphone synthesizer.  The lexicon is the 
  4960.            computer users version of Oxford Advanced Learners' Dictionary, with 
  4961.            letter to sound rules trained from that lexicon.  Intonation is 
  4962.            provided by a ToBI-like system using a decision tree to predict 
  4963.            accent and end tone position. The F0 itself is predicted as three 
  4964.            points on each syllable, using linear regression trained from the 
  4965.            Boston University FM database (f2b) and mapped to Roger's pitch 
  4966.            range.  Duration is predicted by decision tree, predicting zscore 
  4967.            durations for segments trained from the 460 Timit sentence spoken by 
  4968.            another British male speaker. 
  4969.  
  4970.  voice_ked_diphoneAn American English male speaker, Kurt.  Again this uses the 
  4971.            UniSyn residual excited LPC diphone synthesizer.  This uses the CMU 
  4972.            lexicon, and letter to sound rules trained from it.  Intonation as 
  4973.            with Roger is trained from the Boston University FM Radio corpus. 
  4974.            Duration for this voice also comes from that database. 
  4975.  
  4976.  voice_kal_diphoneAn American English male speaker.  Again this uses the UniSyn 
  4977.            residual excited LPC diphone synthesizer.  And like ked, uses the 
  4978.            CMU lexicon, and letter to sound rules trained from it.  Intonation 
  4979.            as with Roger is trained from the Boston University FM Radio corpus. 
  4980.            Duration for this voice also comes from that database.  This voice 
  4981.            was built in two days work and is at least as good as ked due to us 
  4982.            understanding the process better.  The diphone labels were 
  4983.            autoaligned with hand correction. 
  4984.  
  4985.  voice_don_diphoneSteve Isard's LPC based diphone synthesizer, Donovan 
  4986.            diphones.  The other parts of this voice, lexicon, intonation, and 
  4987.            duration are the same as voice_rab_diphone described above.  The 
  4988.            quality of the diphones is not as good as the other voices because 
  4989.            it uses spike excited LPC.  Although the quality is not as good it 
  4990.            is much faster and the database is much smaller than the others. 
  4991.  
  4992.  voice_el_diphoneA male Castilian Spanish speaker, using the Eduardo Lopez 
  4993.            diphones. Alistair Conkie and Borja Etxebarria did much to make 
  4994.            this.  It has improved recently but is not as comprehensive as our 
  4995.            English voices. 
  4996.  
  4997.  voice_gsw_diphoneThis offers a male RP speaker, Gordon, famed for many 
  4998.            previous CSTR synthesizers, using the standard diphone module.  Its 
  4999.            higher levels are very similar to the Roger voice above.  This voice 
  5000.            is not in the standard distribution, and is unlikely to be added for 
  5001.            commercial reasons, even though it sounds better than Roger. 
  5002.  
  5003.  voice_en1_mbrolaThe Roger diphone set using the same front end as 
  5004.            voice_rab_diphone but uses the MBROLA diphone synthesizer for 
  5005.            waveform synthesis.  The MBROLA synthesizer and Roger diphone 
  5006.            database (called en1) is not distributed by CSTR but is available 
  5007.            for non-commercial use for free from 
  5008.            http://tcts.fpms.ac.be/synthesis/mbrola.html. We do however provide 
  5009.            the Festival part of the voice in 'festvox_en1.tar.gz'. 
  5010.  
  5011.  voice_us1_mbrolaA female Amercian English voice using our standard US English 
  5012.            front end and the us1 database for the MBROLA diphone synthesizer 
  5013.            for waveform synthesis.  The MBROLA synthesizer and the us1 diphone 
  5014.            database is not distributed by CSTR but is available for 
  5015.            non-commercial use for free from 
  5016.            http://tcts.fpms.ac.be/synthesis/mbrola.html.  We provide the 
  5017.            Festival part of the voice in 'festvox_us1.tar.gz'. 
  5018.  
  5019.  voice_us2_mbrolaA male Amercian English voice using our standard US English 
  5020.            front end and the us2 database for the MBROLA diphone synthesizer 
  5021.            for waveform synthesis.  The MBROLA synthesizer and the us2 diphone 
  5022.            database is not distributed by CSTR but is available for 
  5023.            non-commercial use for free from 
  5024.            http://tcts.fpms.ac.be/synthesis/mbrola.html.  We provide the 
  5025.            Festival part of the voice in 'festvox_us2.tar.gz'. 
  5026.  
  5027.  voice_us3_mbrolaAnother male Amercian English voice using our standard US 
  5028.            English front end and the us2 database for the MBROLA diphone 
  5029.            synthesizer for waveform synthesis.  The MBROLA synthesizer and the 
  5030.            us2 diphone database is not distributed by CSTR but is available for 
  5031.            non-commercial use for free from 
  5032.            http://tcts.fpms.ac.be/synthesis/mbrola.html. We provide the 
  5033.            Festival part of the voice in 'festvox_us1.tar.gz'. 
  5034.  Other voices will become available through time.  Groups other than CSTR are 
  5035.  working on new voices.  Particularly OGI's CSLU have release a number of 
  5036.  American English voices, two Mexican Spanish voices and two German voices. 
  5037.  All use OGI's their own residual excited LPC synthesizer which is distributed 
  5038.  as a plug-in for Festival. (see http://www.cse.ogi.edu/CSLU/research/TTS for 
  5039.  details). 
  5040.  
  5041.  Other languages are being worked on including German, Basque, Welsh, Greek and 
  5042.  Polish already have been developed and could be release soon. CSTR has a set 
  5043.  of Klingon diphones though the text anlysis for Klingon still requires some 
  5044.  work (If anyone has access to a good Klingon continous speech corpora please 
  5045.  let us know.) 
  5046.  
  5047.  Pointers and examples of voices developed at CSTR and elsewhere will be posted 
  5048.  on the Festival home page. 
  5049.  
  5050.  
  5051. ΓòÉΓòÉΓòÉ 25.2. Building a new voice ΓòÉΓòÉΓòÉ
  5052.  
  5053.  This section runs through the definition of a new voice in Festival. Although 
  5054.  this voice is simple (it is a simplified version of the distributed spanish 
  5055.  voice) it shows all the major parts that must be defined to get Festival to 
  5056.  speak in a new voice.  Thanks go to Alistair Conkie for helping me define this 
  5057.  but as I don't speak Spanish there are probably many mistakes.  Hopefully its 
  5058.  pedagogical use is better than its ability to be understood in Castille. 
  5059.  
  5060.  A much more detailed document on building voices in Festival has been written 
  5061.  and is recommend reading for any one attempting to add a new voice to Festival 
  5062.  black99.  The information here is a little sparse though gives the basic 
  5063.  requirements. 
  5064.  
  5065.  The general method for defining a new voice is to define the parameters for 
  5066.  all the various sub-parts e.g. phoneset, duration parameter intonation 
  5067.  parameters etc., then defined a function of the form voice_NAME which when 
  5068.  called will actually select the voice. 
  5069.  
  5070.  
  5071. ΓòÉΓòÉΓòÉ 25.2.1. Phoneset ΓòÉΓòÉΓòÉ
  5072.  
  5073.  For most new languages and often for new dialects, a new phoneset is required. 
  5074.  It is really the basic building block of a voice and most other parts are 
  5075.  defined in terms of this set, so defining it first is a good start. 
  5076.  
  5077.                       (defPhoneSet
  5078.                        spanish
  5079.                        ;;;  Phone Features
  5080.                        (;; vowel or consonant
  5081.                         (vc + -)
  5082.                         ;; vowel length: short long diphthong schwa
  5083.                         (vlng s l d a 0)
  5084.                         ;; vowel height: high mid low
  5085.                         (vheight 1 2 3 -)
  5086.                         ;; vowel frontness: front mid back
  5087.                         (vfront 1 2 3 -)
  5088.                         ;; lip rounding
  5089.                         (vrnd + -)
  5090.                         ;; consonant type: stop fricative affricative nasal liquid
  5091.                         (ctype s f a n l 0)
  5092.                         ;; place of articulation: labial alveolar palatal labio-dental
  5093.                         ;;             dental velar
  5094.                         (cplace l a p b d v 0)
  5095.                         ;; consonant voicing
  5096.                         (cvox + -)
  5097.                         )
  5098.                        ;; Phone set members (features are not! set properly)
  5099.                        (
  5100.                         (#  - 0 - - - 0 0 -)
  5101.                         (a  + l 3 1 - 0 0 -)
  5102.                         (e  + l 2 1 - 0 0 -)
  5103.                         (i  + l 1 1 - 0 0 -)
  5104.                         (o  + l 3 3 - 0 0 -)
  5105.                         (u  + l 1 3 + 0 0 -)
  5106.                         (b  - 0 - - + s l +)
  5107.                         (ch - 0 - - + a a -)
  5108.                         (d  - 0 - - + s a +)
  5109.                         (f  - 0 - - + f b -)
  5110.                         (g  - 0 - - + s p +)
  5111.                         (j  - 0 - - + l a +)
  5112.                         (k  - 0 - - + s p -)
  5113.                         (l  - 0 - - + l d +)
  5114.                         (ll - 0 - - + l d +)
  5115.                         (m  - 0 - - + n l +)
  5116.                         (n  - 0 - - + n d +)
  5117.                         (ny - 0 - - + n v +)
  5118.                         (p  - 0 - - + s l -)
  5119.                         (r  - 0 - - + l p +)
  5120.                         (rr - 0 - - + l p +)
  5121.                         (s  - 0 - - + f a +)
  5122.                         (t  - 0 - - + s t +)
  5123.                         (th - 0 - - + f d +)
  5124.                         (x  - 0 - - + a a -)
  5125.                        )
  5126.                       )
  5127.                       (PhoneSet.silences '(#))
  5128.  Note some phonetic features may be wrong. 
  5129.  
  5130.  
  5131. ΓòÉΓòÉΓòÉ 25.2.2. Lexicon and LTS ΓòÉΓòÉΓòÉ
  5132.  
  5133.  Spanish is a language whose pronunciation can almost completely be predicted 
  5134.  from its orthography so in this case we do not need a list of words and their 
  5135.  pronunciations and can do most of the work with letter to sound rules. 
  5136.  
  5137.  Let us first make a lexicon structure as follows 
  5138.  
  5139.                       (lex.create "spanish")
  5140.                       (lex.set.phoneset "spanish")
  5141.  However if we did just want a few entries to test our system without building 
  5142.  any letter to sound rules we could add entries directly to the addenda.  For 
  5143.  example 
  5144.  
  5145.                       (lex.add.entry
  5146.                         '("amigos" nil (((a) 0) ((m i) 1) (g o s))))
  5147.  A letter to sound rule system for Spanish is quite simple in the format 
  5148.  supported by Festival.  The following is a good start to a full set. 
  5149.  
  5150.                       (lts.ruleset
  5151.                       ;  Name of rule set
  5152.                        spanish
  5153.                       ;  Sets used in the rules
  5154.                       (
  5155.                        (LNS l n s )
  5156.                        (AEOU a e o u )
  5157.                        (AEO a e o )
  5158.                        (EI e i )
  5159.                        (BDGLMN b d g l m n )
  5160.                       )
  5161.                       ;  Rules
  5162.                       (
  5163.                        ( [ a ] = a )
  5164.                        ( [ e ] = e )
  5165.                        ( [ i ] = i )
  5166.                        ( [ o ] = o )
  5167.                        ( [ u ] = u )
  5168.                        ( [ "'" a ] = a1 )  ;; stressed vowels
  5169.                        ( [ "'" e ] = e1 )
  5170.                        ( [ "'" i ] = i1 )
  5171.                        ( [ "'" o ] = o1 )
  5172.                        ( [ "'" u ] = u1 )
  5173.                        ( [ b ] = b )
  5174.                        ( [ v ] = b )
  5175.                        ( [ c ] "'" EI = th )
  5176.                        ( [ c ] EI = th )
  5177.                        ( [ c h ] = ch )
  5178.                        ( [ c ] = k )
  5179.                        ( [ d ] = d )
  5180.                        ( [ f ] = f )
  5181.                        ( [ g ] "'" EI = x )
  5182.                        ( [ g ] EI = x )
  5183.                        ( [ g u ] "'" EI = g )
  5184.                        ( [ g u ] EI = g )
  5185.                        ( [ g ] = g )
  5186.                        ( [ h u e ] = u e )
  5187.                        ( [ h i e ] = i e )
  5188.                        ( [ h ] =  )
  5189.                        ( [ j ] = x )
  5190.                        ( [ k ] = k )
  5191.                        ( [ l l ] # = l )
  5192.                        ( [ l l ] = ll )
  5193.                        ( [ l ] = l )
  5194.                        ( [ m ] = m )
  5195.                        ( [ ~ n ] = ny )
  5196.                        ( [ n ] = n )
  5197.                        ( [ p ] = p )
  5198.                        ( [ q u ] = k )
  5199.                        ( [ r r ] = rr )
  5200.                        ( # [ r ] = rr )
  5201.                        ( LNS [ r ] = rr )
  5202.                        ( [ r ] = r )
  5203.                        ( [ s ] BDGLMN = th )
  5204.                        ( [ s ] = s )
  5205.                        ( # [ s ] C = e s )
  5206.                        ( [ t ] = t )
  5207.                        ( [ w ] = u )
  5208.                        ( [ x ] = k s )
  5209.                        ( AEO [ y ] = i )
  5210.                        ( # [ y ] # = i )
  5211.                        ( [ y ] = ll )
  5212.                        ( [ z ] = th )
  5213.                       ))
  5214.  We could simply set our lexicon to use the above letter to sound system with 
  5215.  the following command 
  5216.  
  5217.                       (lex.set.lts.ruleset 'spanish)
  5218.  But this would not deal with upper case letters.  Instead of writing new rules 
  5219.  for upper case letters we can define that a Lisp function be called when 
  5220.  looking up a word and intercept the lookup with our own function.  First we 
  5221.  state that unknown words should call a function, and then define the function 
  5222.  we wish called. The actual link to ensure our function will be called is done 
  5223.  below at lexicon selection time 
  5224.  
  5225.                       (define (spanish_lts word features)
  5226.                        "(spanish_lts WORD FEATURES)
  5227.                       Using letter to sound rules build a spanish pronunciation of WORD."
  5228.                        (list word
  5229.                           nil
  5230.                           (lex.syllabify.phstress (lts.apply (downcase word) 'spanish))))
  5231.                       (lex.set.lts.method spanish_lts)
  5232.  In the function we downcase the word and apply the LTS rule to it. Next we 
  5233.  syllabify it and return the created lexical entry. 
  5234.  
  5235.  
  5236. ΓòÉΓòÉΓòÉ 25.2.3. Phrasing ΓòÉΓòÉΓòÉ
  5237.  
  5238.  Without detailed labelled databases we cannot build statistical models of 
  5239.  phrase breaks, but we can simply build a phrase break model based on 
  5240.  punctuation.  The following is a CART tree to predict simple breaks, from 
  5241.  punctuation. 
  5242.  
  5243.                       (set! spanish_phrase_cart_tree
  5244.                       '
  5245.                       ((lisp_token_end_punc in ("?" "." ":"))
  5246.                        ((BB))
  5247.                        ((lisp_token_end_punc in ("'" "\"" "," ";"))
  5248.                         ((B))
  5249.                         ((n.name is 0)  ;; end of utterance
  5250.                         ((BB))
  5251.                         ((NB))))))
  5252.  
  5253.  
  5254. ΓòÉΓòÉΓòÉ 25.2.4. Intonation ΓòÉΓòÉΓòÉ
  5255.  
  5256.  For intonation there are number of simple options without requiring training 
  5257.  data.  For this example we will simply use a hat pattern on all stressed 
  5258.  syllables in content words and on single syllable content words. (i.e. 
  5259.  Simple) Thus we need an accent prediction CART tree. 
  5260.  
  5261.                       (set! spanish_accent_cart_tree
  5262.                        '
  5263.                        ((R:SylStructure.parent.gpos is content)
  5264.                         ((stress is 1)
  5265.                         ((Accented))
  5266.                         ((position_type is single)
  5267.                          ((Accented))
  5268.                          ((NONE))))
  5269.                         ((NONE))))
  5270.  We also need to specify the pitch range of our speaker.  We will be using a 
  5271.  male Spanish diphone database of the follow range 
  5272.  
  5273.                       (set! spanish_el_int_simple_params
  5274.                         '((f0_mean 120) (f0_std 30)))
  5275.  
  5276.  
  5277. ΓòÉΓòÉΓòÉ 25.2.5. Duration ΓòÉΓòÉΓòÉ
  5278.  
  5279.  We will use the trick mentioned above for duration prediction. Using the 
  5280.  zscore CART tree method, we will actually use it to predict factors rather 
  5281.  than zscores. 
  5282.  
  5283.  The tree predicts longer durations in stressed syllables and in clause initial 
  5284.  and clause final syllables. 
  5285.  
  5286.                       (set! spanish_dur_tree
  5287.                        '
  5288.                         ((R:SylStructure.parent.R:Syllable.p.syl_break > 1 ) ;; clause initial
  5289.                         ((R:SylStructure.parent.stress is 1)
  5290.                          ((1.5))
  5291.                          ((1.2)))
  5292.                         ((R:SylStructure.parent.syl_break > 1)  ;; clause final
  5293.                          ((R:SylStructure.parent.stress is 1)
  5294.                          ((2.0))
  5295.                          ((1.5)))
  5296.                          ((R:SylStructure.parent.stress is 1)
  5297.                          ((1.2))
  5298.                          ((1.0))))))
  5299.  In addition to the tree we need durations for each phone in the set 
  5300.  
  5301.                       (set! spanish_el_phone_data
  5302.                       '(
  5303.                         (# 0.0 0.250)
  5304.                         (a 0.0 0.090)
  5305.                         (e 0.0 0.090)
  5306.                         (i 0.0 0.080)
  5307.                         (o 0.0 0.090)
  5308.                         (u 0.0 0.080)
  5309.                         (b 0.0 0.065)
  5310.                         (ch 0.0 0.135)
  5311.                         (d 0.0 0.060)
  5312.                         (f 0.0 0.100)
  5313.                         (g 0.0 0.080)
  5314.                         (j 0.0 0.100)
  5315.                         (k 0.0 0.100)
  5316.                         (l 0.0 0.080)
  5317.                         (ll 0.0 0.105)
  5318.                         (m 0.0 0.070)
  5319.                         (n 0.0 0.080)
  5320.                         (ny 0.0 0.110)
  5321.                         (p 0.0 0.100)
  5322.                         (r 0.0 0.030)
  5323.                         (rr 0.0 0.080)
  5324.                         (s 0.0 0.110)
  5325.                         (t 0.0 0.085)
  5326.                         (th 0.0 0.100)
  5327.                         (x 0.0 0.130)
  5328.                       ))
  5329.  
  5330.  
  5331. ΓòÉΓòÉΓòÉ 25.2.6. Waveform synthesis ΓòÉΓòÉΓòÉ
  5332.  
  5333.  There are a number of choices for waveform synthesis currently supported. 
  5334.  MBROLA supports Spanish, so we could use that.  But their Spanish diphones in 
  5335.  fact use a slightly different phoneset so we would need to change the above 
  5336.  definitions to use it effectively.  Here we will use a diphone database for 
  5337.  Spanish recorded by Eduardo Lopez when he was a Masters student some years 
  5338.  ago. 
  5339.  
  5340.  Here we simply load our pre-built diphone database 
  5341.  
  5342.                       (us_diphone_init
  5343.                         (list
  5344.                         '(name "el_lpc_group")
  5345.                         (list 'index_file
  5346.                            (path-append spanish_el_dir "group/ellpc11k.group"))
  5347.                         '(grouped "true")
  5348.                         '(default_diphone "#-#")))
  5349.  
  5350.  
  5351. ΓòÉΓòÉΓòÉ 25.2.7. Voice selection function ΓòÉΓòÉΓòÉ
  5352.  
  5353.  The standard way to define a voice in Festival is to define a function of the 
  5354.  form voice_NAME which selects all the appropriate parameters.  Because the 
  5355.  definition below follows the above definitions we know that everything 
  5356.  appropriate has been loaded into Festival and hence we just need to select the 
  5357.  appropriate a parameters. 
  5358.  
  5359.                       (define (voice_spanish_el)
  5360.                       "(voice_spanish_el)
  5361.                       Set up synthesis for Male Spanish speaker: Eduardo Lopez"
  5362.                        (voice_reset)
  5363.                        (Parameter.set 'Language 'spanish)
  5364.                        ;; Phone set
  5365.                        (Parameter.set 'PhoneSet 'spanish)
  5366.                        (PhoneSet.select 'spanish)
  5367.                        (set! pos_lex_name nil)
  5368.                        ;; Phrase break prediction by punctuation
  5369.                        (set! pos_supported nil)
  5370.                        ;; Phrasing
  5371.                        (set! phrase_cart_tree spanish_phrase_cart_tree)
  5372.                        (Parameter.set 'Phrase_Method 'cart_tree)
  5373.                        ;; Lexicon selection
  5374.                        (lex.select "spanish")
  5375.                        ;; Accent prediction
  5376.                        (set! int_accent_cart_tree spanish_accent_cart_tree)
  5377.                        (set! int_simple_params spanish_el_int_simple_params)
  5378.                        (Parameter.set 'Int_Method 'Simple)
  5379.                        ;; Duration prediction
  5380.                        (set! duration_cart_tree spanish_dur_tree)
  5381.                        (set! duration_ph_info spanish_el_phone_data)
  5382.                        (Parameter.set 'Duration_Method 'Tree_ZScores)
  5383.                        ;; Waveform synthesizer: diphones
  5384.                        (Parameter.set 'Synth_Method 'UniSyn)
  5385.                        (Parameter.set 'us_sigpr 'lpc)
  5386.                        (us_db_select 'el_lpc_group)
  5387.                        (set! current-voice 'spanish_el)
  5388.                       )
  5389.                       (provide 'spanish_el)
  5390.  
  5391.  
  5392. ΓòÉΓòÉΓòÉ 25.2.8. Last remarks ΓòÉΓòÉΓòÉ
  5393.  
  5394.  We save the above definitions in a file 'spanish_el.scm'.  Now we can declare 
  5395.  the new voice to Festival.  See Defining a new voice for a description of 
  5396.  methods for adding new voices.  For testing purposes we can explciitly load 
  5397.  the file 'spanish_el.scm' 
  5398.  
  5399.  The voice is now available for use in festival. 
  5400.  
  5401.                       festival> (voice_spanish_el)
  5402.                       spanish_el
  5403.                       festival> (SayText "hola amigos")
  5404.                       <Utterance 0x04666>
  5405.  
  5406.  As you can see adding a new voice is not very difficult.  Of course there is 
  5407.  quite a lot more than the above to add a high quality robust voice to 
  5408.  Festival.  But as we can see many of the basic tools that we wish to use 
  5409.  already exist.  The main difference between the above voice and the English 
  5410.  voices already in Festival are that their models are better trained from 
  5411.  databases.  This produces, in general, better results, but the concepts behind 
  5412.  them are basically the same.  All of those trainable methods may be 
  5413.  parameterized with data for new voices. 
  5414.  
  5415.  As Festival develops, more modules will be added with better support for 
  5416.  training new voices so in the end we hope that adding in high quality new 
  5417.  voices is actually as simple as (or indeed simpler than) the above 
  5418.  description. 
  5419.  
  5420.  
  5421. ΓòÉΓòÉΓòÉ 25.2.9. Resetting globals ΓòÉΓòÉΓòÉ
  5422.  
  5423.  Because the version of Scheme used in Festival only has a single flat name 
  5424.  space it is unfortunately too easy for voices to set some global which 
  5425.  accidentally affects all other voices selected after it.  Because of this 
  5426.  problem we have introduced a convention to try to minimise the possibility of 
  5427.  this becoming a problem.  Each voice function defined should always call 
  5428.  voice_reset at the start.  This will reset any globals and also call a tidy up 
  5429.  function provided by the previous voice function. 
  5430.  
  5431.  Likewise in your new voice function you should provide a tidy up function to 
  5432.  reset any non-standard global variables you set.  The function 
  5433.  current_voice_reset will be called by voice_reset.  If the value of 
  5434.  current_voice_reset is nil then it is not called.  voice_reset sets 
  5435.  current_voice_reset to nil, after calling it. 
  5436.  
  5437.  For example suppose some new voice requires the audio device to be directed to 
  5438.  a different machine.  In this example we make the giant's voice go through the 
  5439.  netaudio machine big_speakers while the standard voice go through 
  5440.  small_speakers. 
  5441.  
  5442.  Although we can easily select the machine big_speakers as out when our 
  5443.  voice_giant is called, we also need to set it back when the next voice is 
  5444.  selected, and don't want to have to modify every other voice defined in the 
  5445.  system.  Let us first define two functions to selection the audio output. 
  5446.  
  5447.                       (define (select_big)
  5448.                        (set! giant_previous_audio (getenv "AUDIOSERVER"))
  5449.                        (setenv "AUDIOSERVER" "big_speakers"))
  5450.                       (define (select_normal)
  5451.                        (setenv "AUDIOSERVER" giant_previous_audio))
  5452.  Note we save the previous value of AUDIOSERVER rather than simply assuming it 
  5453.  was small_speakers. 
  5454.  
  5455.  Our definition of voice_giant definition of voice_giant will look something 
  5456.  like 
  5457.  
  5458.                       (define (voice_giant)
  5459.                       "comment comment ┬╖┬╖┬╖"
  5460.                         (voice_reset)  ;; get into a known state
  5461.                         (select_big)
  5462.                         ;;; other giant voice parameters
  5463.                         ┬╖┬╖┬╖
  5464.                         (set! current_voice_rest select_normal)
  5465.                         (set! current-voice 'giant))
  5466.  The obvious question is which variables should a voice reset. Unfortunately 
  5467.  there is not a definitive answer to that.  To a certain extent I don't want to 
  5468.  define that list as there will be many variables that will by various people 
  5469.  in Festival which are not in the original distribution and we don't want to 
  5470.  restrict them.  The longer term answer is some for of partitioning of the 
  5471.  Scheme name space perhaps having voice local variables (cf. Emacs buffer local 
  5472.  variables).  But ultimately a voice may set global variables which could 
  5473.  redefine the operation of later selected voices and there seems no real way to 
  5474.  stop that, and keep the generality of the system. 
  5475.  
  5476.  Note the convention of setting the global current-voice as the end of any 
  5477.  voice definition file.  We do not enforce this but probabaly should.  The 
  5478.  variable current-voice at any time should identify the current voice, the 
  5479.  voice description information (described below) will relate this name to 
  5480.  properties identifying it. 
  5481.  
  5482.  
  5483. ΓòÉΓòÉΓòÉ 25.3. Defining a new voice ΓòÉΓòÉΓòÉ
  5484.  
  5485.  As there are a number of voices available for Festival and they may or may not 
  5486.  exists in different installations we have tried to make it as simple as 
  5487.  possible to add new voices to the system without having to change any of the 
  5488.  basic distribution.  In fact if the voices use the following standard method 
  5489.  for describing themselves it is merely a matter of unpacking them in order for 
  5490.  them to be used by the system. 
  5491.  
  5492.  The variable voice-path conatins a list of directories where voices will be 
  5493.  automatically searched for.  If this is not set it is set automatically by 
  5494.  appending '/voices/' to all paths in festival load-path.  You may add new 
  5495.  directories explicitly to this variable in your 'sitevars.scm' file or your 
  5496.  own '.festivalrc' as you wish. 
  5497.  
  5498.  Each voice directory is assumed to be of the form 
  5499.  
  5500.                       LANGUAGE/VOICENAME/
  5501.  Within the VOICENAME/ directory itself it is assumed there is a file 
  5502.  'festvox/VOICENAME.scm' which when loaded will define the voice itself.  The 
  5503.  actual voice function should be called voice_VOICENAME. 
  5504.  
  5505.  For example the voices distributed with the standard Festival distribution all 
  5506.  unpack in 'festival/lib/voices'.  The Amercan voice 'ked_diphone' unpacks into 
  5507.  
  5508.                       festival/lib/voices/english/ked_diphone/
  5509.  Its actual definition file is in 
  5510.  
  5511.                       festival/lib/voices/english/ked_diphone/festvox/ked_diphone.scm
  5512.  Note the name of the directory and the name of the Scheme definition file must 
  5513.  be the same. 
  5514.  
  5515.  Alternative voices using perhaps a different encoding of the database but the 
  5516.  same front end may be defined in the same way by using symbolic links in the 
  5517.  langauge directoriy to the main directory.  For example a PSOLA version of the 
  5518.  ked voice may be defined in 
  5519.  
  5520.                       festival/lib/voices/english/ked_diphone/festvox/ked_psola.scm
  5521.  Adding a symbole link in 'festival/lib/voices/english/' ro 'ked_diphone' 
  5522.  called 'ked_psola' will allow that voice to be automatically registered when 
  5523.  Festival starts up. 
  5524.  
  5525.  Note that this method doesn't actually load the voices it finds, that could be 
  5526.  prohibitively time consuming to the start up process.  It blindly assumes that 
  5527.  there is a file 'VOICENAME/festvox/VOICENAME.scm' to load.  An autoload 
  5528.  definition is given for voice_VOICENAME which when called will load that file 
  5529.  and call the real definition if it exists in the file. 
  5530.  
  5531.  This is only a recommended method to make adding new voices easier, it may be 
  5532.  ignored if you wish.  However we still recommend that even if you use your own 
  5533.  convetions for adding new voices you consider the autoload function to define 
  5534.  them in, for example, the 'siteinit.scm' file or '.festivalrc'.  The autoload 
  5535.  function takes three arguments: a function name, a file containing the actual 
  5536.  definiton and a comment. For example a definition of voice can be done 
  5537.  explicitly by 
  5538.  
  5539.                       (autooad voice_f2b  "/home/awb/data/f2b/ducs/f2b_ducs"
  5540.                          "American English female f2b")))
  5541.  Of course you can also load the definition file explicitly if you wish. 
  5542.  
  5543.  In order to allow the system to start making intellegent use of voices we 
  5544.  recommend that all voice definitions include a call to the function 
  5545.  voice_proclaim this allows the system to know some properties about the voice 
  5546.  such as language, gender and dialect.  The proclaim_voice function taks two 
  5547.  arguments a name (e.g. rab_diphone and an assoc list of features and names. 
  5548.  Currently we require language, gender, dialect and description.  The last 
  5549.  being a textual description of the voice itself.  An example proclaimation is 
  5550.  
  5551.                       (proclaim_voice
  5552.                        'rab_diphone
  5553.                        '((language english)
  5554.                         (gender male)
  5555.                         (dialect british)
  5556.                         (description
  5557.                         "This voice provides a British RP English male voice using a
  5558.                          residual excited LPC diphone synthesis method.  It uses a
  5559.                          modified Oxford Advanced Learners' Dictionary for pronunciations.
  5560.                          Prosodic phrasing is provided by a statistically trained model
  5561.                          using part of speech and local distribution of breaks.  Intonation
  5562.                          is provided by a CART tree predicting ToBI accents and an F0
  5563.                          contour generated from a model trained from natural speech.  The
  5564.                          duration model is also trained from data using a CART tree.")))
  5565.  There are functions to access a description.  voice.description will return 
  5566.  the description for a given voice and will load that voice if it is not 
  5567.  already loaded.  voice.describe will describe the given given voice by 
  5568.  synthesizing the textual description using the current voice.  It would be 
  5569.  nice to use the voice itself to give a self introduction but unfortunately 
  5570.  that introduces of problem of decide which language the description should be 
  5571.  in, we are not all as fluent in welsh as we'd like to be. 
  5572.  
  5573.  The function voice.list will list the potential voices in the system.  These 
  5574.  are the names of voices which have been found in the voice-path.  As they have 
  5575.  not actaully been loaded they can't actually be confirmed as usable voices. 
  5576.  One solution to this would be to load all voices at start up time which would 
  5577.  allow confirmation they exist and to get their full description through 
  5578.  proclaim_voice. But start up is already too slow in festival so we have to 
  5579.  accept this stat for the time being.  Splitting the description of the voice 
  5580.  from the actual definition is a possible solution to this problem but we have 
  5581.  not yet looked in to this. 
  5582.  
  5583.  
  5584. ΓòÉΓòÉΓòÉ 26. Tools ΓòÉΓòÉΓòÉ
  5585.  
  5586.  A number of basic data manipulation tools are supported by Festival. These 
  5587.  often make building new modules very easy and are already used in many of the 
  5588.  existing modules.  They typically offer a Scheme method for entering data, and 
  5589.  Scheme and C++ functions for evaluating it. 
  5590.  
  5591.  Regular expressions 
  5592.  CART trees                    Building and using CART 
  5593.  Ngrams                        Building and using Ngrams 
  5594.  Viterbi decoder               Using the Viterbi decoder 
  5595.  Linear regression             Building and using linear regression models 
  5596.  
  5597.  
  5598. ΓòÉΓòÉΓòÉ 26.1. Regular expressions ΓòÉΓòÉΓòÉ
  5599.  
  5600.  Regular expressions are a formal method for describing a certain class of 
  5601.  mathematical languages.  They may be viewed as patterns which match some set 
  5602.  of strings.  They are very common in many software tools such as scripting 
  5603.  languages like the UNIX shell, PERL, awk, Emacs etc. Unfortunately the exact 
  5604.  form of regualr expressions often differs slightly between different 
  5605.  applications making their use often a little tricky. 
  5606.  
  5607.  Festival support regular expressions based mainly of the form used in the GNU 
  5608.  libg++ Regex class, though we have our own implementation of it.  Our 
  5609.  implementation (EST_Regex) is actually based on Henry Spencer's 'regex.c' as 
  5610.  distributed with BSD 4.4. 
  5611.  
  5612.  Regular expressions are represented as character strings which are interpreted 
  5613.  as regular expressions by certain Scheme and C++ functions.  Most characters 
  5614.  in a regular expression are treated as literals and match only that character 
  5615.  but a number of others have special meaning.  Some characters may be escaped 
  5616.  with preceeding backslashes to change them from operators to literals (or 
  5617.  sometime literals to operators). 
  5618.  
  5619.  .         Matches any character. 
  5620.  
  5621.  $         matches end of string 
  5622.  
  5623.  ^         matches beginning of string 
  5624.  
  5625.  X*        matches zero or more occurrences of X, X may be a character, range 
  5626.            of parenthesized expression. 
  5627.  
  5628.  X+        matches one or more occurrences of X, X may be a character, range of 
  5629.            parenthesized expression. 
  5630.  
  5631.  X?        matches zero or one occurrence of X, X may be a character, range of 
  5632.            parenthesized expression. 
  5633.  
  5634.  [┬╖┬╖┬╖]     a ranges matches an of the values in the brackets.  The range 
  5635.            operator "-" allows specification of ranges e.g. a-z for all lower 
  5636.            case characters.  If the first character of the range is ^ then it 
  5637.            matches anything character except those specificed in the range.  If 
  5638.            you wish - to be in the range you must put that first. 
  5639.  
  5640.  \\(┬╖┬╖┬╖\\) Treat contents of parentheses as single object allowing operators *, 
  5641.            +, ? etc to operate on more than single characters. 
  5642.  
  5643.  X\\|Y     matches either X or Y.  X or Y may be single characters, ranges or 
  5644.            parenthesized expressions. 
  5645.  Note that actuall only one backslash is needed before a character to escape it 
  5646.  but becuase these expressions are most often contained with Scheme or C++ 
  5647.  strings, the escpae mechanaism for those strings requires that backslash 
  5648.  itself be escaped, hence you will most often be required to type two 
  5649.  backslashes. 
  5650.  
  5651.  Some example may help in enderstanding the use of regular expressions. 
  5652.  
  5653.  a.b       matches any three letter string starting with an a and ending with a 
  5654.            b. 
  5655.  
  5656.  .*a       matches any string ending in an a 
  5657.  
  5658.  .*a.*     matches any string containing an a 
  5659.  
  5660.  [A-Z].*   matches any string starting with a capital letter 
  5661.  
  5662.  [0-9]+    matches any string of digits 
  5663.  
  5664.  -?[0-9]+\\(\\.[0-9]+\\)?matches any positive or negative real number.  Note 
  5665.            the optional preceeding minus sign and the optional part contain the 
  5666.            point and following numbers.  The point itself must be escaped as 
  5667.            dot on its own matches any character. 
  5668.  
  5669.  [^aeiouAEIOU]+mathes any non-empty string which doesn't conatin a vowel 
  5670.  
  5671.  \\([Ss]at\\(urday\\)\\)?\\|\\([Ss]un\\(day\\)\\)matches Saturday and Sunday in 
  5672.            various ways 
  5673.  
  5674.  The Scheme function string-matches takes a string and a regular expression and 
  5675.  returns t if the regular expression macthes the string and nil otherwise. 
  5676.  
  5677.  
  5678. ΓòÉΓòÉΓòÉ 26.2. CART trees ΓòÉΓòÉΓòÉ
  5679.  
  5680.  One of the basic tools available with Festival is a system for building and 
  5681.  using Classification and Regression Trees (breiman84).  This standard 
  5682.  statistical method can be used to predict both categorical and continuous data 
  5683.  from a set of feature vectors. 
  5684.  
  5685.  The tree itself contains yes/no questions about features and ultimately 
  5686.  provides either a probability distribution, when predicting categorical values 
  5687.  (classification tree), or a mean and standard deviation when predicting 
  5688.  continuous values (regression tree).  Well defined techniques can be used to 
  5689.  construct an optimal tree from a set of training data. The program, developed 
  5690.  in conjunction with Festival, called 'wagon', distributed with the speech 
  5691.  tools, provides a basic but ever increasingly powerful method for constructing 
  5692.  trees. 
  5693.  
  5694.  A tree need not be automatically constructed, CART trees have the advantage 
  5695.  over some other automatic training methods, such as neural networks and linear 
  5696.  regression, in that their output is more readable and often understandable by 
  5697.  humans.  Importantly this makes it possible to modify them.  CART trees may 
  5698.  also be fully hand constructed.  This is used, for example, in generating some 
  5699.  duration models for languages we do not yet have full databases to train from. 
  5700.  
  5701.  A CART tree has the following syntax 
  5702.  
  5703.                         CART ::= QUESTION-NODE || ANSWER-NODE
  5704.                         QUESTION-NODE ::= ( QUESTION YES-NODE NO-NODE )
  5705.                         YES-NODE ::= CART
  5706.                         NO-NODE ::= CART
  5707.                         QUESTION ::= ( FEATURE in LIST )
  5708.                         QUESTION ::= ( FEATURE is STRVALUE )
  5709.                         QUESTION ::= ( FEATURE = NUMVALUE )
  5710.                         QUESTION ::= ( FEATURE > NUMVALUE )
  5711.                         QUESTION ::= ( FEATURE < NUMVALUE )
  5712.                         QUESTION ::= ( FEATURE matches REGEX )
  5713.                         ANSWER-NODE ::= CLASS-ANSWER || REGRESS-ANSWER
  5714.                         CLASS-ANSWER ::= ( (VALUE0 PROB) (VALUE1 PROB) ┬╖┬╖┬╖ MOST-PROB-VALUE )
  5715.                         REGRESS-ANSWER ::= ( ( STANDARD-DEVIATION MEAN ) )
  5716.  Note that answer nodes are distinguished by their car not being atomic. 
  5717.  
  5718.  The interpretation of a tree is with respect to a Stream_Item The FEATURE in a 
  5719.  tree is a standard feature (see Features). 
  5720.  
  5721.  The following example tree is used in one of the Spanish voices to predict 
  5722.  variations from average durations. 
  5723.  
  5724.                       (set! spanish_dur_tree
  5725.                        '
  5726.                       (set! spanish_dur_tree
  5727.                        '
  5728.                         ((R:SylStructure.parent.R:Syllable.p.syl_break > 1 ) ;; clause initial
  5729.                         ((R:SylStructure.parent.stress is 1)
  5730.                          ((1.5))
  5731.                          ((1.2)))
  5732.                         ((R:SylStructure.parent.syl_break > 1)  ;; clause final
  5733.                          ((R:SylStructure.parent.stress is 1)
  5734.                          ((2.0))
  5735.                          ((1.5)))
  5736.                          ((R:SylStructure.parent.stress is 1)
  5737.                          ((1.2))
  5738.                          ((1.0))))))
  5739.  It is applied to the segment stream to give a factor to multiply the average 
  5740.  by. 
  5741.  
  5742.  wagon is constantly improving and with version 1.2 of the speech tools may now 
  5743.  be considered fairly stable for its basic operations. Experimental features 
  5744.  are described in help it gives.  See the Speech Tools manual for a more 
  5745.  comprehensive discussion of using 'wagon'. 
  5746.  
  5747.  However the above format of trees is similar to those produced by many other 
  5748.  systems and hence it is reasonable to translate their formats into one which 
  5749.  Festival can use. 
  5750.  
  5751.  
  5752. ΓòÉΓòÉΓòÉ 26.3. Ngrams ΓòÉΓòÉΓòÉ
  5753.  
  5754.  Bigram, trigrams, and general ngrams are used in the part of speech tagger and 
  5755.  the phrase break predicter.  An Ngram C++ Class is defined in the speech tools 
  5756.  library and some simple facilities are added within Festival itself. 
  5757.  
  5758.  Ngrams may be built from files of tokens using the program ngram_build which 
  5759.  is part of the speech tools.  See the speech tools documentation for details. 
  5760.  
  5761.  Within Festival ngrams may be named and loaded from files and used when 
  5762.  required.  The LISP function load_ngram takes a name and a filename as 
  5763.  argument and loads the Ngram from that file.  For an example of its use once 
  5764.  loaded see 'src/modules/base/pos.cc' or 'src/modules/base/phrasify.cc'. 
  5765.  
  5766.  
  5767. ΓòÉΓòÉΓòÉ 26.4. Viterbi decoder ΓòÉΓòÉΓòÉ
  5768.  
  5769.  Another common tool is a Viterbi decoder.  This C++ Class is defined in the 
  5770.  speech tools library 'speech_tooks/include/EST_viterbi.h' and 
  5771.  'speech_tools/stats/EST_viterbi.cc'.  A Viterbi decoder requires two functions 
  5772.  at declaration time.  The first constructs candidates at each stage, while the 
  5773.  second combines paths.  A number of options are available (which may change). 
  5774.  
  5775.  The prototypical example of use is in the part of speech tagger which using 
  5776.  standard Ngram models to predict probabilities of tags. See 
  5777.  'src/modules/base/pos.cc' for an example. 
  5778.  
  5779.  The Viterbi decoder can also be used through the Scheme function Gen_Viterbi. 
  5780.  This function respects the parameters defined in the variable get_vit_params. 
  5781.  Like other modules this parameter list is an assoc list of feature name and 
  5782.  value.  The parameters supported are: 
  5783.  
  5784.  Relation  The name of the relation the decoeder is to be applied to. 
  5785.  
  5786.  cand_functionA function that is to be called for each item that will return a 
  5787.            list of candidates (with probilities). 
  5788.  
  5789.  return_featThe name of a feature that the best candidate is to be returned in 
  5790.            for each item in the named relation. 
  5791.  
  5792.  p_word    The previous word to the first item in the named relation (only used 
  5793.            when ngrams are the "language model"). 
  5794.  
  5795.  pp_word   The previous previous word to the first item in the named relation 
  5796.            (only used when ngrams are the "language model"). 
  5797.  
  5798.  ngramname the name of an ngram (loaded by ngram.load) to be used as a 
  5799.            "language model". 
  5800.  
  5801.  wfstmname the name of a WFST (loaded by wfst.load) to be used as a "language 
  5802.            model", this is ignored if an ngramname is also specified. 
  5803.  
  5804.  debug     If specified more debug features are added to the items in the 
  5805.            relation. 
  5806.  
  5807.  gscale_p  Grammar scaling factor. 
  5808.  Here is a short example to help make the use of this facility clearer. 
  5809.  
  5810.  There are two parts required for the Viterbi decode a set of candidate 
  5811.  observations and some "language model".  For the math to work properly the 
  5812.  candidate observations must be reverse probabilities (for each candidiate as 
  5813.  given what is the probability of the observation, rather than the probability 
  5814.  of the candidate given the observation).  These can be calculated for the 
  5815.  probabilties candidate given the observation divided by the probability of the 
  5816.  candidate in isolation. 
  5817.  
  5818.  For the sake of simplicity let us assume we have a lexicon of words to 
  5819.  distribution of part of speech tags with reverse probabilities.  And an 
  5820.  tri-gram called pos-tri-gram over ngram sequences of part of speech tags. 
  5821.  First we must define the candidate function 
  5822.  
  5823.                       (define (pos_cand_function w)
  5824.                        ;; select the appropriate lexicon
  5825.                        (lex.select 'pos_lex)
  5826.                        ;; return the list of cands with rprobs
  5827.                        (cadr
  5828.                        (lex.lookup (item.name w) nil)))
  5829.  The returned candidate list would look somthing like 
  5830.  
  5831.                       ( (jj -9.872) (vbd -6.284) (vbn -5.565) )
  5832.  Our part of speech tagger function would look something like this 
  5833.  
  5834.                       (define (pos_tagger utt)
  5835.                        (set! get_vit_params
  5836.                           (list
  5837.                            (list 'Relation "Word")
  5838.                            (list 'return_feat 'pos_tag)
  5839.                            (list 'p_word "punc")
  5840.                            (list 'pp_word "nn")
  5841.                            (list 'ngramname "pos-tri-gram")
  5842.                            (list 'cand_function 'pos_cand_function)))
  5843.                        (Gen_Viterbi utt)
  5844.                        utt)
  5845.  this will assign the optimal part of speech tags to each word in utt. 
  5846.  
  5847.  
  5848. ΓòÉΓòÉΓòÉ 26.5. Linear regression ΓòÉΓòÉΓòÉ
  5849.  
  5850.  The linear regression model takes models built from some external package and 
  5851.  finds coefficients based on the features and weights.  A model consists of a 
  5852.  list of features.  The first should be the atom Intercept plus a value.  The 
  5853.  following in the list should consist of a feature (see Features) followed by a 
  5854.  weight.  An optional third element may be a list of atomic values.  If the 
  5855.  result of the feature is a member of this list the feature's value is treated 
  5856.  as 1 else it is 0. This third argument allows an efficient way to map 
  5857.  categorical values into numeric values.  For example, from the F0 prediction 
  5858.  model in 'lib/f2bf0lr.scm'.  The first few parameters are 
  5859.  
  5860.                       (set! f2b_f0_lr_start
  5861.                       '(
  5862.                         ( Intercept 160.584956 )
  5863.                         ( Word.Token.EMPH 36.0 )
  5864.                         ( pp.tobi_accent 10.081770 (H*) )
  5865.                         ( pp.tobi_accent 3.358613 (!H*) )
  5866.                         ( pp.tobi_accent 4.144342 (*? X*? H*!H* * L+H* L+!H*) )
  5867.                         ( pp.tobi_accent -1.111794 (L*) )
  5868.                         ┬╖┬╖┬╖
  5869.                       )
  5870.  Note the feature pp.tobi_accent returns an atom, and is hence tested with the 
  5871.  map groups specified as third arguments. 
  5872.  
  5873.  Models may be built from feature data (in the same format as 'wagon' using the 
  5874.  'ols' program distributed with the speech tools library. 
  5875.  
  5876.  
  5877. ΓòÉΓòÉΓòÉ 27. Building models from databases ΓòÉΓòÉΓòÉ
  5878.  
  5879.  Because our research interests tend towards creating statistical models 
  5880.  trained from real speech data, Festival offers various support for extracting 
  5881.  information from speech databases, in a way suitable for building models. 
  5882.  
  5883.  Models for accent prediction, F0 generation, duration, vowel reduction, 
  5884.  homograph disambiguation, phrase break assignment and unit selection have been 
  5885.  built using Festival to extract and process various databases. 
  5886.  
  5887.  Labelling databases           Phones, syllables, words etc. 
  5888.  Extracting features           Extraction of model parameters. 
  5889.  Building models               Building stochastic models from features 
  5890.  
  5891.  
  5892. ΓòÉΓòÉΓòÉ 27.1. Labelling databases ΓòÉΓòÉΓòÉ
  5893.  
  5894.  In order for Festival to use a database it is most useful to build utterance 
  5895.  structures for each utterance in the database.  As discussed earlier, 
  5896.  utterance structures contain relations of items.  Given such a structure for 
  5897.  each utterance in a database we can easily read in the utterance 
  5898.  representation and access it, dumping information in a normalised way allowing 
  5899.  for easy building and testing of models. 
  5900.  
  5901.  Of course the level of labelling that exists, or that you are willing to do by 
  5902.  hand or using some automatic tool, for a particular database will vary.  For 
  5903.  many purposes you will at least need phonetic labelling. Hand labelled data is 
  5904.  still better than auto-labelled data, but that could change.  The size and 
  5905.  consistency of the data is important too. 
  5906.  
  5907.  For this discussion we will assume labels for: segments, syllables, words, 
  5908.  phrases, intonation events, pitch targets.  Some of these can be derived, some 
  5909.  need to be labelled.  This would not fail with less labelling but of course 
  5910.  you wouldn't be able to extract as much information from the result. 
  5911.  
  5912.  In our databases these labels are in Entropic's Xlabel format, though it is 
  5913.  fairly easy to convert any reasonable format. 
  5914.  
  5915.  Segment   These give phoneme labels for files.  Note the these labels must be 
  5916.            members of the phoneset that you will be using for this database. 
  5917.            Often phone label files may contain extra labels (e.g. beginning and 
  5918.            end silence) which are not really part of the phoneset.  You should 
  5919.            remove (or re-label) these phones accordingly. 
  5920.  
  5921.  Word      Again these will need to be provided.  The end of the word should 
  5922.            come at the last phone in the word (or just after).  Pauses/silences 
  5923.            should not be part of the word. 
  5924.  
  5925.  Syllable  There is a chance these can be automatically generated from Word and 
  5926.            Segment files given a lexicon.  Ideally these should include lexical 
  5927.            stress. 
  5928.  
  5929.  IntEvent  These should ideally mark accent/boundary tone type for each 
  5930.            syllable, but this almost definitely requires hand-labelling.  Also 
  5931.            given that hand-labelling of accent type is harder and not as 
  5932.            accurate, it is arguable that anything other than accented vs. 
  5933.            non-accented can be used reliably. 
  5934.  
  5935.  Phrase    This could just mark the last non-silence phone in each utterance, 
  5936.            or before any silence phones in the whole utterance. 
  5937.  
  5938.  Target    This can be automatically derived from an F0 file and the Segment 
  5939.            files. A marking of the mean F0 in each voiced phone seem to give 
  5940.            adequate results. 
  5941.  Once these files are created an utterance file can be automatically created 
  5942.  from the above data.  Note it is pretty easy to get the streams right but 
  5943.  getting the relations between the streams is much harder.  Firstly labelling 
  5944.  is rarely accurate and small windows of error must be allowed to ensure things 
  5945.  line up properly.  The second problem is that some label files identify point 
  5946.  type information (IntEvent and Target) while others identify segments (e.g. 
  5947.  Segment, Words etc.).  Relations have to know this in order to get it right. 
  5948.  For example is not right for all syllables between two IntEvents to be linked 
  5949.  to the IntEvent, only to the Syllable the IntEvent is within. 
  5950.  
  5951.  The script 'festival/examples/make_utts' is an example Festival script which 
  5952.  automatically builds the utterance files from the above labelled files. 
  5953.  
  5954.  The script, by default assumes, a hierarchy in an database directory of the 
  5955.  following form.  Under a directory 'festival/' where all festival specific 
  5956.  database ifnromation can be kept, a directory 'relations/' contains a 
  5957.  subdirectory for each basic relation (e.g. 'Segment/', 'Syllable/', etc.) 
  5958.  Each of which contains the basic label files for that relation. 
  5959.  
  5960.  The following command will build a set of utterance structures (including 
  5961.  building hte relations that link between these basic relations). 
  5962.  
  5963.                       make_utts -phoneset radio festival/relation/Segment/*.Segment
  5964.  This will create utterances in 'festival/utts/'.  There are a number of 
  5965.  options to 'make_utts' use '-h' to find them.  The '-eval' option allows extra 
  5966.  scheme code to be loaded which may be called by the utterance building 
  5967.  process. The function make_utts_user_function will be called on all utterance 
  5968.  created.  Redefining that in database specific loaded code will allow database 
  5969.  specific fixed to the utterance. 
  5970.  
  5971.  
  5972. ΓòÉΓòÉΓòÉ 27.2. Extracting features ΓòÉΓòÉΓòÉ
  5973.  
  5974.  The easiest way to extract features from a labelled database of the form 
  5975.  described in the previous section is by loading in each of the utterance 
  5976.  structures and dumping the desired features. 
  5977.  
  5978.  Using the same mechanism to extract the features as will eventually be used by 
  5979.  models built from the features has the important advantage of avoiding 
  5980.  spurious errors easily introduced when collecting data.  For example a feature 
  5981.  such as n.accent in a Festival utterance will be defined as 0 when there is no 
  5982.  next accent.  Extracting all the accents and using an external program to 
  5983.  calculate the next accent may make a different decision so that when the 
  5984.  generated model is used a different value for this feature will be produced. 
  5985.  Such mismatches in training models and actual use are unfortunately common, so 
  5986.  using the same mechanism to extract data for training, and for actual use is 
  5987.  worthwhile. 
  5988.  
  5989.  The recommedn method for extracting features is using the festival script 
  5990.  'dumpfeats'.  It basically takes a list of feature names and a list of 
  5991.  utterance files and dumps the desired features. 
  5992.  
  5993.  Features may be dumped into a single file or into separate files one for each 
  5994.  utterance.  Feature names may be specified on the command line or in a 
  5995.  separate file.  Extar code to define new features may be loaded too. 
  5996.  
  5997.  For example suppose we wanted to save the features for a set of utterances 
  5998.  include the duration, phone name, previous and next phone names for all 
  5999.  segments in each utterance. 
  6000.  
  6001.                       dumpfeats -feats "(segment_duration name p.name n.name)" \
  6002.                            -output feats/%s.dur -relation Segment \
  6003.                            festival/utts/*.utt
  6004.  This will save these features in files named for the utterances they come from 
  6005.  in the directory 'feats/'.  The argument to '-feats' is treated as literal 
  6006.  list only if it starts with a left parenthesis, otherwise it is treated as a 
  6007.  filename contain named features (unbracketed). 
  6008.  
  6009.  Extra code (for new feature definitions) may be loaded through the '-eval' 
  6010.  option.  If the argument to '-eval' starts with a left parenthesis it is 
  6011.  trated as an s-expression rather than a filename and is evaluated.  If 
  6012.  argument '-output' contains "%s" it will be filled in with the utterance's 
  6013.  filename, if it is a simple filename the features from all utterances will be 
  6014.  saved in that same file.  The features for each item in the named relation are 
  6015.  saved on a single line. 
  6016.  
  6017.  
  6018. ΓòÉΓòÉΓòÉ 27.3. Building models ΓòÉΓòÉΓòÉ
  6019.  
  6020.  This section describes how to build models from data extracted from databases 
  6021.  as described in the previous section.  It uses the CART building program, 
  6022.  'wagon' which is available in the speech tools distribution.  But the data is 
  6023.  suitable for many other types of model building techniques, such as linear 
  6024.  regression or neural networks. 
  6025.  
  6026.  Wagon is described in the speech tools manual, though we will cover simple use 
  6027.  here.  To use Wagon you need a datafile and a data description file. 
  6028.  
  6029.  A datafile consists of a number of vectors one per line each containing the 
  6030.  same number of fields.  This, not coincidentally, is exactly the format 
  6031.  produced by 'dumpfeats' described in the previous section.  The data 
  6032.  description file describes the fields in the datafile and their range.  Fields 
  6033.  may be of any of the following types: class (a list of symbols), floats, or 
  6034.  ignored.  Wagon will build a classification tree if the first field (the 
  6035.  predictee) is of type class, or a regression tree if the first field is a 
  6036.  float.  An example data description file would be 
  6037.  
  6038.                       (
  6039.                       ( duration float )
  6040.                       ( name # @ @@ a aa ai au b ch d dh e e@ ei f g h i i@ ii jh k l m n
  6041.                         ng o oi oo ou p r s sh t th u u@ uh uu v w y z zh )
  6042.                       ( n.name # @ @@ a aa ai au b ch d dh e e@ ei f g h i i@ ii jh k l m n
  6043.                         ng o oi oo ou p r s sh t th u u@ uh uu v w y z zh )
  6044.                       ( p.name # @ @@ a aa ai au b ch d dh e e@ ei f g h i i@ ii jh k l m n
  6045.                         ng o oi oo ou p r s sh t th u u@ uh uu v w y z zh )
  6046.                       ( R:SylStructure.parent.position_type 0 final initial mid single )
  6047.                       ( pos_in_syl float )
  6048.                       ( syl_initial 0 1 )
  6049.                       ( syl_final 0 1)
  6050.                       ( R:SylStructure.parent.R:Syllable.p.syl_break 0 1 3 )
  6051.                       ( R:SylStructure.parent.syl_break 0 1 3 4 )
  6052.                       ( R:SylStructure.parent.R:Syllable.n.syl_break 0 1 3 4 )
  6053.                       ( R:SylStructure.parent.R:Syllable.p.stress 0 1 )
  6054.                       ( R:SylStructure.parent.stress 0 1 )
  6055.                       ( R:SylStructure.parent.R:Syllable.n.stress 0 1 )
  6056.                       )
  6057.  The script 'speech_tools/bin/make_wagon_desc' goes some way to helping.  Given 
  6058.  a datafile and a file containing the field names, it will construct an 
  6059.  approximation of the description file.  This file should still be edited as 
  6060.  all fields are treated as of type class by 'make_wagon_desc' and you may want 
  6061.  to change them some of them to float. 
  6062.  
  6063.  The data file must be a single file, although we created a number of feature 
  6064.  files by the process described in the previous section.  From a list of file 
  6065.  ids select, say, 80% of them, as training data and cat them into a single 
  6066.  datafile.  The remaining 20% may be catted together as test data. 
  6067.  
  6068.  To build a tree use a command like 
  6069.  
  6070.                       wagon -desc DESCFILE -data TRAINFILE -test TESTFILE
  6071.  The minimum cluster size (default 50) may be reduced using the command line 
  6072.  option -stop plus a number. 
  6073.  
  6074.  Varying the features and stop size may improve the results. 
  6075.  
  6076.  Building the models and getting good figures is only one part of the process. 
  6077.  You must integrate this model into Festival if its going to be of any use.  In 
  6078.  the case of CART trees generated by Wagon, Festival supports these directly. 
  6079.  In the case of CART trees predicting zscores, or factors to modify duration 
  6080.  averages, ees can be used as is. 
  6081.  
  6082.  Note there are other options to Wagon which may help build better CART models. 
  6083.  Consult the chapter in the speech tools manual on Wagon for more information. 
  6084.  
  6085.  Other parts of the distributed system use CART trees, and linear regression 
  6086.  models that were training using the processes described in this chapter.  Some 
  6087.  other parts of the distributed system use CART trees which were written by 
  6088.  hand and may be improved by properly applying these processes. 
  6089.  
  6090.  
  6091. ΓòÉΓòÉΓòÉ 28. Programming ΓòÉΓòÉΓòÉ
  6092.  
  6093.  This chapter covers aspects of programming within the Festival environment, 
  6094.  creating new modules, and modifying existing ones. It describes basic Classes 
  6095.  available and gives some particular examples of things you may wish to add. 
  6096.  
  6097.  The source code               A walkthrough of the source code 
  6098.  Writing a new module          Example access of an utterance 
  6099.  
  6100.  
  6101. ΓòÉΓòÉΓòÉ 28.1. The source code ΓòÉΓòÉΓòÉ
  6102.  
  6103.  The ultimate authority on what happens in the system lies in the source code 
  6104.  itself.  No matter how hard we try, and how automatic we make it, the source 
  6105.  code will always be ahead of the documentation.  Thus if you are going to be 
  6106.  using Festival in a serious way, familiarity with the source is essential. 
  6107.  
  6108.  The lowest level functions are catered for in the Edinburgh Speech Tools, a 
  6109.  separate library distributed with Festival.  The Edinburgh Speech Tool Library 
  6110.  offers the basic utterance structure, waveform file access, and other various 
  6111.  useful low-level functions which we share between different speech systems in 
  6112.  our work. See Section Overview of Edinburgh Speech Tools Library Manual. 
  6113.  
  6114.  The directory structure for the Festival distribution reflects the conceptual 
  6115.  split in the code. 
  6116.  
  6117.  ./bin/    The user-level executable binaries and scripts that are part of the 
  6118.            festival system.  These are simple symbolic links to the binaries or 
  6119.            if the system is compiled with shared libraries small wrap-around 
  6120.            shell scripts that set LD_LIBRARY_PATH appropriately 
  6121.  
  6122.  ./doc/    This contains the texinfo documentation for the whole system.  The 
  6123.            'Makefile' constructs the info and/or html version as desired. Note 
  6124.            that the festival binary itself is used to generate the lists of 
  6125.            functions and variables used within the system, so must be compiled 
  6126.            and in place to generate a new version of the documentation. 
  6127.  
  6128.  ./examples/This contains various examples.  Some are explained within this 
  6129.            manual, others are there just as examples. 
  6130.  
  6131.  ./lib/    The basic Scheme parts of the system, including 'init.scm' the first 
  6132.            file loaded by festival at start-up time.  Depending on your 
  6133.            installation, this directory may also contain subdirectories 
  6134.            containing lexicons, voices and databases.  This directory and its 
  6135.            sub-directories are used by Festival at run-time. 
  6136.  
  6137.  ./lib/etc/Executables for Festival's internal use.  A subdirectory containing 
  6138.            at least the audio spooler will be automatically created (one for 
  6139.            each different architecture the system is compiled on).  Scripts are 
  6140.            added to this top level directory itself. 
  6141.  
  6142.  ./lib/voices/By default this contains the voices used by Festival including 
  6143.            their basic Scheme set up functions as well as the diphone 
  6144.            databases. 
  6145.  
  6146.  ./lib/dicts/This contains various lexicon files distributed as part of the 
  6147.            system. 
  6148.  
  6149.  ./config/ This contains the basic 'Makefile' configuration files for compiling 
  6150.            the system (run-time configuration is handled by Scheme in the 
  6151.            'lib/' directory).  The file 'config/config' created as a copy of 
  6152.            the standard 'config/config-dist' is the installation specific 
  6153.            configuration.  In most cases a simpel copy of the distribution file 
  6154.            will be sufficient. 
  6155.  
  6156.  ./src/    The main C++/C source for the system. 
  6157.  
  6158.  ./src/lib/Where the 'libFestival.a' is built. 
  6159.  
  6160.  ./src/include/Where include files shared between various parts of the system 
  6161.            live.  The file 'festival.h' provides access to most of the parts of 
  6162.            the system. 
  6163.  
  6164.  ./src/main/Contains the top level C++ files for the actual executables. This 
  6165.            is directory where the executable binary 'festival' is created. 
  6166.  
  6167.  ./src/arch/The main core of the Festival system.  At present everything is 
  6168.            held in a single sub-directory './src/arc/festival/'.  This contains 
  6169.            the basic core of the synthesis system itself.  This directory 
  6170.            contains lisp front ends to access the core utterance architecture, 
  6171.            and phonesets, basic tools like, client/server support, ngram 
  6172.            support, etc, and an audio spooler. 
  6173.  
  6174.  ./src/modules/In contrast to the 'arch/' directory this contains the non-core 
  6175.            parts of the system.  A set of basic example modules are included 
  6176.            with the standard distribution.  These are the parts that do the 
  6177.            synthesis, the other parts are just there to make module writing 
  6178.            easier. 
  6179.  
  6180.  ./src/modules/base/This contains some basic simple modules that weren't quite 
  6181.            big enough to deserve their own directory.  Most importantly it 
  6182.            includes the Initialize module called by many synthesis methods 
  6183.            which sets up an utterance structure and loads in initial values. 
  6184.            This directory also contains phrasing, part of speech, and word 
  6185.            (syllable and phone construction from words) modules. 
  6186.  
  6187.  ./src/modules/Lexicon/This is not really a module in the true sense (the Word 
  6188.            module is the main user of this).  This contains functions to 
  6189.            construct, compile, and access lexicons (entries of words, part of 
  6190.            speech and pronunciations).  This also contains a letter-to-sound 
  6191.            rule system. 
  6192.  
  6193.  ./src/modules/Intonation/This contains various intonation systems, from the 
  6194.            very simple to quite complex parameter driven intonation systems. 
  6195.  
  6196.  ./src/modules/Duration/This contains various duration prediction systems, from 
  6197.            the very simple (fixed duration) to quite complex parameter driven 
  6198.            duration systems. 
  6199.  
  6200.  ./src/modules/UniSyn/A basic diphone synthesizer system, supporting a simple 
  6201.            database format (which can be grouped into a more efficient binary 
  6202.            representation).  It is multi-lingual, and allows multiple databases 
  6203.            to be loaded at once. It offers a choice of concatenation methods 
  6204.            for diphones: residual excited LPC or PSOLA (TM) (which is not 
  6205.            distributed) 
  6206.  
  6207.  ./src/modules/Text/Various text analysis functions, particularly the tokenizer 
  6208.            and utterance segmenter (from arbitrary files).  This directory also 
  6209.            contains the support for text modes and SGML. 
  6210.  
  6211.  ./src/modules/donovan/An LPC based diphone synthesizer.  Very small and neat. 
  6212.  
  6213.  ./src/modules/rxp/The Festival/Scheme front end to An XML parser written by 
  6214.            Richard Tobin from University of Edinburgh's Language Technology 
  6215.            Group┬╖┬╖ rxp is now part of the speech tools rather than just 
  6216.            Festival. 
  6217.  
  6218.  ./src/modules/parserA simple interface the the Stochastic Context Free Grammar 
  6219.            parser in the speech tools library. 
  6220.  
  6221.  ./src/modules/diphoneAn optional module contain the previouslty used diphone 
  6222.            synthsizer. 
  6223.  
  6224.  ./src/modules/clunitsA partial implementation of a cluster unit selection 
  6225.            algorithm as described in black97c. 
  6226.  
  6227.  ./src/modules/Database rjc_synthesisThis consist of a new set of modules for 
  6228.            doing waveform synthesis.  They are inteneded to unit size 
  6229.            independent (e.g. diphone, phone, non-uniform unit).  Also 
  6230.            selection, prosodic modification, joining and signal processing are 
  6231.            separately defined.  Unfortunately this code has not really been 
  6232.            exercised enough to be considered stable to be used in the default 
  6233.            synthesis method, but those working on new synthesis techniques may 
  6234.            be interested in integration using these new modules. They may be 
  6235.            updated before the next full release of Festival. 
  6236.  
  6237.  ./src/modules/*Other optional directories may be contained here containing 
  6238.            various research modules not yet part of the standard distribution. 
  6239.            See below for descriptions of how to add modules to the basic 
  6240.            system. 
  6241.  One intended use of Festival is offer a software system where new modules may 
  6242.  be easily tested in a stable environment.  We have tried to make the addition 
  6243.  of new modules easy, without requiring complex modifications to the rest of 
  6244.  the system. 
  6245.  
  6246.  All of the basic modules should really be considered merely as example 
  6247.  modules.  Without much effort all of them could be improved. 
  6248.  
  6249.  
  6250. ΓòÉΓòÉΓòÉ 28.2. Writing a new module ΓòÉΓòÉΓòÉ
  6251.  
  6252.  This section gives a simple example of writing a new module. showing the basic 
  6253.  steps that must be done to create and add a new module that is available for 
  6254.  the rest of the system to use.  Note many things can be done solely in Scheme 
  6255.  now and really only low-level very intensive things (like waveform 
  6256.  synthesizers) need be coded in C++. 
  6257.  
  6258.  
  6259. ΓòÉΓòÉΓòÉ 28.2.1. Example 1: adding new modules ΓòÉΓòÉΓòÉ
  6260.  
  6261.  The example here is a duration module which sets durations of phones for a 
  6262.  given list of averages.  To make this example more interesting, all durations 
  6263.  in accented syllables are increased by 1.5.  Note that this is just an example 
  6264.  for the sake of one, this (and much better techniques) could easily done 
  6265.  within the system as it is at present using a hand-crafted CART tree. 
  6266.  
  6267.  Our knew module, called Duration_Simple can most easily be added to the 
  6268.  './src/Duration/' directory in a file 'simdur.cc'.  You can worry about the 
  6269.  copyright notice, but after that you'll probably need the following includes 
  6270.  
  6271.                       #include <festival.h>
  6272.  The module itself must be declared in a fixed form.  That is receiving a 
  6273.  single LISP form (an utterance) as an argument and returning that LISP form at 
  6274.  the end.  Thus our definition will start 
  6275.  
  6276.                       LISP FT_Duration_Simple(LISP utt)
  6277.                       {
  6278.  Next we need to declare an utterance structure and extract it from the LISP 
  6279.  form. We also make a few other variable declarations 
  6280.  
  6281.                         EST_Utterance *u = get_c_utt(utt);
  6282.                         EST_Item *s;
  6283.                         float end=0.0, dur;
  6284.                         LISP ph_avgs,ldur;
  6285.  We cannot list the average durations for each phone in the source code as we 
  6286.  cannot tell which phoneset we are using (or what modifications we want to make 
  6287.  to durations between speakers).  Therefore the phone and average duration 
  6288.  information is held in a Scheme variable for easy setting at run time.  To use 
  6289.  the information in our C++ domain we must get that value from the Scheme 
  6290.  domain.  This is done with the following statement. 
  6291.  
  6292.                         ph_avgs = siod_get_lval("phoneme_averages","no phoneme durations");
  6293.  The first argument to siod_get_lval is the Scheme name of a variable which has 
  6294.  been set to an assoc list of phone and average duration before this module is 
  6295.  called.  See the variable phone_durations in 'lib/mrpa_durs.scm' for the 
  6296.  format.  The second argument to siod_get_lval. is an error message to be 
  6297.  printed if the variable phone_averages is not set.  If the second argument to 
  6298.  siod_get_lval is NULL then no error is given and if the variable is unset this 
  6299.  function simply returns the Scheme value nil. 
  6300.  
  6301.  Now that we have the duration data we can go through each segment in the 
  6302.  utterance and add the duration.  The loop looks like 
  6303.  
  6304.                         for (s=u->relation("Segment")->head(); s != 0; s = next(s))
  6305.                         {
  6306.  We can lookup the average duration of the current segment name using the 
  6307.  function siod_assoc_str.  As arguments, it takes the segment name s->name() 
  6308.  and the assoc list of phones and duration. 
  6309.  
  6310.                           ldur = siod_assoc_str(s->name(),ph_avgs);
  6311.  Note the return value is actually a LISP pair (phone name and duration), or 
  6312.  nil if the phone isn't in the list.  Here we check if the segment is in the 
  6313.  list.  If it is not we print an error and set the duration to 100 ms, if it is 
  6314.  in the list the floating point number is extracted from the LISP pair. 
  6315.  
  6316.                           if (ldur == NIL)
  6317.                           {
  6318.                             cerr << " Phoneme: " << s->name() << " no duration "
  6319.                               << endl;
  6320.                             dur = 0.100;
  6321.                           }
  6322.                           else
  6323.                             dur = get_c_float(car(cdr(ldur)));
  6324.  If this phone is in an accented syllable we wish to increase its duration by a 
  6325.  factor of 1.5.  To find out if it is accented we use the feature system to 
  6326.  find the syllable this phone is part of and find out if that syllable is 
  6327.  accented. 
  6328.  
  6329.                           if (ffeature(s,"R:SylStructure.parent.accented") == 1)
  6330.                             dur *= 1.5;
  6331.  Now that we have the desired duration we increment the end duration with our 
  6332.  predicted duration for this segment and set the end of the current segment. 
  6333.  
  6334.                           end += dur;
  6335.                           s->fset("end",end);
  6336.                         }
  6337.  Finally we return the utterance from the function. 
  6338.  
  6339.  
  6340.                         return utt;
  6341.                       }
  6342.  Once a module is defined it must be declared to the system so it may be 
  6343.  called.  To do this one must call the function festival_def_utt_module which 
  6344.  takes a LISP name, the C++ function name and a documentation string describing 
  6345.  what the module does.  This will automatically be available at run-time and 
  6346.  added to the manual. The call to this function should be added to the 
  6347.  initialization function in the directory you are adding the module too.  The 
  6348.  function is called festival_DIRNAME_init().  If one doesn't exist you'll need 
  6349.  to create it. 
  6350.  
  6351.  In './src/Duration/' the function festival_Duration_init() is at the end of 
  6352.  the file 'dur_aux.cc'.  Thus we can add our new modules declaration at the end 
  6353.  of that function.  But first we must declare the C++ function in that file. 
  6354.  Thus above that function we would add 
  6355.  
  6356.                       LISP FT_Duration_Simple(LISP args);
  6357.  While at the end of the function festival_Duration_init() we would add 
  6358.  
  6359.                         festival_def_utt_module("Duration_Simple",FT_Duration_Simple,
  6360.                         "(Duration_Simple UTT)\n\
  6361.                        Label all segments with average duration ┬╖┬╖┬╖ ");
  6362.  
  6363.  In order for our new file to be compiled we must add it to the 'Makefile' in 
  6364.  that directory, to the SRCS variable. Then when we type make in './src/' our 
  6365.  new module will be properly linked in and available for use. 
  6366.  
  6367.  Of course we are not quite finished.  We still have to say when our new 
  6368.  duration module should be called.  When we set 
  6369.  
  6370.                         (Parameter.set 'Duration_Method Duration_Simple)
  6371.  for a voice it will use our new module, calls to the function utt.synth will 
  6372.  use our new duration module. 
  6373.  
  6374.  Note in earlier versions of Festival it was necessary to modify the duration 
  6375.  calling function in 'lib/duration.scm' but that is no longer necessary. 
  6376.  
  6377.  
  6378. ΓòÉΓòÉΓòÉ 28.2.2. Example 2: accessing the utterance ΓòÉΓòÉΓòÉ
  6379.  
  6380.  In this example we will make more direct use of the utterance structure, 
  6381.  showing the gory details of following relations in an utterance.  This time we 
  6382.  will create a module that will name all syllables with a concatenation of the 
  6383.  names of the segments they are related to. 
  6384.  
  6385.  As before we need the same standard includes 
  6386.  
  6387.                       #include "festival.h"
  6388.  Now the definition the function 
  6389.  
  6390.                       LISP FT_Name_Syls(LISP utt)
  6391.                       {
  6392.  As with the previous example we are called with an utterance LISP object and 
  6393.  will return the same.  The first task is to extract the utterance object from 
  6394.  the LISP object. 
  6395.  
  6396.                         EST_Utterance *u = get_c_utt(utt);
  6397.                         EST_Item *syl,*seg;
  6398.  Now for each syllable in the utterance we want to find which segments are 
  6399.  related to it. 
  6400.  
  6401.                         for (syl=u->relation("Syllable")->head(); syl != 0; syl = next(syl))
  6402.                         {
  6403.  Here we declare a variable to cummulate the names of the segments. 
  6404.  
  6405.                           EST_String sylname = "";
  6406.  Now we iterate through the SylStructure daughters of the syllable.  These will 
  6407.  be the segments in that syllable. 
  6408.  
  6409.                           for (seg=daughter1(syl,"SylStructure"); seg; seg=next(seg))
  6410.                             sylname += seg->name();
  6411.  Finally we set the syllables name to the concatenative name, and loop to the 
  6412.  next syllable. 
  6413.  
  6414.                           syl->set_name(sylname);
  6415.                         }
  6416.  Finally we return the LISP form of the utterance. 
  6417.  
  6418.                         return utt;
  6419.                       }
  6420.  
  6421.  
  6422. ΓòÉΓòÉΓòÉ 28.2.3. Example 3: adding new directories ΓòÉΓòÉΓòÉ
  6423.  
  6424.  In this example we will add a whole new subsystem.  This will often be a 
  6425.  common way for people to use Festival.  For example let us assume we wish to 
  6426.  add a formant waveform synthesizer (e.g like that in the free 'rsynth' 
  6427.  program).  In this case we will add a whole new sub-directory to the modules 
  6428.  directory.  Let us call it 'rsynth/'. 
  6429.  
  6430.  In the directory we need a 'Makefile' of the standard form so we should copy 
  6431.  one from one of the other directories, e.g. 'Intonation/'.  Standard methods 
  6432.  are used to identify the source code files in a 'Makefile' so that the '.o' 
  6433.  files are properly added to the library.  Following the other examples will 
  6434.  ensure your code is integrated properly. 
  6435.  
  6436.  We'll just skip over the bit where you extract the information from the 
  6437.  utterance structure and synthesize the waveform (see 'donovan/donovan.cc' or 
  6438.  'diphone/diphone.cc' for examples). 
  6439.  
  6440.  To get Festival to use your new module you must tell it to compile the 
  6441.  directory's contents.  This is done in 'festival/config/config'. Add the line 
  6442.  
  6443.                       ALSO_INCLUDE += rsynth
  6444.  to the end of that file (there are simialr ones mentioned).  Simply adding the 
  6445.  name of the directory here will add that as a new module and the directory 
  6446.  will be compiled. 
  6447.  
  6448.  What you must provide in your code is a function festival_DIRNAME_init() which 
  6449.  will be called at initialization time.  In this function you should call any 
  6450.  further initialization require and define and new Lisp functions you with to 
  6451.  made available to the rest of the system.  For example in the 'rsynth' case we 
  6452.  would define in some file in 'rsynth/' 
  6453.  
  6454.                       #include "festival.h"
  6455.                       static LISP utt_rtsynth(LISP utt)
  6456.                       {
  6457.                         EST_Utterance *u = get_c_utt(utt);
  6458.                         // Do format synthesis
  6459.                         return utt;
  6460.                       }
  6461.                       void festival_rsynth_init()
  6462.                       {
  6463.                         proclaim_module("rsynth");
  6464.                         festival_def_utt_module("Rsynth_Synth",utt_rsynth,
  6465.                         "(Rsynth_Synth UTT)
  6466.                         A simple formant synthesizer");
  6467.                         ┬╖┬╖┬╖
  6468.                       }
  6469.  Integration of the code in optional (and standard directories) is done by 
  6470.  automatically creating 'src/modules/init_modules.cc' for the list of standard 
  6471.  directories plus those defined as ALSO_INCLUDE. A call to a function called 
  6472.  festival_DIRNAME_init() will be made. 
  6473.  
  6474.  This mechanism is specifically designed so you can add modules to the system 
  6475.  without changing anything in the standard distribution. 
  6476.  
  6477.  
  6478. ΓòÉΓòÉΓòÉ 28.2.4. Example 4: adding new LISP objects ΓòÉΓòÉΓòÉ
  6479.  
  6480.  This third examples shows you how to add a new Object to Scheme and add 
  6481.  wraparounds to allow manipulation within the the Scheme (and C++) domain. 
  6482.  
  6483.  Like example 2 we are assuming this is done in a new directory. Suppose you 
  6484.  have a new object called Widget that can transduce a string into some other 
  6485.  string (with some optional continuous parameter.  Thus, here we create a new 
  6486.  file 'widget.cc' like this 
  6487.  
  6488.                       #include "festival.h"
  6489.                       #include "widget.h"  // definitions for the widget class
  6490.  In order to register the widgets as Lisp objects we actually need to register 
  6491.  them as EST_Val's as well.  Thus we now need 
  6492.  
  6493.                       VAL_REGISTER_CLASS(widget,Widget)
  6494.                       SIOD_REGISTER_CLASS(widget,Widget)
  6495.  The first names given to these functions should be a short mnenomic name for 
  6496.  the object that will be used in the defining of a set of access and 
  6497.  construction functions.  It of course must be unique within the whole systems. 
  6498.  The second name is the name of the object itself. 
  6499.  
  6500.  To understand its usage we can add a few simple widget maniplutation functions 
  6501.  
  6502.                       LISP widget_load(LISP filename)
  6503.                       {
  6504.                         EST_String fname = get_c_string(filename);
  6505.                         Widget *w = new Widget;  // build a new widget
  6506.                         if (w->load(fname) == 0)  // successful load
  6507.                          return siod(w);
  6508.                         else
  6509.                         {
  6510.                          cerr << "widget load: failed to load \"" << fname << "\"" << endl;
  6511.                          festival_error();
  6512.                         }
  6513.                         return NIL;  // for compilers that get confused
  6514.                       }
  6515.  Note that the function siod constructs a LISP object from a widget, the class 
  6516.  register macro defines that for you. Also note that when giving an object to a 
  6517.  LISP object it then owns the object and is responsibile for deleting it when 
  6518.  garbage collection occurs on that LISP object.  Care should be taken that you 
  6519.  don't put the same object within different LISP objects.  The macros 
  6520.  VAL_RESGISTER_CLASS_NODEL should be called if you do not want your give object 
  6521.  to be deleted by the LISP system (this may cause leaks). 
  6522.  
  6523.  If you want refer to these functions in other files within your models you can 
  6524.  use 
  6525.  
  6526.                       VAL_REGISTER_CLASS_DCLS(widget,Widget)
  6527.                       SIOD_REGISTER_CLASS_DCLS(widget,Widget)
  6528.  in a common '.h' file 
  6529.  
  6530.  The following defines a function that takes a LISP object containing a widget, 
  6531.  aplies some method and returns a string. 
  6532.  
  6533.                       LISP widget_apply(LISP lwidget, LISP string, LISP param)
  6534.                       {
  6535.                         Widget *w = widget(lwidget);
  6536.                         EST_String s = get_c_string(string);
  6537.                         float p = get_c_float(param);
  6538.                         EST_String answer;
  6539.                         answer = w->apply(s,p);
  6540.                         return strintern(answer);
  6541.                       }
  6542.   The function widget, defined by the regitration macros, takes a LISP object 
  6543.  and returns a pointer to the widget inside it.  If the LISP object does not 
  6544.  contain a widget an error will be thrown. 
  6545.  
  6546.  Finally you wish to add these functions to the Lisp system 
  6547.  
  6548.                       void festival_widget_init()
  6549.                       {
  6550.                        init_subr_1("widget.load",widget_load,
  6551.                         "(widget.load FILENAME)\n\
  6552.                        Load in widget from FILENAME.");
  6553.                        init_subr_3("widget.apply",widget_apply,
  6554.                         "(widget.apply WIDGET INPUT VAL)\n\
  6555.                        Returns widget applied to string iNPUT with float VAL.");
  6556.                       }
  6557.  
  6558.  In yout 'Makefile' for this directory you'll need to add the include directory 
  6559.  where 'widget.h' is, if it is not contained within the directory itself.  This 
  6560.  done through the make variable LOCAL_INCLUDES as 
  6561.  
  6562.                       LOCAL_INCLUDES = -I/usr/local/widget/include
  6563.  And for the linker you 'll need to identify where your widget library is.  In 
  6564.  your 'festival/config/config' file at the end add 
  6565.  
  6566.                       COMPILERLIBS += -L/usr/local/widget/lib -lwidget
  6567.  
  6568.  
  6569. ΓòÉΓòÉΓòÉ 29. API ΓòÉΓòÉΓòÉ
  6570.  
  6571.  If you wish to use Festival within some other application there are a number 
  6572.  of possible interfaces. 
  6573.  
  6574.  Scheme API                    Programming in Scheme 
  6575.  Shell API                     From Unix shell 
  6576.  Server/client API             Festival as a speech synthesis server 
  6577.  C/C++ API                     Through function calls from C++. 
  6578.  C only API                    Small independent C client access 
  6579.  Java and JSAPI                Sythesizing from Java 
  6580.  
  6581.  
  6582. ΓòÉΓòÉΓòÉ 29.1. Scheme API ΓòÉΓòÉΓòÉ
  6583.  
  6584.  Festival includes a full programming language, Scheme (a variant of Lisp) as a 
  6585.  powerful interface to its speech synthesis functions. Often this will be the 
  6586.  easiest method of controlling Festival's functionality.  Even when using other 
  6587.  API's they will ultimately depend on the Scheme interpreter. 
  6588.  
  6589.  Scheme commands (as s-expressions) may be simply written in files and 
  6590.  interpreted by Festival, either by specification as arguments on the command 
  6591.  line, in the interactive interpreter, or through standard input as a pipe. 
  6592.  Suppose we have a file 'hello.scm' containing 
  6593.  
  6594.                       ;; A short example file with Festival Scheme commands
  6595.                       (voice_rab_diphone) ;; select Gordon
  6596.                       (SayText "Hello there")
  6597.                       (voice_don_diphone) ;; select Donovan
  6598.                       (SayText "and hello from me")
  6599.  
  6600.  From the command interpreter we can execute the commands in this file by 
  6601.  loading them 
  6602.  
  6603.                       festival> (load "hello.scm")
  6604.                       nil
  6605.  Or we can execute the commands in the file directly from the shell command 
  6606.  line 
  6607.  
  6608.                       unix$ festival -b hello.scm
  6609.  The '-b' option denotes batch operation meaning the file is loaded and then 
  6610.  Festival will exit, without starting the command interpreter. Without this 
  6611.  option '-b' Festival will load 'hello.scm' and then accept commands on 
  6612.  standard input.  This can be convenient when some initial set up is required 
  6613.  for a session. 
  6614.  
  6615.  Note one disadvantage of the batch method is that time is required for 
  6616.  Festival's initialisation every time it starts up.  Although this will 
  6617.  typically only be a few seconds, for saying short individual expressions that 
  6618.  lead in time may be unacceptable.  Thus simply executing the commands within 
  6619.  an already running system is more desirable, or using the server/client mode. 
  6620.  
  6621.  Of course its not just about strings of commands, because Scheme is a fully 
  6622.  functional language, functions, loops, variables, file access, arithmetic 
  6623.  operations may all be carried out in your Scheme programs. Also, access to 
  6624.  Unix is available through the system function.  For many applications directly 
  6625.  programming them in Scheme is both the easiest and the most efficient method. 
  6626.  
  6627.  A number of example Festival scripts are included in 'examples/'. Including a 
  6628.  program for saying the time, and for telling you the latest news (by accessing 
  6629.  a page from the web).  Also see the detailed discussion of a script example in 
  6630.  See POS Example. 
  6631.  
  6632.  
  6633. ΓòÉΓòÉΓòÉ 29.2. Shell API ΓòÉΓòÉΓòÉ
  6634.  
  6635.  The simplest use of Festival (though not the most powerful) is simply using it 
  6636.  to directly render text files as speech.  Suppose we have a file 'hello.txt' 
  6637.  containing 
  6638.  
  6639.                       Hello world.  Isn't it excellent weather
  6640.                       this morning.
  6641.  We can simply call Festival as 
  6642.  
  6643.                       unix$ festival --tts hello.txt
  6644.  Or for even simpler one-off phrases 
  6645.  
  6646.                       unix$ echo "hello " | festival --tts
  6647.  This is easy to use but you will need to wait for Festival to start up and 
  6648.  initialise its databases before it starts to render the text as speech.  This 
  6649.  may take several seconds on some machines.  A socket based server mechanism is 
  6650.  provided in Festival which will allow a single server process to start up once 
  6651.  and be used efficiently by multiple client programs. 
  6652.  
  6653.  Note also the use of Sable for marked up text, see XML/SGML mark-up. Sable 
  6654.  allows various forms of additional information in text, such as phrasing, 
  6655.  emphasis, pronunciation, as well as changing voices, and inclusion of external 
  6656.  waveform files (i.e. random noises).  For many application this will be the 
  6657.  preferred interface method.  Other text modes too are available through the 
  6658.  command line by using auto-text-mode-alist. 
  6659.  
  6660.  
  6661. ΓòÉΓòÉΓòÉ 29.3. Server/client API ΓòÉΓòÉΓòÉ
  6662.  
  6663.  Festival offers a BSD socket-based interface.  This allows Festival to run as 
  6664.  a server and allow client programs to access it.  Basically the server offers 
  6665.  a new command interpreter for each client that attaches to it.  The server is 
  6666.  forked for each client but this is much faster than having to wait for a 
  6667.  Festival process to start from scratch.  Also the server can run on a bigger 
  6668.  machine, offering much faster synthesis. 
  6669.  
  6670.  Note: the Festival server is inherently insecure and may allow arbitrary users 
  6671.  access to your machine. 
  6672.  
  6673.  Every effort has been made to minimise the risk of unauthorised access through 
  6674.  Festival and a number of levels of security are provided. However with any 
  6675.  program offering socket access, like httpd, sendmail or ftpd there is a risk 
  6676.  that unauthorised access is possible.  I trust Festival's security enough to 
  6677.  often run it on my own machine and departmental servers, restricting access to 
  6678.  within our department.  Please read the information below before using the 
  6679.  Festival server so you understand the risks. 
  6680.  
  6681.  
  6682. ΓòÉΓòÉΓòÉ 29.3.1. Server access control ΓòÉΓòÉΓòÉ
  6683.  
  6684.  The following access control is available for Festival when running as a 
  6685.  server.  When the server starts it will usually start by loading in various 
  6686.  commands specific for the task it is to be used for.  The following variables 
  6687.  are used to control access. 
  6688.  
  6689.  server_port A number identifying the inet socket port.  By default this is 
  6690.            1314.  It may be changed as required. 
  6691.  
  6692.  server_log_fileIf nil no logging takes place, if t logging is printed to 
  6693.            standard out and if a file name log messages are appended to that 
  6694.            file. All connections and attempted connections are logged with a 
  6695.            time stamp and the name of the client.  All commands sent from the 
  6696.            client are also logged (output and data input is not logged). 
  6697.  
  6698.  server_deny_listIf non-nil it is used to identify which machines are not 
  6699.            allowed access to the server.  This is a list of regular 
  6700.            expressions. If the host name of the client matches any of the 
  6701.            regexs in this list the client is denied access.  This overrides all 
  6702.            other access methods.  Remember that sometimes hosts are identified 
  6703.            as numbers not as names. 
  6704.  
  6705.  server_access_listIf this is non-nil only machines whose names match at least 
  6706.            one of the regexs in this list may connect as clients.  Remember 
  6707.            that sometimes hosts are identified as numbers not as names, so you 
  6708.            should probably exclude the IP number of machine as well as its name 
  6709.            to be properly secure. 
  6710.  
  6711.  server_passwdIf this is non-nil, the client must send this passwd to the 
  6712.            server followed by a newline before access is given.  This is 
  6713.            required even if the machine is included in the access list.  This 
  6714.            is designed so servers for specific tasks may be set up with 
  6715.            reasonable security. 
  6716.  
  6717.  (set_server_safe_functions FUNCNAMELIST)If called this can restrict which 
  6718.            functions the client may call.  This is the most restrictive form of 
  6719.            access, and thoroughly recommended.  In this mode it would be normal 
  6720.            to include only the specific functions the client can execute (i.e. 
  6721.            the function to set up output, and a tts function).  For example a 
  6722.            server could call the following at set up time, thus restricting 
  6723.            calls to only those that 'festival_client' --ttw uses. 
  6724.  
  6725.                       (set_server_safe_functions
  6726.                           '(tts_return_to_client tts_text tts_textall Parameter.set))
  6727.  
  6728.  Its is strongly recommend that you run Festival in server mode as userid 
  6729.  nobody to limit the access the process will have, also running it in a chroot 
  6730.  environment is more secure. 
  6731.  
  6732.  For example suppose we wish to allow access to all machines in the CSTR domain 
  6733.  except for holmes.cstr.ed.ac.uk and adam.cstr.ed.ac.uk.  This may be done by 
  6734.  the following two commands 
  6735.  
  6736.                       (set! server_deny_list '("holmes\\.cstr\\.ed\\.ac\\.uk"
  6737.                                    "adam\\.cstr\\.ed\\.ac\\.uk"))
  6738.                       (set! server_access_list '("[^\\.]*\\.cstr\\.ed\\.ac\\.uk"))
  6739.  This is not complete though as when DNS is not working holmes and adam will 
  6740.  still be able to access the server (but if our DNS isn't working we probably 
  6741.  have more serious problems).  However the above is secure in that only 
  6742.  machines in the domain cstr.ed.ac.uk can access the server, though there may 
  6743.  be ways to fix machines to identify themselves as being in that domain even 
  6744.  when they are not. 
  6745.  
  6746.  By default Festival in server mode will only accept client connections for 
  6747.  localhost. 
  6748.  
  6749.  
  6750. ΓòÉΓòÉΓòÉ 29.3.2. Client control ΓòÉΓòÉΓòÉ
  6751.  
  6752.  An example client program called 'festival_client' is included with the system 
  6753.  that provides a wide range of access methods to the server.  A number of 
  6754.  options for the client are offered. 
  6755.  
  6756.  --server  The name (or IP number) of the server host.  By default this is 
  6757.            'localhost' (i.e. the same machine you run the client on). 
  6758.  
  6759.  --port    The port number the Festival server is running on.  By default this 
  6760.            is 1314. 
  6761.  
  6762.  --output FILENAMEIf a waveform is to be synchronously returned, it will be 
  6763.            saved in FILENAME.  The --ttw option uses this as does the use of 
  6764.            the Festival command utt.send.wave.client.  If an output waveform 
  6765.            file is received by 'festival_client' and no output file has been 
  6766.            given the waveform is discarded with an error message. 
  6767.  
  6768.  --passwd PASSWDIf a passwd is required by the server this should be stated on 
  6769.            the client call.  PASSWD is sent plus a newline before any other 
  6770.            communication takes places.  If this isn't specified and a passwd is 
  6771.            required, you must enter that first, if the --ttw option is used, a 
  6772.            passwd is required and none specified access will be denied. 
  6773.  
  6774.  --prolog FILEFILE is assumed to be contain Festival commands and its contents 
  6775.            are sent to the server after the passwd but before anything else. 
  6776.            This is convenient to use in conjunction with --ttw which otherwise 
  6777.            does not offer any way to send commands as well as the text to the 
  6778.            server. 
  6779.  
  6780.  --otype OUTPUTTYPEIf an output waveform file is to be used this specified the 
  6781.            output type of the file.  The default is nist, but, ulaw, riff, ulaw 
  6782.            and others as supported by the Edinburgh Speech Tools Library are 
  6783.            valid.  You may use raw too but note that Festival may return 
  6784.            waveforms of various sampling rates depending on the sample rates of 
  6785.            the databases its using.  You can of course make Festival only 
  6786.            return one particular sample rate, by using after_synth_hooks.  Note 
  6787.            that byte order will be native machine of the client machine if the 
  6788.            output format allows it. 
  6789.  
  6790.  --ttw     Text to wave is an attempt to make festival_client useful in many 
  6791.            simple applications.  Although you can connect to the server and 
  6792.            send arbitrary Festival Scheme commands, this option automatically 
  6793.            does what is probably what you want most often.  When specified this 
  6794.            options takes text from the specified file (or stdin), synthesizes 
  6795.            it (in one go) and saves it in the specified output file.  It 
  6796.            basically does the following 
  6797.  
  6798.                       (Parameter.set 'Wavefiletype '<output type>)
  6799.                       (tts_textall "
  6800.                       <file/stdin contents>
  6801.                       ")))
  6802.  Note that this is best used for small, single utterance texts as you have to 
  6803.  wait for the whole text to be synthesized before it is returned. 
  6804.  
  6805.  --aucommand COMMANDExecute COMMAND of each waveform returned by the server. 
  6806.            The variable FILE will be set when COMMAND is executed. 
  6807.  
  6808.  --async   So that the delay between the text being sent and the first sound 
  6809.            being available to play, this option in conjunction with --ttw 
  6810.            causes the text to be synthesized utterance by utterance and be sent 
  6811.            back in separated waveforms.  Using --aucommand each waveform my be 
  6812.            played locally, and when 'festival_client' is interrupted the sound 
  6813.            will stop.  Getting the client to connect to an audio server 
  6814.            elsewhere means the sound will not necessarily stop when the 
  6815.            'festival_client' process is stopped. 
  6816.  
  6817.  --withlispWith each command being sent to Festival a Lisp return value is 
  6818.            sent, also Lisp expressions may be sent from the server to the 
  6819.            client through the command send_client.  If this option is specified 
  6820.            the Lisp expressions are printed to standard out, otherwise this 
  6821.            information is discarded. 
  6822.  
  6823.  A typical example use of 'festival_client' is 
  6824.  
  6825.                       festival_client --async --ttw --aucommand 'na_play $FILE' fred.txt
  6826.  This will use 'na_play' to play each waveform generated for the utterances in 
  6827.  'fred.txt'.  Note the single quotes so that the $ in $FILE isn't expanded 
  6828.  locally. 
  6829.  
  6830.  Note the server must be running before you can talk to it.  At present 
  6831.  Festival is not set up for automatic invocations through 'inetd' and 
  6832.  '/etc/services'.  If you do that yourself, note that it is a different type of 
  6833.  interface as 'inetd' assumes all communication goes through standard in/out. 
  6834.  
  6835.  Also note that each connection to the server starts a new session. Variables 
  6836.  are not persistent over multiple calls to the server so if any initialization 
  6837.  is required (e.g. loading of voices) it must be done each time the client 
  6838.  starts or more reasonably in the server when it is started. 
  6839.  
  6840.  A PERL festival client is also available in 
  6841.  'festival/examples/festival_client.pl' 
  6842.  
  6843.  
  6844. ΓòÉΓòÉΓòÉ 29.4. C/C++ API ΓòÉΓòÉΓòÉ
  6845.  
  6846.  As well as offerening an interface through Scheme and the shell some users may 
  6847.  also wish to embedd Festival within their own C++ programs. A number of simply 
  6848.  to use high level functions are available for such uses. 
  6849.  
  6850.  In order to use Festival you must include 'festival/src/include/festival.h' 
  6851.  which in turn will include the necessary other include files in 
  6852.  'festival/src/include' and 'speech_tools/include' you should ensure these are 
  6853.  included in the include path for you your program.  Also you will need to link 
  6854.  your program with 'festival/src/lib/libFestival.a', 
  6855.  'speech_tools/lib/libestools.a', 'speech_tools/lib/libestbase.a' and 
  6856.  'speech_tools/lib/libeststring.a' as well as any other optional libraries such 
  6857.  as net audio. 
  6858.  
  6859.  The main external functions available for C++ users of Festival are. 
  6860.  
  6861.  void festival_initialize(int load_init_files,int heapsize); This must be 
  6862.            called before any other festival functions may be called. It sets up 
  6863.            the synthesizer system.  The first argument if true, causes the 
  6864.            system set up files to be loaded (which is normallly what is 
  6865.            necessary), the second argument is the initial size of the Scheme 
  6866.            heap, this should normally be 210000 unless you envisage processing 
  6867.            very large Lisp structures. 
  6868.  
  6869.  int festival_say_file(const EST_String &filename);Say the contents of the 
  6870.            given file.  Returns TRUE or FALSE depending on where this was 
  6871.            successful. 
  6872.  
  6873.  int festival_say_text(const EST_String &text);Say the contents of the given 
  6874.            string.  Returns TRUE or FALSE depending on where this was 
  6875.            successful. 
  6876.  
  6877.  int festival_load_file(const EST_String &filename);Load the contents of the 
  6878.            given file and evaluate its contents as Lisp commands.  Returns TRUE 
  6879.            or FALSE depending on where this was successful. 
  6880.  
  6881.  int festival_eval_command(const EST_String &expr);Read the given string as a 
  6882.            Lisp command and evaluate it.  Returns TRUE or FALSE depending on 
  6883.            where this was successful. 
  6884.  
  6885.  int festival_text_to_wave(const EST_String &text,EST_Wave &wave);Synthesize 
  6886.            the given string into the given wave.  Returns TRUE or FALSE 
  6887.            depending on where this was successful. 
  6888.  Many other commands are also available but often the above will be sufficient. 
  6889.  
  6890.  Below is a simple top level program that uses the Festival functions 
  6891.  
  6892.                       int main(int argc, char **argv)
  6893.                       {
  6894.                         EST_Wave wave;
  6895.                         int heap_size = 210000;  // default scheme heap size
  6896.                         int load_init_files = 1; // we want the festival init files loaded
  6897.                         festival_initialize(load_init_files,heap_size);
  6898.                         // Say simple file
  6899.                         festival_say_file("/etc/motd");
  6900.                         festival_eval_command("(voice_ked_diphone)");
  6901.                         // Say some text;
  6902.                         festival_say_text("hello world");
  6903.                         // Convert to a waveform
  6904.                         festival_text_to_wave("hello world",wave);
  6905.                         wave.save("/tmp/wave.wav","riff");
  6906.                         // festival_say_file puts the system in async mode so we better
  6907.                         // wait for the spooler to reach the last waveform before exiting
  6908.                         // This isn't necessary if only festival_say_text is being used (and
  6909.                         // your own wave playing stuff)
  6910.                         festival_wait_for_spooler();
  6911.                         return 0;
  6912.                       }
  6913.  
  6914.  
  6915. ΓòÉΓòÉΓòÉ 29.5. C only API ΓòÉΓòÉΓòÉ
  6916.  
  6917.  A simpler C only interface example is given inf 
  6918.  'festival/examples/festival_client.c'.  That interface talks to a festival 
  6919.  server.  The code does not require linking with any other EST or Festival code 
  6920.  so is much smaller and easier to include in other programs.  The code is 
  6921.  missing some functionality but not much consider how much smaller it is. 
  6922.  
  6923.  
  6924. ΓòÉΓòÉΓòÉ 29.6. Java and JSAPI ΓòÉΓòÉΓòÉ
  6925.  
  6926.  Initial support for talking to a Festival server from java is included from 
  6927.  version 1.3.0 and initial JSAPI support is included from 1.4.0. At present the 
  6928.  JSAPI talks to a Festival server elsewhere rather than as part of the Java 
  6929.  process itself. 
  6930.  
  6931.  A simple (Pure) Java festival client is given 
  6932.  'festival/src/modules/java/cstr/festival/Client.java' with a wraparound script 
  6933.  in 'festival/bin/festival_client_java'. 
  6934.  
  6935.  See the file 'festival/src/modules/java/cstr/festival/jsapi/ReadMe' for 
  6936.  requirements and a small example of using the JSAPI interface. 
  6937.  
  6938.  
  6939. ΓòÉΓòÉΓòÉ 30. Examples ΓòÉΓòÉΓòÉ
  6940.  
  6941.  This chapter contains some simple walkthrough examples of using Festival in 
  6942.  various ways, not just as speech synthesizer 
  6943.  
  6944.  POS Example                   Using Festival as a part of speech tagger 
  6945.  
  6946.  
  6947. ΓòÉΓòÉΓòÉ 30.1. POS Example ΓòÉΓòÉΓòÉ
  6948.  
  6949.  This example shows how we can use part of the standard synthesis process to 
  6950.  tokenize and tag a file of text.  This section does not cover training and 
  6951.  setting up a part of speech tag set (See POS tagging), only how to go about 
  6952.  using the standard POS tagger on text. 
  6953.  
  6954.  This example also shows how to use Festival as a simple scripting language, 
  6955.  and how to modify various methods used during text to speech. 
  6956.  
  6957.  The file 'examples/text2pos' contains an executable shell script which will 
  6958.  read arbitrary ascii text from standard input and produce words and their part 
  6959.  of speech (one per line) on standard output. 
  6960.  
  6961.  A Festival script, like any other UNIX script, it must start with the the 
  6962.  characters #! followed by the name of the 'festival' executable.  For scripts 
  6963.  the option -script is also required.  Thus our first line looks like 
  6964.  
  6965.                       #!/usr/local/bin/festival -script
  6966.  Note that the pathname may need to be different on your system 
  6967.  
  6968.  Following this we have copious comments, to keep our lawyers happy, before we 
  6969.  get into the real script. 
  6970.  
  6971.  The basic idea we use is that the tts process segments text into utterances, 
  6972.  those utterances are then passed to a list of functions, as defined by the 
  6973.  Scheme variable tts_hooks.  Normally this variable contains a list of two 
  6974.  function, utt.synth and utt.play which will synthesize and play the resulting 
  6975.  waveform.  In this case, instead, we wish to predict the part of speech value, 
  6976.  and then print it out. 
  6977.  
  6978.  The first function we define basically replaces the normal synthesis function 
  6979.  utt.synth.  It runs the standard festival utterance modules used in the 
  6980.  synthesis process, up to the point where POS is predicted. This function looks 
  6981.  like 
  6982.  
  6983.                       (define (find-pos utt)
  6984.                       "Main function for processing TTS utterances.  Predicts POS and
  6985.                       prints words with their POS"
  6986.                        (Token utt)
  6987.                        (POS utt)
  6988.                       )
  6989.  The normal text-to-speech process first tokenizes the text splitting it in to 
  6990.  ``sentences''.  The utterance type of these is Token.  Then we call the Token 
  6991.  utterance module, which converts the tokens to a stream of words.  Then we 
  6992.  call the POS module to predict part of speech tags for each word.  Normally we 
  6993.  would call other modules ultimately generating a waveform but in this case we 
  6994.  need no further processing. 
  6995.  
  6996.  The second function we define is one that will print out the words and parts 
  6997.  of speech 
  6998.  
  6999.                       (define (output-pos utt)
  7000.                       "Output the word/pos for each word in utt"
  7001.                        (mapcar
  7002.                        (lambda (pair)
  7003.                         (format t "%l/%l\n" (car pair) (car (cdr pair))))
  7004.                        (utt.features utt 'Word '(name pos))))
  7005.  This uses the utt.features function to extract features from the items in a 
  7006.  named stream of an utterance.  In this case we want the name and pos features 
  7007.  for each item in the Word stream.  Then for each pair we print out the word's 
  7008.  name, a slash and its part of speech followed by a newline. 
  7009.  
  7010.  Our next job is to redefine the functions to be called during text to speech. 
  7011.  The variable tts_hooks is defined in 'lib/tts.scm'.  Here we set it to our two 
  7012.  newly-defined functions 
  7013.  
  7014.                       (set! tts_hooks (list find-pos output-pos))
  7015.  So that garbage collection messages do not appear on the screen we stop the 
  7016.  message from being outputted by the following command 
  7017.  
  7018.                       (gc-status nil)
  7019.  The final stage is to start the tts process running on standard input. 
  7020.  Because we have redefined what functions are to be run on the utterances, it 
  7021.  will no longer generate speech but just predict part of speech and print it to 
  7022.  standard output. 
  7023.  
  7024.                       (tts_file "-")
  7025.  
  7026.  
  7027. ΓòÉΓòÉΓòÉ 31. Problems ΓòÉΓòÉΓòÉ
  7028.  
  7029.  There will be many problems with Festival, both in installation and running 
  7030.  it.  It is a young system and there is a lot to it. We believe the basic 
  7031.  design is sound and problems will be features that are missing or incomplete 
  7032.  rather than fundamental ones. 
  7033.  
  7034.  We are always open to suggestions on how to improve it and fix problems, we 
  7035.  don't guarantee we'll have the time to fix problems but we are interested in 
  7036.  hearing what problems you have. 
  7037.  
  7038.  Before you smother us with mail here is an incomplete list of general problems 
  7039.  we have already identified 
  7040.  
  7041.      The more documentation we write the more we realize how much more 
  7042.       documentation is required.  Most of the Festival documentation was 
  7043.       written by someone who knows the system very well, and makes many English 
  7044.       mistakes.  A good re-write by some one else would be a good start. 
  7045.  
  7046.      The system is far too slow.  Although machines are getting faster, it 
  7047.       still takes too long to start the system and get it to speak some given 
  7048.       text.  Even so, on reasonable machines, Festival can generate the speech 
  7049.       several times faster than it takes to say it.  But even if it is five 
  7050.       time faster, it will take 2 seconds to generate a 10 second utterance.  A 
  7051.       2 second wait is too long.  Faster machines would improve this but a 
  7052.       change in design is a better solution. 
  7053.  
  7054.      The system is too big.  It takes a long time to compile even on quite 
  7055.       large machines, and its foot print is still in the 10s of megabytes as is 
  7056.       the run-time requirement.  Although we have spent some time trying to fix 
  7057.       this (optional modules have made the possibility of building a much 
  7058.       smaller binary) we haven't done enough yet. 
  7059.  
  7060.      The signal quality of the voices isn't very good by today's standard of 
  7061.       synthesizers, even given the improvement quality since the last release. 
  7062.       This is partly our fault in not spending the time (or perhaps also not 
  7063.       having enough expertise) on the low-level waveform synthesis parts of the 
  7064.       system.  This will improve in the future with better signal processing 
  7065.       (under development) and better synthesis techniques (also under 
  7066.       development). 
  7067.  
  7068.  
  7069. ΓòÉΓòÉΓòÉ 32. References ΓòÉΓòÉΓòÉ
  7070.  
  7071.  allen87   Allen J., Hunnicut S. and Klatt, D. Text-to-speech: the MITalk 
  7072.            system, Cambridge University Press, 1987. 
  7073.  
  7074.  abelson85 Abelson H. and Sussman G. Structure and Interpretation of Computer 
  7075.            Programs, MIT Press, 1985. 
  7076.  
  7077.  black94   Black A. and Taylor, P. "CHATR: a generic speech synthesis system.", 
  7078.            Proceedings of COLING-94, Kyoto, Japan 1994. 
  7079.  
  7080.  black96   Black, A. and Hunt, A. "Generating F0 contours from ToBI labels 
  7081.            using linear regression", ICSLP96, vol. 3, pp 1385-1388, 
  7082.            Philadelphia, PA. 1996. 
  7083.  
  7084.  black97b  Black, A, and Taylor, P. "Assigning Phrase Breaks from 
  7085.            Part-of-Speech Sequences", Eurospeech97, Rhodes, Greece, 1997. 
  7086.  
  7087.  black97c  Black, A, and Taylor, P. "Automatically clustering similar units for 
  7088.            unit selection in speech synthesis", Eurospeech97, Rhodes, Greece, 
  7089.            1997. 
  7090.  
  7091.  black98   Black, A., Lenzo, K. and Pagel, V., "Issues in building general 
  7092.            letter to sound rules.", 3rd ESCA Workshop on Speech Synthesis, 
  7093.            Jenolan Caves, Australia, 1998. 
  7094.  
  7095.  black99   Black, A., and Lenzo, K., "Building Voices in the Festival Speech 
  7096.            Synthesis System," unpublished document, Carnegie Mellon University, 
  7097.            available at 
  7098.            http://www.cstr.ed.ac.uk/projects/festival/docs/festvox/ 
  7099.  
  7100.  breiman84 Breiman, L., Friedman, J. Olshen, R. and Stone, C. Classification 
  7101.            and regression trees, Wadsworth and Brooks, Pacific Grove, CA. 1984. 
  7102.  
  7103.  campbell91Campbell, N. and Isard, S. "Segment durations in a syllable frame", 
  7104.            Journal of Phonetics, 19:1 37-47, 1991. 
  7105.  
  7106.  DeRose88  DeRose, S. "Grammatical category disambiguation by statistical 
  7107.            optimization". Computational Linguistics, 14:31-39, 1988. 
  7108.  
  7109.  dusterhoff97Dusterhoff, K. and Black, A. "Generating F0 contours for speech 
  7110.            synthesis using the Tilt intonation theory" Proceedings of ESCA 
  7111.            Workshop of Intonation, September, Athens, Greece. 1997 
  7112.  
  7113.  dutoit97  Dutoit, T. An introduction to Text-to-Speech Synthesis Kluwer 
  7114.            Acedemic Publishers, 1997. 
  7115.  
  7116.  hunt89    Hunt, M., Zwierynski, D. and Carr, R. "Issues in high quality LPC 
  7117.            analysis and synthesis", Eurospeech89, vol. 2, pp 348-351, Paris, 
  7118.            France. 1989. 
  7119.  
  7120.  jilka96   Jilka M. Regelbasierte Generierung natuerlich klingender Intonation 
  7121.            des Amerikanischen Englisch, Magisterarbeit, Institute of Natural 
  7122.            Language Processing, University of Stuttgart. 1996 
  7123.  
  7124.  moulines90Moulines, E, and Charpentier, N. "Pitch-synchronous waveform 
  7125.            processing techniques for text-to-speech synthesis using diphones" 
  7126.            Speech Communication, 9(5/6) pp 453-467. 1990. 
  7127.  
  7128.  pagel98,  Pagel, V., Lenzo, K., and Black, A. "Letter to Sound Rules for 
  7129.            Accented Lexicon Compression", ICSLP98, Sydney, Australia, 1998. 
  7130.  
  7131.  ritchie92 Ritchie G, Russell G, Black A and Pulman S. Computational 
  7132.            Morphology: practical mechanisms for the English Lexicon, MIT Press, 
  7133.            Cambridge, Mass. 
  7134.  
  7135.  vansanten96van Santen, J., Sproat, R., Olive, J. and Hirschberg, J. eds, 
  7136.            "Progress in Speech Synthesis," Springer Verlag, 1996. 
  7137.  
  7138.  silverman92Silverman K., Beckman M., Pitrelli, J., Ostendorf, M., Wightman, 
  7139.            C., Price, P., Pierrehumbert, J., and Hirschberg, J "ToBI: a 
  7140.            standard for labelling English prosody."  Proceedings of ICSLP92 vol 
  7141.            2. pp 867-870, 1992 
  7142.  
  7143.  sproat97  Sproat, R., Taylor, P, Tanenblatt, M. and Isard, A. "A Markup 
  7144.            Language for Text-to-Speech Synthesis", Eurospeech97, Rhodes, 
  7145.            Greece, 1997. 
  7146.  
  7147.  sproat98, Sproat, R. eds, "Multilingual Text-to-Speech Synthesis: The Bell 
  7148.            Labs approach", Kluwer 1998. 
  7149.  
  7150.  sable98,  Sproat, R., Hunt, A., Ostendorf, M., Taylor, P., Black, A., Lenzo, 
  7151.            K., and Edgington, M. "SABLE: A standard for TTS markup." ICSLP98, 
  7152.            Sydney, Australia, 1998. 
  7153.  
  7154.  taylor91  Taylor P., Nairn I., Sutherland A. and Jack M┬╖┬╖ "A real time speech 
  7155.            synthesis system", Eurospeech91, vol. 1, pp 341-344, Genoa, Italy. 
  7156.            1991. 
  7157.  
  7158.  taylor96  Taylor P. and Isard, A. "SSML: A speech synthesis markup language" 
  7159.            to appear in Speech Communications. 
  7160.  
  7161.  wwwxml97  World Wide Web Consortium Working Draft "Extensible Markup Language 
  7162.            (XML)Version 1.0 Part 1: Syntax", 
  7163.            http://www.w3.org/pub/WWW/TR/WD-xml-lang-970630.html 
  7164.  
  7165.  yarowsky96Yarowsky, D., "Homograph disambiguation in text-to-speech 
  7166.            synthesis", in "Progress in Speech Synthesis," eds. van Santen, J., 
  7167.            Sproat, R., Olive, J. and Hirschberg, J. pp 157-172. Springer 
  7168.            Verlag, 1996. 
  7169.  
  7170.  
  7171. ΓòÉΓòÉΓòÉ 33. Feature functions ΓòÉΓòÉΓòÉ
  7172.  
  7173.  This chapter contains a list of a basic feature functions available for stream 
  7174.  items in utterances.  See Features.  These are the basic features, which can 
  7175.  be combined with relative features (such as n. for next, and relations to 
  7176.  follow links).  Some of these features are implemented as short C++ functions 
  7177.  (e.g. asyl_in) while others are simple features on an item (e.g. pos).  Note 
  7178.  that functional feature take precidence over simple features, so accessing and 
  7179.  feature called "X" will always use the function called "X" even if a the 
  7180.  simple feature call "X" exists on the item. 
  7181.  
  7182.  Unlike previous versions there are no features that are builtin on all items 
  7183.  except addr (reintroduced in 1.3.1) which returns a unique string for that 
  7184.  item (its the hex address on teh item within the machine).  Features may be 
  7185.  defined through Scheme too, these all have the prefix lisp_. 
  7186.  
  7187.  The feature functions are listed in the form Relation.name where Relation is 
  7188.  the name of the stream that the function is appropriate to and name is its 
  7189.  name.  Note that you will not require the Relation part of the name if the 
  7190.  stream item you are applying the function to is of that type.