Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37509510
en ru br
ALT Linux repos
S:2.5-alt0.4
5.0: 1.96-alt6
4.1: 1.96-alt5.M41.1
4.0: 1.96-alt2.6
3.0:
+backports:1.96-alt0.M30.1

Other repositories
Upstream:1.96-beta

Group :: Sound
RPM: festival

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: 09-usability-language-detection.diff
Download


Description: Provide a general method for adding additional languages
 in festival. This general method in this patch was written by Sergio 
 Oller and merged with earlier patches of lib_languages.scm and 
 russianpatch.diff. The russianpatch.diff was written by Sergey 
 B Kirpichev. The merging was performed by Peter Drysdale.
 .
 This patch provides a proclaim_language function able to detect which
 voices are installed for each language, enabling festival to load only
 installed voices, closing  #732083.
Author: Sergio Oller <sergioller@gmail.com>, Sergey B Kirpichev,
.       Peter Drysdale
Forwarded: Yes
Last-Update: 2013-12-29
--- a/src/main/festival_main.cc
+++ b/src/main/festival_main.cc
@@ -103,7 +103,7 @@
 	"              are printed (default if stdin not a tty)\n"+
 	"--language <string>\n"+
         "              Run in named language, default is\n"+
-	"              english, spanish and welsh are available\n"+
+	"              english, spanish, russian, welsh and others are available\n"+
 	"--server      Run in server mode waiting for clients\n"+
 	"              of server_port (1314)\n"+
 	"--script <ifile>\n"+
--- a/lib/languages.scm
+++ b/lib/languages.scm
@@ -2,7 +2,7 @@
 ;;;                                                                       ;;
 ;;;                Centre for Speech Technology Research                  ;;
 ;;;                     University of Edinburgh, UK                       ;;
-;;;                       Copyright (c) 1996,1997                         ;;
+;;;                       Copyright (c) 1996,2010                         ;;
 ;;;                        All Rights Reserved.                           ;;
 ;;;                                                                       ;;
 ;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
@@ -31,90 +31,224 @@
 ;;;                                                                       ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
+;;;               Author: Sergio Oller
+;;;                 Date: January 2010 
 ;;;  Specification of voices and some major choices of synthesis
 ;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
-;;;  This should use some sort of database description for voices so
-;;;  new voices will become automatically available.
+;;;     Language definitions, now it works similar to voice definitions.
 ;;;
 
