home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / fest-141.zip / festival / lib / lexicons.scm < prev    next >
Lisp/Scheme  |  1999-05-30  |  10KB  |  256 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;                                                                       ;;
  3. ;;;                Centre for Speech Technology Research                  ;;
  4. ;;;                     University of Edinburgh, UK                       ;;
  5. ;;;                       Copyright (c) 1996,1997                         ;;
  6. ;;;                        All Rights Reserved.                           ;;
  7. ;;;                                                                       ;;
  8. ;;;  Permission is hereby granted, free of charge, to use and distribute  ;;
  9. ;;;  this software and its documentation without restriction, including   ;;
  10. ;;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
  11. ;;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
  12. ;;;  permit persons to whom this work is furnished to do so, subject to   ;;
  13. ;;;  the following conditions:                                            ;;
  14. ;;;   1. The code must retain the above copyright notice, this list of    ;;
  15. ;;;      conditions and the following disclaimer.                         ;;
  16. ;;;   2. Any modifications must be clearly marked as such.                ;;
  17. ;;;   3. Original authors' names are not deleted.                         ;;
  18. ;;;   4. The authors' names are not used to endorse or promote products   ;;
  19. ;;;      derived from this software without specific prior written        ;;
  20. ;;;      permission.                                                      ;;
  21. ;;;                                                                       ;;
  22. ;;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
  23. ;;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
  24. ;;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
  25. ;;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
  26. ;;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
  27. ;;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
  28. ;;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
  29. ;;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
  30. ;;;  THIS SOFTWARE.                                                       ;;
  31. ;;;                                                                       ;;
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  33. ;;;
  34. ;;;  Definition of various lexicons
  35. ;;;
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37.  
  38. ;;;  If there exists a sudirectory of the lib-path called dicts then that 
  39. ;;;  is used as the lexicon directory by default.  If it doesn't exist 
  40. ;;;  we set lexdir to the directory in CSTR where our lexicons are.  
  41. ;;;  In non-CSTR installations where lexicons are not in lib/dicts, 
  42. ;;;  you should set lexdir in sitevars.scm
  43.  
  44. (defvar lexdir 
  45.   (if (probe_file (path-append libdir "dicts"))
  46.       (path-append libdir "dicts/")
  47.       ;; else we'll guess we're in the CSTR filespace
  48.       (path-as-directory "/projects/festival/lib/dicts/"))
  49.   "lexdir
  50.   The directory where the lexicon(s) are, by default.")
  51.  
  52. (require 'pos)        ;; for part of speech mapping 
  53.  
  54. (define (setup_cstr_lex)
  55. "(setup_cstr_lexicon)
  56. Define and setup the CSTR lexicon.  The CSTR lexicon consists
  57. of about 25,000 entries in the mrpa phone set.  A large number of
  58. specific local entries are also added to the addenda."
  59.   (if (not (member_string "mrpa" (lex.list)))
  60.       (begin
  61.     (lex.create "mrpa")
  62.     (lex.set.compile.file (path-append lexdir "cstrlex.out"))
  63.     (lex.set.phoneset "mrpa")
  64.     (lex.set.lts.method 'lts_rules)
  65.     (lex.set.lts.ruleset 'nrl)
  66.     (lex.set.pos.map english_pos_map_wp39_to_wp20)
  67.     (mrpa_addenda)
  68.     (lex.add.entry
  69.      '("previous" nil (((p r ii) 1) ((v ii) 0) ((@ s) 0))))
  70.     (lex.add.entry
  71.      '("audio" () (((oo d) 1) ((ii) 0) ((ou) 0))))
  72.     (lex.add.entry
  73.      '("modules" () (((m o d) 1) ((uu l s) 0))))
  74.     )))
  75.  
  76. (define (setup_oald_lex)
  77. "(setup_oald_lexicon)
  78. Define and setup the CUVOALD lexicon.  This is derived from the
  79. Computer Users Version of the Oxford Advanced Learners' Dictionary
  80. of Current English.  This version includes a trained set of letter
  81. to sound rules which have also been used to reduce the actual lexicon
  82. size by over half, for those entries that the lts model gets exactly
  83. the same."
  84.   (if (not (member_string "oald" (lex.list)))
  85.       (load (path-append lexdir "oald/oaldlex.scm"))))
  86.  
  87. (define (setup_cmu_lex)
  88.   "(setup_cmu_lex)
  89. Lexicon derived from the CMU lexicon (cmudict-0.4), around 100,000 entries,
  90. in the radio phoneset (sort of darpa-like).  Includes letter to sound
  91. rule model trained from this data, and uses the lexical stress predictor
  92. from OALD."
  93.   (if (not (member_string "cmu" (lex.list)))
  94.       (load (path-append lexdir "cmu/cmulex.scm"))))
  95.  
  96. (define (setup_cmumt_lex)
  97.   "(setup_cmumt_lex)
  98. Lexicon derived from the CMU lexicon (cmudict-0.4), around 100,000 entries,
  99. in the radio phoneset (sort of darpa-like).  Includes letter to sound
  100. rule model trained from this data, and uses the lexical stress predictor
  101. from OALD."
  102.   (if (not (member_string "cmumt" (lex.list)))
  103.       (load (path-append lexdir "cmu_mt/cmumtlex.scm"))))
  104.  
  105. (define (setup_cmu6_lex)
  106.   "(setup_cmu6_lex)
  107. Lexicon derived from the CMU lexicon (cmudict-0.6), around 100,000 entries,
  108. in the radio phoneset (sort of darpa-like).  Includes letter to sound
  109. rule model trained from this data, the format of this lexicon is suitable
  110. for the UniSyn metrical phonology modules.  That is the entries are
  111. not syllabified,"
  112.   (if (not (member_string "cmu6" (lex.list)))
  113.       (load (path-append lexdir "cmu6/cmu6lex.scm"))))
  114.  
  115. (define (setup_moby_lex)
  116. "(setup_moby_lexicon)
  117. Define and setup the MOBY lexicon.  This is derived from the public
  118. domain version of the Moby (TM) Pronunciator II lexicon.  It can be
  119. converted automatically to British English mrpa phoneset which of
  120. course is sub-optimal.  It contains around 120,000 entries and has part
  121. of speech information for homographs."
  122.   (if (not (member_string "moby" (lex.list)))
  123.       (begin
  124.     (lex.create "moby")
  125.     ;  (lex.set.compile.file (path-append lexdir "mobylex.out"))
  126.     (lex.set.compile.file "/home/awb/src/mobypron/mobylex.out")
  127.     (lex.set.phoneset "mrpa")
  128.     (lex.set.lts.method 'lts_rules)
  129.     (lex.set.lts.ruleset 'nrl)
  130.     (lex.set.pos.map english_pos_map_wp39_to_wp20)
  131.     (lex.add.entry 
  132.      '("a" dt (((@) 0))))
  133.     (lex.add.entry 
  134.      '("the" dt (((dh @) 0))))
  135.     (lex.add.entry
  136.      '("taylor" n (((t ei) 1) ((l @) 0))))
  137.     (lex.add.entry
  138.      '("who" prp ((( h uu ) 0))))
  139.     (mrpa_addenda))))
  140.  
  141. (define (setup_beep_lex)
  142.   "(setup_beep_lex)
  143. Lexicon derived from the British English Example Pronunciation dictionary
  144. (BEEP) from Tony Robinson  ajr@eng.cam.ac.uk.  Around 160,000 entries."
  145.   (if (not (member_string "beep" (lex.list)))
  146.       (begin
  147.     (lex.create "beep")
  148.     (lex.set.compile.file (path-append lexdir "beep_lex.out"))
  149.     (lex.set.phoneset "mrpa")
  150.     (lex.set.lts.method 'lts_rules)
  151.     (lex.set.lts.ruleset 'nrl)
  152.     (lex.set.pos.map english_pos_map_wp39_to_wp20)
  153.     (lex.add.entry
  154.      '("taylor" nil (((t ei) 1) ((l @) 0))))
  155.     (mrpa_addenda))))
  156.  
  157. ;;; The nrl letter to sound rules produce mrpa phone set so we need
  158. ;;; to do some fancy things to make them work for American English
  159. (define (f2b_lts word features)
  160. "(f2b_lts WORD FEATURES)
  161. Letter to sound rule system for f2b (American English), uses the NRL
  162. LTS ruleset and maps the result to the radio phone set."
  163.  '("unknown" nil (((ah n) 0) ((n ow n) 1)))
  164. )
  165.  
  166. ;;; A CART tree for predicting lexical stress for strings of phones
  167. ;;; generated by the LTS models.  This was actually trained from
  168. ;;; OALD as that's the only lexicon with stress and part of speech information
  169. ;;; It trained in a phoneset independent way and may be used be either
  170. ;;; OALD or CMU models (and probably MOBY and OGI lex too).
  171. ;;; On held out data it gets 
  172. ;;;           07390  378 7768      [7390/7768]      95.134
  173. ;;;           1 512 8207 8719      [8207/8719]      94.128
  174. ;;;            7902 8585 
  175. ;;; total 16487 correct 15597.000 94.602%
  176. ;;;  
  177. (set! english_stress_tree
  178. '((sylpos < 1.7)
  179.  ((1))
  180.  ((ph_vlng is a)
  181.   ((0))
  182.   ((ph_vheight is 1)
  183.    ((num2end < 1.5)
  184.     ((ph_vfront is 1)
  185.      ((ph_vlng is s) ((0)) ((pos is v) ((1)) ((0))))
  186.      ((pos is n) ((0)) ((sylpos < 2.2) ((1)) ((0)))))
  187.     ((ph_vlng is l)
  188.      ((1))
  189.      ((ph_vfront is 1)
  190.       ((num2end < 2.4)
  191.        ((0))
  192.        ((pos is a)
  193.         ((num2end < 3.3) ((sylpos < 2.3) ((1)) ((0))) ((0)))
  194.         ((sylpos < 3.2)
  195.          ((num2end < 3.3) ((0)) ((pos is v) ((1)) ((0))))
  196.          ((0)))))
  197.       ((0)))))
  198.    ((num2end < 1.5)
  199.     ((pos is n)
  200.      ((0))
  201.      ((sylpos < 2.4)
  202.       ((pos is v)
  203.        ((1))
  204.        ((ph_vlng is d)
  205.         ((ph_vheight is 2) ((ph_vfront is 1) ((1)) ((0))) ((0)))
  206.         ((1))))
  207.       ((ph_vlng is d)
  208.        ((sylpos < 3.3)
  209.         ((pos is v)
  210.          ((ph_vheight is 2) ((ph_vfront is 1) ((0)) ((1))) ((0)))
  211.          ((0)))
  212.         ((0)))
  213.        ((ph_vheight is 2)
  214.         ((1))
  215.         ((ph_vrnd is +) ((1)) ((ph_vlng is l) ((0)) ((1))))))))
  216.     ((ph_vlng is d)
  217.      ((pos is v)
  218.       ((sylpos < 2.4) ((1)) ((0)))
  219.       ((ph_vfront is 2)
  220.        ((pos is n)
  221.         ((num2end < 2.4)
  222.          ((ph_vrnd is +)
  223.           ((0))
  224.           ((sylpos < 2.2) ((1)) ((ph_vheight is 2) ((1)) ((0)))))
  225.          ((sylpos < 2.4) ((ph_vheight is 2) ((0)) ((1))) ((0))))
  226.         ((1)))
  227.        ((ph_vheight is 2) ((1)) ((ph_vfront is 1) ((0)) ((1))))))
  228.      ((pos is n)
  229.       ((num2end < 2.4)
  230.        ((ph_vfront is 3)
  231.         ((sylpos < 2.3) ((1)) ((ph_vlng is l) ((1)) ((0))))
  232.         ((1)))
  233.        ((1)))
  234.       ((1)))))))))
  235.  
  236. (define (lex_user_unknown_word word feats)
  237.   "(lex_user_unknown_word WORD FEATS)
  238. Function called by lexicon when 'function type letter to sound rules
  239. is defined.  It is the user's responsibility to defined this function
  240. themselves when they want to deal with unknown words themselves."
  241.   (error "lex_user_unknown_word: has not been defined by user"))
  242.  
  243. (define (Word utt)
  244. "(Word utt)                                
  245. Construct (synthesis specific) syllable/segments from Word relation
  246. using current lexicon and specific module."
  247.   (let ((rval (apply_method 'Word_Method utt)))
  248.     (cond
  249.      (rval rval) ;; new style
  250.      (t
  251.       (Classic_Word utt)))))
  252.  
  253.  
  254. (provide 'lexicons)
  255.  
  256.