Building Synthetic Voices | ||
---|---|---|
<<< Previous | Next >>> |
This chapter acts as a reference guide for the particular dialect of the Scheme programming language used in the Festival Speech Synthesis systems. The Scheme programming language is a dialect of Lisp designed to be more consistent. It was chosen for the basic scripting language in Festival because:
it is a very easy language for machines to parse and interpret, thus the foot print for the interpreter proper is very small
it offers garbage collection making managing objects safe and easy.
it offers a general consistent datastructure for representing parameters, rules etc.
it was familiar to the authors
its is suitable for use as an embedded system
The actual interpreter used in Festival is based on George Carret's SIOD, "Scheme in one Defun". But this has been substantially enhanced from its small elegant beginnings into something that might be better called "Scheme in one directory". Although there is a standard for Scheme the version in Festival does not fully follow it, for both good and bad reasons. Thus finding in order for people to be able to program in Festival's Scheme we provide this chapter to list the core type, functions, etc and some examples. We do not pretend to be teaching programming here but as we know many people who are interested in building voices are not primarily programmers, some guidance on the language and its usage will make the simple programming that is required in building voices, more accessible.
For reference the Scheme Revised Revised Revised report describes the standard definition [srrrr90]. For a good introduction to programming in general that happens to use Scheme as its example language we recommend [abelson85]. Also for those who are unfamiliar with the use of Lisp-like scripting languages we recommend a close look as GNU Emacs which uses Lisp as its underlying scripting language, knowledge of the internals of Emacs did to some extent influence the scripting language design of Festival.
"Lots of brackets" is what comes to most people's minds when considering Lisp and its various derivatives such as Scheme. At the start this can seem daunting and it is true that parenthesis errors can cuase problems. But with an editor that does proper bracket matching, brackets can actually be helpful in code structure rather than a hindrance.
The fundamental structure is the s-expression. It consists of an atom, or a list of s-expressions. This simply defined recursive structure allows complex structures to easily be specified. For example
Unlike other programming languages Scheme's data and code are in the same format, s-expressions. Thus s-expression are evaluated, recursively.3
(1 2 3)
(a (b c) d)
((a b) (d e))
are treated as variables and evaluated return their currently set value.
evalutate to themselves.
The each member of the list is evaluated and the first item in the list is treated as a function and applied using the remainer of the list as arguments to the function.
when evaluated will return 3 as the symbol + is bound to a function that adds it arguments.(+ 1 2)
Variables may be set using the set! function which takes a variable name and a value as arguments
The set! function is unusual in that it does not evaluate its first argument. If it did you have to explcitly quote it or set some other variable to have a value of a to get the desired effect.(set! a 3)
quoting, define
<<< Previous | Home | Next >>> |
Festival Details | Data Types |