-(define (language_british_english)
-"(language_british_english)
-Set up language parameters for British English."
-  (require 'voices)
-  ;;  Will get more elaborate, with different choices of voices in language
-
-  (set! male1 voice_rab_diphone)
-  (set! male2 voice_don_diphone)
-  (if (symbol-bound? 'voice_gsw_diphone)
-      (set! male3 voice_gsw_diphone))
-  (if (symbol-bound? 'voice_gsw_450)
-      (set! male4 voice_gsw_450))
 
-  (male1)
-  (Parameter.set 'Language 'britishenglish)
+(defvar system-language-path '("/usr/share/festival/languages/" )
+  "system-language-path
+   Additional directory not near the load path where languages can be
+   found, this can be redefined in lib/sitevars.scm if desired.")
+
+(defvar language-path 
+  (remove-duplicates
+   (append (mapcar (lambda (d) (path-append d "languages/")) load-path)
+	   (mapcar (lambda (d) (path-as-directory d)) system-language-path)
+	   ))
+
+  "language-path
+   List of places to look for languages. If not set it is initialised from
+   load-path by appending \"languages/\" to each directory with 
+   system-language-path appended.")
+
+(defvar language-locations ()
+  "language-locations
+   Association list recording where languages were found.")
+
+(defvar language-location-trace nil
+  "language-location-trace
+   Set t to print language locations as they are found")
+
+(defvar Language_descriptions nil
+  "Internal variable containing list of language descriptions as
+decribed by proclaim_language.")
+
+(define (language.get_voices langname)
+  "Returns a list with the installed voices for language langname"
+ (let ( (defmale nil) (deffemale nil) (lang nil) )
+
+  (set! lang (cdr (assoc langname Language_aliases)))
+  (if (string-equal lang nil)
+    (set! lang langname)
+  )
+ 
+  (set! defmale (cdr (assoc 'default_male (cadr (assoc lang Language_descriptions)))))
+  (set! deffemale (cdr (assoc 'default_female (cadr (assoc lang Language_descriptions)))))
+  (list (cons 'male defmale) (cons 'female deffemale))
+ )
 )
 
-(define (language_american_english)
-"(language_american_english)
-Set up language parameters for Aemerican English."
-
-  (if (symbol-bound? 'voice_kal_diphone)
-      (set! female1 voice_kal_diphone))
-  (set! male1 voice_ked_diphone)
 
-  (male1)
-  (Parameter.set 'Language 'americanenglish)
+(define (proclaim_language name description)
+"(proclaim_language NAME DESCRIPTION)
+Describe a language to the systen.  NAME should be atomic name, that
+conventionally will have language_ prepended to name the basic selection
+function.  OPTIONS is an assoc list of feature and value and must
+have at least features for default_male, default_female and name aliases.
+Values for these features must be lists of atoms."
+  (let ((langdesc (assoc name Language_descriptions))
+        (default_male (cadr (assoc 'default_male description)))
+        (default_female (cadr (assoc 'default_female description)))
+        (aliases (cadr (assoc 'aliases description)))
+        (langname (cadr (assoc 'language description)))
+        (voice_conditions nil)
+        (dialect (cadr (assoc 'dialect description)))
+        (voice_conditions_gender nil)
+       )
+    (set! voice_conditions (list (list 'language langname)))
+    ; In order to find available voices we may need to impose 
+    ; specific dialect conditions
+    (if dialect
+       (set! voice_conditions (cons (list 'dialect dialect) voice_conditions))
+    )
+
+    ; Let's find available male voices:
+    (set! voice_conditions_gender (cons (list 'gender 'male) voice_conditions))
+    (set! default_male (append default_male (voice.find voice_conditions_gender)))
+    (set! default_male (voice.remove_unavailable default_male))
+    (set! default_male (reverse (remove-duplicates (reverse default_male))))
+
+    ; Let's find available female voices:
+    (set! voice_conditions_gender (cons (list 'gender 'female) voice_conditions))
+    (set! default_female (append default_female (voice.find voice_conditions_gender)))
+    (set! default_female (voice.remove_unavailable default_female))
+    (set! default_female (reverse (remove-duplicates (reverse default_female))))
+
+    ; Now we change the given description replacing default voices:
+    (set-car! (cdr (assoc 'default_male description)) default_male)
+    (set-car! (cdr (assoc 'default_female description)) default_female)
+
+    ; Set up language aliases:
+    (if aliases
+       (language.names.add name aliases))
+    ; Set up description:
+    (if langdesc
+       (set-car! (cdr langdesc) description)
+       (set! Language_descriptions
+             (cons (list name description) Language_descriptions)))
+  )
 )
 
-(define (language_scots_gaelic)
-"(language_scots_gaelic)
-Set up language parameters for Scots Gaelic."
-  (error "Scots Gaelic not yet supported.")
 
-  (Parameter.set 'Language 'scotsgaelic)
+(defvar Language_aliases nil
+  "Internal variable containing an association of language name
+   aliases such as english-> british_english.")
+
+(define (language.names.add language aliases)
+"(language.names.add LANGUAGE ALIASES)
+Describe a language to the systen. LANGUAGE should be atomic name, that
+conventionally will have language_ prepended to name the basic selection
+function. ALIASES is a list of names for that language."
+  (let ( (alias nil) )
+
+       (while aliases
+        (set! alias (car aliases))
+        (cond ( (not (assoc alias Language_aliases) nil)
+	         (set! Language_aliases  (cons (cons alias language) Language_aliases))
+              )
+              (t
+                 (set-cdr! (assoc alias Language_aliases) language)
+              )
+        )
+        (set! aliases (cdr aliases))
+       )
+  )
 )
 
-(define (language_welsh)
-"(language_welsh)
-Set up language parameters for Welsh."
-
-  (set! male1 voice_welsh_hl)
-
-  (male1)
-  (Parameter.set 'Language 'welsh)
+(define (language-location name dir doc)
+  "(language-location NAME DIR DOCSTRING)
+   Record the location of a language. Called for each language found on language-path.
+   Can be called in site-init or .festivalrc for additional languages which
+   exist elsewhere."
+  (let ((func_name (intern name))
+	)
+
+    (set! name (intern name))
+    (set! language-locations (cons (cons name dir) language-locations))
+    (eval (list 'autoload func_name dir doc))
+    (if language-location-trace
+	(format t "Language: %s %s.scm\n" name dir)
+	)
+    )
+  )
+
+
+(define (language.list)
+"(language.list)
+List of all (potential) languages in the system.  This checks the language-location
+list of potential languages found be scanning the language-path at start up time."
+   (mapcar car Language_descriptions))
+
+(define (language.select name)
+"(language.select LANG)
+Call function to set up language LANG.  This is normally done by 
+prepending language_ to LANG and call it as a function."
+   (let ( (lang nil) )
+       (set! lang (cdr (assoc name Language_aliases)))
+       (if (string-equal lang nil)
+           (set! lang name)
+       )
+   (cond 
+      ((boundp (intern(string-append "language_" lang))) ;;if function "language_lang" exists, evaluate it
+          (eval (list (intern (string-append "language_" lang))))
+      )
+      ((string-matches lang "klingon")
+        (print "Klingon is not supported yet, using English:")
+        (language.select 'english)
+      )
+      (t ;;else, print a message with available languages
+        (print "Language not installed. The installed languages are:")
+        (print (language.list))
+      )
+   )
+   )
+nil
 )
 
-(define (language_castillian_spanish)
-"(language_spanish)
-Set up language parameters for Castillian Spanish."
 
-  (voice_el_diphone)
-  (set! male1 voice_el_diphone)
+(define (search-for-languages)
+  "(search-for-languages)
+   Search down language-path to locate languages."
+
+  (let ((dirs language-path)
+	(dir nil)
+	languages language
+	name 
+	)
+    (while dirs
+     (set! dir (car dirs))
+       (setq languages (directory-entries dir t))
+       (while languages
+         (set! language (car languages))
+         (if (string-matches language "language_.*scm$")
+                (begin
+                 (load (path-append dir language))
+	         (language-location (path-basename language)
+                                    (path-append dir (path-basename language))
+                                    "language found")
+	        )
+         )
+       (set! languages (cdr languages))
+      )
+     (set! dirs (cdr dirs))
+     )
+    )
+  )
 
-  (Parameter.set 'Language 'spanish)
+(define (select_language language)
+"(select_language LANG)
+Chooses language."
+  (language.select language)
 )
 
-(define (select_language language)
-  (cond
-   ((or (equal? language 'britishenglish)
-	(equal? language 'english))  ;; we all know its the *real* English
-    (language_british_english))
-   ((equal? language 'americanenglish)
-    (language_american_english))
-   ((equal? language 'scotsgaelic)
-    (language_scots_gaelic))
-   ((equal? language 'welsh)
-    (language_welsh))
-   ((equal? language 'spanish)
-    (language_castillian_spanish))
-   ((equal? language 'klingon)
-    (language_klingon))
-   (t
-    (print "Unsupported language, using English")
-    (language_british_english))))
+(search-for-languages)
 
-(defvar language_default language_british_english)
+(defvar language_default 'english)
 
 (provide 'languages)
--- /dev/null
+++ b/lib/languages/language_czech.scm
@@ -0,0 +1,80 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Czech language description
+;;
+;;
+
+(define (language_czech)
+"(language_czech)
+Set up language parameters for Czech."
+
+  (let ( (mydefault_voices (language.get_voices 'czech))
+         (mymalevoices nil)
+         (myfemalevoices nil)
+       )
+  (set! mymalevoices (cadr (assoc 'male mydefault_voices)))
+  (if (> (length mymalevoices) 0)
+    (set! male1 (lambda () (voice.select (nth 0 mymalevoices))))
+    (set! male1 nil)
+  )
+
+  (set! myfemalevoices (cadr (assoc 'female mydefault_voices)))
+  (if (> (length myfemalevoices) 0)
+    (set! female1 (lambda () (voice.select (nth 0 myfemalevoices))))
+    (set! female1 nil)
+  )
+
+  (if (null male1)
+     (if (null female1)
+        (format t "Not a Czech voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (Param.set 'Language 'czech)
+nil
+  )
+)
+
+(proclaim_language
+ 'czech
+ '((language czech)
+   (default_male (list czech_ph))
+   (default_female nil)
+   (aliases nil)
+  ))
+
--- /dev/null
+++ b/lib/languages/language_russian.scm
@@ -0,0 +1,81 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Russian language description
+;;
+;;
+
+(define (language_russian)
+"(language_finnish)
+Set up language parameters for Russian."
+
+  (let ( (mydefault_voices (language.get_voices 'russian))
+         (mymalevoices nil)
+         (myfemalevoices nil)
+       )
+  (set! mymalevoices (cadr (assoc 'male mydefault_voices)))
+  (if (> (length mymalevoices) 0)
+    (set! male1 (lambda () (voice.select (nth 0 mymalevoices))))
+    (set! male1 nil)
+  )
+
+  (set! myfemalevoices (cadr (assoc 'female mydefault_voices)))
+  (if (> (length myfemalevoices) 0)
+    (set! female1 (lambda () (voice.select (nth 0 myfemalevoices))))
+    (set! female1 nil)
+  )
+
+  (if (null male1)
+     (if (null female1)
+        (format t "Not a Russian voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (Param.set 'Language 'russian)
+current-voice
+  )
+)
+
+(proclaim_language
+ 'russian
+ '((language russian)
+   (default_male (list msu_ru_nsh_clunits))
+   (default_female nil)
+   (aliases nil)
+  ))
+
+
--- /dev/null
+++ b/lib/languages/language_italian.scm
@@ -0,0 +1,81 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Italian language description
+;;
+;;
+
+
+(define (language_italian)
+"(language_italian)
+Set up language parameters for Italian."
+
+  (let ( (mydefault_voices (language.get_voices 'italian))
+         (mymalevoices nil)
+         (myfemalevoices nil)
+       )
+  (set! mymalevoices (cadr (assoc 'male mydefault_voices)))
+  (if (> (length mymalevoices) 0)
+    (set! male1 (lambda () (voice.select (nth 0 mymalevoices))))
+    (set! male1 nil)
+  )
+
+  (set! myfemalevoices (cadr (assoc 'female mydefault_voices)))
+  (if (> (length myfemalevoices) 0)
+    (set! female1 (lambda () (voice.select (nth 0 myfemalevoices))))
+    (set! female1 nil)
+  )
+
+  (if (null male1)
+     (if (null female1)
+        (format t "Not an Italian voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (Param.set 'Language 'italian)
+current-voice
+  )
+)
+
+(proclaim_language
+ 'italian
+ '((language italian)
+   (default_male (list pc_diphone))
+   (default_female (list lp_diphone))
+   (aliases nil)
+  ))
+
--- /dev/null
+++ b/lib/languages/language_american_english.scm
@@ -0,0 +1,74 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; American English language description
+;;
+;;
+
+(define (language_american_english)
+"(language_american_english)
+Set up language parameters for American English."
+
+  (let ( (mydefault_voices (language.get_voices 'american_english))
+       )
+  (if (not (null (cadr (assoc 'male mydefault_voices ))))
+    (set! male1 (lambda () (voice.select (nth 0 (cadr (assoc 'male mydefault_voices))))))
+    (set! male1 nil)
+  )
+  (if (not (null (cadr (assoc 'female mydefault_voices ))))
+    (set! female1 (lambda () (voice.select (nth 0 (cadr (assoc 'female mydefault_voices))))))
+    (set! female1 nil)
+  )
+  (if (null male1)
+     (if (null female1)
+        (format t "Not an american English voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (Param.set 'Language 'americanenglish)
+current-voice
+  )
+)
+
+(proclaim_language
+ 'american_english
+ '((language english)
+   (dialect american)
+   (default_male (list ked_diphone))
+   (default_female (list kal_diphone))
+   (aliases (list americanenglish))
+  ))
--- /dev/null
+++ b/lib/languages/language_scots_gaelic.scm
@@ -0,0 +1,55 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Scots Gaelic language description
+;;
+;;
+
+(define (language_scots_gaelic)
+"(language_scots_gaelic)
+Set up language parameters for Scots Gaelic."
+  (error "Scots Gaelic not yet supported.")
+
+  (Param.set 'Language 'scotsgaelic)
+)
+
+(proclaim_language
+ 'scots_gaelic
+ '((language scotsgaelic)
+   (default_male nil)
+   (default_female nil)
+   (aliases (list scotsgaelic))
+  ))
--- /dev/null
+++ b/lib/languages/language_british_english.scm
@@ -0,0 +1,94 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:  
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; British English language description
+;;
+;;
+
+(define (language_british_english)
+"(language_british_english)
+Set up language parameters for British English."
+
+  (let ( (mydefault_voices (language.get_voices 'british_english))
+         (mymalevoices nil)
+         (myfemalevoices nil)
+       )
+  (set! mymalevoices (cadr (assoc 'male mydefault_voices)))
+  (if (> (length mymalevoices) 0)
+    (set! male1 (lambda () (voice.select (nth 0 mymalevoices))))
+    (set! male1 nil)
+  )
+  (if (> (length mymalevoices) 1)
+    (set! male2 (lambda () (voice.select (nth 1 mymalevoices))))
+    (set! male2 nil)
+  )
+  (if (> (length mymalevoices) 2)
+    (set! male3 (lambda () (voice.select (nth 2 mymalevoices))))
+    (set! male3 nil)
+  )
+  (if (> (length mymalevoices) 3)
+    (set! male4 (lambda () (voice.select (nth 3 mymalevoices))))
+    (set! male4 nil)
+  )
+
+
+  (set! myfemalevoices (cadr (assoc 'female mydefault_voices)))
+  (if (> (length myfemalevoices) 0)
+    (set! female1 (lambda () (voice.select (nth 0 myfemalevoices))))
+    (set! female1 nil)
+  )
+  
+  (if (null male1)
+     (if (null female1)
+        (format t "Not a british English voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (Param.set 'Language 'britishenglish)
+nil
+  )
+)
+
+(proclaim_language
+ 'british_english
+ '((language english)
+   (dialect british)
+   (default_male (list rab_diphone don_diphone gsw_diphone gsw_450))
+   (default_female nil)
+   (aliases (list britishenglish))
+  ))
+
--- /dev/null
+++ b/lib/languages/language_finnish.scm
@@ -0,0 +1,80 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Finnish language description
+;;
+;;
+
+(define (language_finnish)
+"(language_finnish)
+Set up language parameters for Finnish."
+
+  (let ( (mydefault_voices (language.get_voices 'finnish))
+         (mymalevoices nil)
+         (myfemalevoices nil)
+       )
+  (set! mymalevoices (cadr (assoc 'male mydefault_voices)))
+  (if (> (length mymalevoices) 0)
+    (set! male1 (lambda () (voice.select (nth 0 mymalevoices))))
+    (set! male1 nil)
+  )
+
+  (set! myfemalevoices (cadr (assoc 'female mydefault_voices)))
+  (if (> (length myfemalevoices) 0)
+    (set! female1 (lambda () (voice.select (nth 0 myfemalevoices))))
+    (set! female1 nil)
+  )
+
+  (if (null male1)
+     (if (null female1)
+        (format t "Not a Finnish voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (Param.set 'Language 'finnish)
+current-voice
+  )
+)
+
+(proclaim_language
+ 'finnish
+ '((language finnish)
+   (default_male (list hy_fi_mv_diphone))
+   (default_female (list suo_fi_lj_diphone))
+   (aliases nil)
+  ))
+
--- /dev/null
+++ b/lib/languages/language_welsh.scm
@@ -0,0 +1,80 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Welsh language description
+;;
+;;
+
+(define (language_welsh)
+"(language_welsh)
+Set up language parameters for Welsh."
+
+  (let ( (mydefault_voices (language.get_voices 'welsh))
+         (mymalevoices nil)
+         (myfemalevoices nil)
+       )
+  (set! mymalevoices (cadr (assoc 'male mydefault_voices)))
+  (if (> (length mymalevoices) 0)
+    (set! male1 (lambda () (voice.select (nth 0 mymalevoices))))
+    (set! male1 nil)
+  )
+
+  (set! myfemalevoices (cadr (assoc 'female mydefault_voices)))
+  (if (> (length myfemalevoices) 0)
+    (set! female1 (lambda () (voice.select (nth 0 myfemalevoices))))
+    (set! female1 nil)
+  )
+
+  (if (null male1)
+     (if (null female1)
+        (format t "Not a Welsh voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (Param.set 'Language 'welsh)
+current-voice
+  )
+)
+
+(proclaim_language
+ 'welsh
+ '((language welsh)
+   (default_male (list welsh_hl))
+   (default_female nil)
+   (aliases nil)
+  ))
+
--- /dev/null
+++ b/lib/languages/language_castillian_spanish.scm
@@ -0,0 +1,80 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Castillian Spanish language description
+;;
+;;
+
+(define (language_castillian_spanish)
+"(language_castillian_spanish)
+Set up language parameters for Castillian Spanish."
+
+  (let ( (mydefault_voices (language.get_voices 'spanish))
+         (mymalevoices nil)
+         (myfemalevoices nil)
+       )
+  (set! mymalevoices (cadr (assoc 'male mydefault_voices)))
+  (if (> (length mymalevoices) 0)
+    (set! male1 (lambda () (voice.select (nth 0 mymalevoices))))
+    (set! male1 nil)
+  )
+
+  (set! myfemalevoices (cadr (assoc 'female mydefault_voices)))
+  (if (> (length myfemalevoices) 0)
+    (set! female1 (lambda () (voice.select (nth 0 myfemalevoices))))
+    (set! female1 nil)
+  )
+
+  (if (null male1)
+     (if (null female1)
+        (format t "Not a Spanish voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (Param.set 'Language 'spanish)
+nil
+  )
+)
+
+(proclaim_language
+ 'castillian_spanish
+ '((language spanish)
+   (default_male (list el_diphone))
+   (default_female nil)
+   (aliases (list spanish castellano))
+  ))
+
--- a/lib/init.scm
+++ b/lib/init.scm
@@ -147,7 +147,12 @@
     (load (path-append home-directory ".festivalrc")))
 
 ;;; Default voice (have to do something cute so autoloads still work)
-(eval (list voice_default))
+(unwind-protect
+ (eval (list voice_default))
+ (begin
+   (format t "Error evaluating default voice: %s\n" voice_default)
+   (format t "continuing\n")))
+
 
 (provide 'init)
 
--- /dev/null
+++ b/lib/languages/language_english.scm
@@ -0,0 +1,78 @@
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                       ;;
+;;;                Centre for Speech Technology Research                  ;;
+;;;                     University of Edinburgh, UK                       ;;
+;;;                         Copyright (c) 2002                            ;;
+;;;                        All Rights Reserved.                           ;;
+;;;                                                                       ;;
+;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
+;;;  this software and its documentation without restriction, including   ;;
+;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
+;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
+;;;  permit persons to whom this work is furnished to do so, subject to   ;;
+;;;  the following conditions:                                            ;;
+;;;   1. The code must retain the above copyright notice, this list of    ;;
+;;;      conditions and the following disclaimer.                         ;;
+;;;   2. Any modifications must be clearly marked as such.                ;;
+;;;   3. Original authors' names are not deleted.                         ;;
+;;;   4. The authors' names are not used to endorse or promote products   ;;
+;;;      derived from this software without specific prior written        ;;
+;;;      permission.                                                      ;;
+;;;                                                                       ;;
+;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
+;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
+;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
+;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
+;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
+;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
+;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
+;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
+;;;  THIS SOFTWARE.                                                       ;;
+;;;                                                                       ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                         Author: 
+;;;                         Date:   
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; American English language description
+;;
+;;
+
+(define (language_english)
+"(language_english)
+Set up language parameters for English."
+
+  (let ( (mydefault_voices (language.get_voices 'english)))
+
+  (if (cadr (assoc 'male mydefault_voices ))
+    (set! male1 (lambda () (voice.select (car (cadr (assoc 'male mydefault_voices))))))
+    (set! male1 nil)
+  )
+
+  (if (cadr (assoc 'female mydefault_voices ))
+    (set! female1 (lambda () (voice.select (car (cadr (assoc 'female mydefault_voices))))))
+    (set! female1 nil)
+  )
+  
+  (if (null male1)
+     (if (null female1)
+        (format t "Not an English voice installed")
+        (female1)
+     )
+     (male1)
+  )
+  (if (equal? 'american (cdr (assoc 'dialect (cdr (assoc current-voice Voice_descriptions)))))
+     (Param.set 'Language 'americanenglish)
+     (Param.set 'Language 'britishenglish)
+  )
+ )
+current-voice
+)
+
+(proclaim_language
+ 'english
+ '((language english)
+   (default_male (list rab_diphone don_diphone))
+   (default_female nil)
+   (aliases nil)
+  ))
--- a/lib/voices.scm
+++ b/lib/voices.scm
@@ -31,7 +31,7 @@
 ;;;                                                                       ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
-;;; Preapre to access voices. Searches down a path of places.
+;;; Prepare to access voices. Searches down a path of places.
 ;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -76,7 +76,7 @@
 
 
 ;; Declaration of voices. When we declare a voice we record the
-;; directory and set up an autoload for the vocie-selecting function
+;; directory and set up an autoload for the voice-selecting function
 
 (defvar voice-locations ()
   "voice-locations
@@ -230,6 +230,35 @@
 voice.describe."
    (mapcar car voice-locations))
 
+(define (voice.find parameters)
+"(voice.find PARAMETERS)
+List of the (potential) voices in the system that match the PARAMETERS described
+in the proclaim_voice description fields."
+  (let ((voices (eval (list voice.list)))
+        (validvoices nil)
+        (voice nil)
+       )
+    (while parameters
+      (while voices
+        (set! voice (car voices))
+;;I believe the next line should be improved. equal? doesn't work always.
+        (if (equal? (list (cadr (assoc (caar parameters)
+                                       (cadr (assoc voice Voice_descriptions))
+                                ))) (cdar parameters))
+            (begin
+              (set! validvoices (append (list voice) validvoices))
+            )
+        )
+        (set! voices (cdr voices))
+      )
+      (set! voices validvoices)
+      (set! validvoices nil)
+      (set! parameters (cdr parameters))
+    )
+  voices
+  )
+)
+
 ;; Voices are found on the voice-path if they are in directories of the form
 ;;		DIR/LANGUAGE/NAME
 
@@ -240,24 +269,46 @@
   (let ((dirs voice-path)
 	(dir nil)
 	languages language
-	voices voicedir voice
+	voices voicedir voice voice_proclaimed
 	)
     (while dirs
      (set! dir (car dirs))
      (setq languages (directory-entries dir t))
      (while languages
        (set! language (car languages))
+       (set! voice_proclaimed nil) ; flag to mark if proclaim_voice is found
        (set! voices (directory-entries (path-append dir language) t))
        (while voices
 	 (set! voicedir (car voices))
 	 (set! voice (path-basename voicedir))
-	 (if (string-matches voicedir ".*\\..*")
+	 (if (or (string-matches voicedir ".*\\..*")
+             (not (probe_file (path-append dir language voicedir "festvox" (string-append voicedir ".scm"))))
+             );; if directory is \.. or voice description doesn't exist, then do nothing. Else, load voice
 	     nil
-	     (voice-location 
-	      voice 
-	      (path-as-directory (path-append dir language voicedir))
-	      "voice found on path")
-	     )
+       (begin
+	       ;; Do the voice proclamation: load the voice definition file.
+	       (set! voice-def-file (load (path-append dir language voicedir "festvox" 
+						       (string-append voicedir ".scm")) t))
+	       ;; now find the "proclaim_voice" lines and register these voices.
+	       (mapcar
+		       (lambda (line)
+             (if (string-matches (car line) "proclaim_voice")
+               (begin
+		                (voice-location (intern (cadr (cadr line)))
+                                    (path-as-directory (path-append dir language voicedir)) "registered voice")
+                    (eval line)
+                    (set! voice_proclaimed t)
+               )
+             )
+           )
+		       voice-def-file)
+         (if (not voice_proclaimed) ;proclaim_voice is missing. Use old voice location method
+           (voice-location voice
+                           (path-as-directory (path-append dir language voicedir))
+                           "voice found on path")
+         )
+       )
+   )
 	 (set! voices (cdr voices))
 	 )
        (set! languages (cdr languages))
@@ -287,7 +338,9 @@
        (while voices
 	 (set! voicedir (car voices))
 	 (set! voice (path-basename voicedir))
-	 (if (string-matches voicedir ".*\\..*")
+	 (if (or (string-matches voicedir ".*\\..*") 
+             (not (probe_file (path-append dir language voicedir "festvox" (string-append voicedir ".scm"))))
+             );; if directory is \.. or voice description doesn't exist, then do nothing. Else, load voice
 	     nil
 	     (begin
 	       ;; load the voice definition file, but don't evaluate it!
@@ -297,7 +350,12 @@
 	       (mapcar
 		(lambda (line)
 		  (if (string-matches (car line) "proclaim_voice")
-		      (voice-location-multisyn (intern (cadr (cadr line)))  voicedir (path-append dir language voicedir) "registerd multisyn voice")))
+                    (begin
+		      (voice-location-multisyn (intern (cadr (cadr line)))  voicedir (path-append dir language voicedir) "registerd multisyn voice")
+                      (eval line)
+                    )
+                  )
+                )
 		voice-def-file)
 	     ))
 	 (set! voices (cdr voices)))
@@ -323,39 +381,60 @@
 the default voice. [see Site initialization]")
 
 (defvar default-voice-priority-list 
-  '(kal_diphone
-    cmu_us_slt_cg
-    cmu_us_rms_cg
-    cmu_us_bdl_cg
-    cmu_us_jmk_cg
-    cmu_us_awb_cg
-;    cstr_rpx_nina_multisyn       ; restricted license (lexicon)
-;    cstr_rpx_jon_multisyn       ; restricted license (lexicon)
-;    cstr_edi_awb_arctic_multisyn ; restricted license (lexicon)
-;    cstr_us_awb_arctic_multisyn
-    ked_diphone
-    don_diphone
-    rab_diphone
-    en1_mbrola
-    us1_mbrola
-    us2_mbrola
-    us3_mbrola
-    gsw_diphone  ;; not publically distributed
-    el_diphone
+  (reverse (remove-duplicates (reverse 
+  (append 
+    (list 'nitech_us_slt_arctic_hts
+          'nitech_us_awb_arctic_hts
+          'nitech_us_bdl_arctic_hts
+          'nitech_us_clb_arctic_hts
+          'nitech_us_jmk_arctic_hts
+          'nitech_us_rms_arctic_hts
+          'kal_diphone
+          'ked_diphone
+          'cstr_us_awb_arctic_multisyn
+          'cstr_us_jmk_arctic_multisyn
     )
+    (voice.find (list (list 'engine 'hts)))
+    (voice.find (list (list 'engine 'diphone)))
+    (voice.find (list (list 'engine 'clunits)))
+    (voice.find (list (list 'engine 'clustergen)))
+    (voice.list)
+  ))))
   "default-voice-priority-list
    List of voice names. The first of them available becomes the default voice.")
 
-(let ((voices default-voice-priority-list)
-      voice)
-  (while (and voices (eq voice_default 'no_voice_error))
-	 (set! voice (car voices))
-	 (if (assoc voice voice-locations)
-	     (set! voice_default (intern (string-append "voice_" voice)))
-	     )
-	 (set! voices (cdr voices))
-	 )
+
+(define (voice.remove_unavailable voices)
+ "voice.remove_unavailable VOICES takes a list of voice names and returns
+a list with the voices in VOICES available."
+  (let ((output (mapcar (lambda(x) (if (assoc (intern x) voice-locations ) (intern x))) voices)))
+    (while (member nil output)
+       (set! output (remove nil output))
+    )
+  output
   )
+)
+
+
+
+(define (set_voice_default voices)
+ "set_voice_default VOICES sets as voice_default the first voice available from VOICES list"
+  (let ( (avail_voices (voice.remove_unavailable voices))
+       )
+       (if avail_voices
+         (begin
+           (set! voice_default (intern (string-append "voice_" (car avail_voices))))
+          t
+         )
+         (begin 
+           (print "Could not find any of these voices:")
+           (print voices)
+           nil
+         )
+       )
+  )
+)
 
 
+(set_voice_default default-voice-priority-list)
 (provide 'voices)
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin