home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / fest-141.zip / festival / lib / postlex.scm < prev    next >
Lisp/Scheme  |  1999-06-17  |  15KB  |  345 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;                                                                       ;;
  3. ;;;                Centre for Speech Technology Research                  ;;
  4. ;;;                     University of Edinburgh, UK                       ;;
  5. ;;;                         Copyright (c) 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. ;;;  Postlexical rules
  35. ;;;
  36.  
  37. (define (PostLex utt)
  38. "(PostLex utt)
  39. Apply post lexical rules to segment stream.  These may be almost
  40. arbitrary rules as specified by the particular voice, through the
  41. postlex_hooks variable.  A number of standard post lexical rule
  42. sets are provided including reduction, posessives etc.  These
  43. rules are also used to mark standard segments with their cluster
  44. information used in creating diphone names."
  45. (let ((rval (apply_method 'PostLex_Method utt)))
  46.   (cond
  47.    (rval rval) ;; new style 
  48.    (t   ;; should only really need this one
  49.     (apply_hooks postlex_rules_hooks utt)))
  50.   utt
  51. ))
  52.  
  53. (define (Classic_PostLex utt)
  54.   "(Classic_PostLex utt)
  55. Apply post lexical rules (both builtin and those specified in 
  56. postlex_rules_hooks)."
  57.   (Builtin_PostLex utt)  ;; haven't translated all the rules yet
  58.   (apply_hooks postlex_rules_hooks utt)
  59.   utt
  60. )  
  61.  
  62. (defvar postlex_rules_hooks nil
  63. "postlex_rules_hooks
  64. A function or list of functions which encode post lexical rules.
  65. This will be voice specific, though some rules will be shared across
  66. languages.")
  67.  
  68. ;;;  Mapping of full vowels to reduced vowels, this should be part
  69. ;;;  of the phoneset definitions
  70. (defvar postlex_vowel_reduce_table
  71.   '((mrpa
  72.      ((uh @) (i @) (a @) (e @) (u @) (o @) (oo @)))
  73.     (radio
  74.      ((ah ax el en em) 
  75.       (ih ax) 
  76. ;      (er axr ax) 
  77. ;      (iy ih) 
  78. ;      (ey ax) 
  79.       (aa ax) 
  80.       (ae ax) 
  81.       (eh ax))))
  82. "postlex_vowel_reduce_table
  83. Mapping of vowels to their reduced form.  This in an assoc list of
  84. phoneset name to an assoc list of full vowel to reduced form.")
  85.  
  86. (defvar postlex_vowel_reduce_cart_tree nil
  87. "postlex_vowel_reduce_cart_tree
  88. CART tree for vowel reduction.")
  89.  
  90. (defvar postlex_vowel_reduce_cart_tree_hand
  91.   '((stress is 0)
  92.     ((p.syl_break < 2)
  93.      ((syl_break < 2)
  94.       ((1))
  95.       ((0)))
  96.      ((0)))
  97.     ((0)))
  98. "postlex_vowel_reduce_cart_tree_hand
  99. A CART tree for vowel reduction.  This is hand-written.")
  100.  
  101. (defvar postlex_vowel_reduce_cart_data
  102. '
  103. ((R:SylStructure.parent.gpos is cc)
  104.  (((0 0.993548) (1 0.00645161) 0))
  105.  ((p.R:SylStructure.parent.gpos is md)
  106.   (((0 0.903226) (1 0.0967742) 0))
  107.   ((p.R:SylStructure.parent.gpos is det)
  108.    ((n.R:SylStructure.parent.gpos is content)
  109.     ((last_accent < 2.5)
  110.      ((next_accent < 2.5)
  111.       ((next_accent < 1.2)
  112.        ((n.syl_break is 4)
  113.         (((0 0.967213) (1 0.0327869) 0))
  114.         ((syl_break is 4)
  115.          (((0 0.952381) (1 0.047619) 0))
  116.          ((n.syl_break is 4)
  117.           (((0 0.953488) (1 0.0465116) 0))
  118.           ((position_type is single)
  119.            (((0 0.947368) (1 0.0526316) 0))
  120.            ((accented is 0)
  121.             ((n.accented is 0)
  122.              (((0 0.857143) (1 0.142857) 0))
  123.              (((0 0.415385) (1 0.584615) 1)))
  124.             (((0 0.974359) (1 0.025641) 0)))))))
  125.        (((0 0.968254) (1 0.031746) 0)))
  126.       (((0 0.969697) (1 0.030303) 0)))
  127.      (((0 0.976744) (1 0.0232558) 0)))
  128.     (((0 0.990291) (1 0.00970874) 0)))
  129.    ((next_accent < 108.5)
  130.     ((p.R:SylStructure.parent.gpos is pps)
  131.      (((0 0.828947) (1 0.171053) 0))
  132.      ((R:SylStructure.parent.gpos is det)
  133.       ((accented is 0)
  134.        (((0 0.0599572) (1 0.940043) 1))
  135.        (((0 0.949367) (1 0.0506329) 0)))
  136.       ((p.R:SylStructure.parent.gpos is cc)
  137.        (((0 0.880952) (1 0.119048) 0))
  138.        ((p.R:SylStructure.parent.gpos is wp)
  139.         (((0 0.875) (1 0.125) 0))
  140.         ((p.R:SylStructure.parent.gpos is in)
  141.          ((n.syl_break is 4)
  142.           (((0 0.961538) (1 0.0384615) 0))
  143.           ((next_accent < 2.5)
  144.            ((syl_break is 4)
  145.             (((0 0.95122) (1 0.0487805) 0))
  146.             ((next_accent < 1.2)
  147.              ((accented is 0)
  148.               ((n.stress is 0)
  149.                (((0 0.788462) (1 0.211538) 0))
  150.                ((R:SylStructure.parent.R:Word.p.gpos is content)
  151.                 (((0 0.863636) (1 0.136364) 0))
  152.                 ((position_type is single)
  153.                  (((0 0.729167) (1 0.270833) 0))
  154.                  (((0 0.4) (1 0.6) 1)))))
  155.               (((0 0.983871) (1 0.016129) 0)))
  156.              (((0 0.96) (1 0.04) 0))))
  157.            (((0 0.963636) (1 0.0363636) 0))))
  158.          ((position_type is single)
  159.           ((syl_break is 4)
  160.            (((0 0.993865) (1 0.00613497) 0))
  161.            ((p.R:SylStructure.parent.gpos is to)
  162.             (((0 0.984375) (1 0.015625) 0))
  163.             ((syl_break is 1)
  164.              ((accented is 0)
  165.               ((n.R:SylStructure.parent.gpos is in)
  166.                (((0 0.869565) (1 0.130435) 0))
  167.                ((R:SylStructure.parent.gpos is content)
  168.                 (((0 0.861789) (1 0.138211) 0))
  169.                 ((p.R:SylStructure.parent.gpos is content)
  170.                  ((p.syl_break is 4)
  171.                   (((0 0.858065) (1 0.141935) 0))
  172.                   ((R:SylStructure.parent.gpos is in)
  173.                    ((p.syl_break is 1)
  174.                     ((n.R:SylStructure.parent.gpos is det)
  175.                      (((0 0.659574) (1 0.340426) 0))
  176.                      ((p.stress is 0)
  177.                       (((0 0.422222) (1 0.577778) 1))
  178.                       (((0 0.582278) (1 0.417722) 0))))
  179.                     ((n.accented is 0)
  180.                      ((n.R:SylStructure.parent.gpos is content)
  181.                       (((0 0.65) (1 0.35) 0))
  182.                       ((p.stress is 0)
  183.                        (((0 0.464286) (1 0.535714) 1))
  184.                        (((0 0.538462) (1 0.461538) 0))))
  185.                      (((0 0.803279) (1 0.196721) 0))))
  186.                    ((n.R:SylStructure.parent.gpos is det)
  187.                     (((0 0.952381) (1 0.047619) 0))
  188.                     ((n.syl_break is 4)
  189.                      (((0 0.833333) (1 0.166667) 0))
  190.                      ((p.stress is 0)
  191.                       ((p.syl_break is 1)
  192.                        ((n.syl_break is 1)
  193.                         (((0 0.740741) (1 0.259259) 0))
  194.                         ((R:SylStructure.parent.gpos is aux)
  195.                          (((0 0.478261) (1 0.521739) 1))
  196.                          (((0 0.769231) (1 0.230769) 0))))
  197.                        (((0 0.755556) (1 0.244444) 0)))
  198.                       (((0 0.797619) (1 0.202381) 0)))))))
  199.                  (((0 0.870968) (1 0.129032) 0)))))
  200.               (((0 0.983806) (1 0.0161943) 0)))
  201.              (((0 0.977778) (1 0.0222222) 0)))))
  202.           ((next_accent < 21.6)
  203.            ((p.stress is 0)
  204.             ((R:SylStructure.parent.R:Word.p.gpos is md)
  205.              (((0 0.961538) (1 0.0384615) 0))
  206.              ((position_type is mid)
  207.               (((0 0.977612) (1 0.0223881) 0))
  208.               ((n.R:SylStructure.parent.gpos is det)
  209.                (((0 0.916667) (1 0.0833333) 0))
  210.                ((R:SylStructure.parent.R:Word.n.gpos is 0)
  211.                 (((0 0.915493) (1 0.084507) 0))
  212.                 ((R:SylStructure.parent.R:Word.n.gpos is pps)
  213.                  (((0 0.884615) (1 0.115385) 0))
  214.                  ((n.stress is 0)
  215.                   ((n.syl_break is 4)
  216.                    (((0 0.986755) (1 0.013245) 0))
  217.                    ((p.syl_break is 4)
  218.                     (((0 0.977011) (1 0.0229885) 0))
  219.                     ((n.syl_break is 4)
  220.                      (((0 0.965517) (1 0.0344828) 0))
  221.                      ((last_accent < 1.2)
  222.                       ((last_accent < 0.1)
  223.                        (((0 0.910448) (1 0.0895522) 0))
  224.                        ((next_accent < 1.2)
  225.                         ((R:SylStructure.parent.R:Word.n.gpos is in)
  226.                          (((0 0.82) (1 0.18) 0))
  227.                          ((n.syl_break is 0)
  228.                           ((R:SylStructure.parent.R:Word.p.gpos is content)
  229.                            (((0 0.819672) (1 0.180328) 0))
  230.                            (((0 0.444444) (1 0.555556) 1)))
  231.                           (((0 0.785714) (1 0.214286) 0))))
  232.                         (((0 0.836364) (1 0.163636) 0))))
  233.                       (((0 0.962025) (1 0.0379747) 0))))))
  234.                   ((stress is 0)
  235.                    ((n.syl_break is 4)
  236.                     (((0 0.21875) (1 0.78125) 1))
  237.                     ((R:SylStructure.parent.R:Word.p.gpos is aux)
  238.                      (((0 0.259259) (1 0.740741) 1))
  239.                      ((p.syl_break is 1)
  240.                       (((0 0.243094) (1 0.756906) 1))
  241.                       ((R:SylStructure.parent.R:Word.p.gpos is det)
  242.                        (((0 0.290323) (1 0.709677) 1))
  243.                        ((R:SylStructure.parent.R:Word.p.gpos is in)
  244.                         (((0 0.3) (1 0.7) 1))
  245.                         ((syl_break is 1)
  246.                          (((0 0.289157) (1 0.710843) 1))
  247.                          ((p.syl_break is 4)
  248.                           (((0 0.352941) (1 0.647059) 1))
  249.                           ((n.syl_break is 0)
  250.                            (((0 0.311475) (1 0.688525) 1))
  251.                            ((syl_break is 4)
  252.                             (((0 0.4) (1 0.6) 1))
  253.                             (((0 0.581395) (1 0.418605) 0)))))))))))
  254.                    (((0 1) (1 0) 0)))))))))
  255.             ((stress is 0)
  256.              ((R:SylStructure.parent.R:Word.n.gpos is 0)
  257.               (((0 0.121212) (1 0.878788) 1))
  258.               ((next_accent < 2.4)
  259.                ((R:SylStructure.parent.gpos is content)
  260.                 ((position_type is mid)
  261.                  (((0 0.176895) (1 0.823105) 1))
  262.                  ((p.syl_break is 1)
  263.                   (((0 0.229167) (1 0.770833) 1))
  264.                   ((syl_break is 4)
  265.                    (((0 0.242775) (1 0.757225) 1))
  266.                    ((p.syl_break is 0)
  267.                     ((n.R:SylStructure.parent.gpos is in)
  268.                      (((0 0.253521) (1 0.746479) 1))
  269.                      ((R:SylStructure.parent.R:Word.p.gpos is in)
  270.                       (((0 0.262774) (1 0.737226) 1))
  271.                       ((last_accent < 2.1)
  272.                        ((n.R:SylStructure.parent.gpos is aux)
  273.                         (((0 0.304348) (1 0.695652) 1))
  274.                         ((next_accent < 1.2)
  275.                          ((n.R:SylStructure.parent.gpos is cc)
  276.                           (((0 0.291667) (1 0.708333) 1))
  277.                           ((syl_break is 1)
  278.                            ((n.syl_break is 4)
  279.                             (((0 0.344828) (1 0.655172) 1))
  280.                             ((R:SylStructure.parent.R:Word.p.gpos is det)
  281.                              (((0 0.364706) (1 0.635294) 1))
  282.                              ((n.syl_break is 4)
  283.                               (((0 0.384615) (1 0.615385) 1))
  284.                               ((last_accent < 1.2)
  285.                                ((p.accented is 0)
  286.                                 (((0 0.584906) (1 0.415094) 0))
  287.                                 ((n.accented is 0)
  288.                                  ((R:SylStructure.parent.R:Word.p.gpos is content)
  289.                                   (((0 0.41) (1 0.59) 1))
  290.                                   (((0 0.6) (1 0.4) 0)))
  291.                                  (((0 0.333333) (1 0.666667) 1))))
  292.                                (((0 0.380952) (1 0.619048) 1))))))
  293.                            ((p.accented is 0)
  294.                             (((0 0.183673) (1 0.816327) 1))
  295.                             ((n.R:SylStructure.parent.gpos is content)
  296.                              ((n.stress is 0)
  297.                               (((0 0.295455) (1 0.704545) 1))
  298.                               ((R:SylStructure.parent.R:Word.p.gpos is content)
  299.                                ((n.syl_break is 1)
  300.                                 (((0 0.5) (1 0.5) 0))
  301.                                 (((0 0.40625) (1 0.59375) 1)))
  302.                                (((0 0.333333) (1 0.666667) 1))))
  303.                              (((0 0.2) (1 0.8) 1))))))
  304.                          (((0 0.3) (1 0.7) 1))))
  305.                        (((0 0.302326) (1 0.697674) 1)))))
  306.                     (((0 0.25) (1 0.75) 1))))))
  307.                 (((0 0.173913) (1 0.826087) 1)))
  308.                (((0 0.166667) (1 0.833333) 1))))
  309.              (((0 1) (1 0) 0))))
  310.            (((0 0.2) (1 0.8) 1)))))))))
  311.     (((0 0.15) (1 0.85) 1)))))))
  312.  
  313. (defvar postlex_mrpa_r_cart_tree
  314. '((name is r)
  315.    ((R:Segment.n.ph_vc is -)
  316.     ((delete))
  317.     ((nil)))
  318.    ((nil)))
  319. "postlex_mrpa_r_cart_tree
  320. For remove final R when not between vowels.")
  321.  
  322. (define (postlex_apos_s_check utt)
  323.   "(postlex_apos_s_check UTT)
  324. Deal with possesive s for English (American and British).  Delete
  325. schwa of 's if previous is not a fricative or affricative, and
  326. change voiced to unvoiced s if previous is not voiced."
  327.   (mapcar
  328.    (lambda (seg)
  329.      (if (string-equal "'s" (item.feat 
  330.                  seg "R:SylStructure.parent.parent.name"))
  331.      (if (string-equal "a" (item.feat seg 'ph_vlng))
  332.          (if (and (member_string (item.feat seg 'p.ph_ctype) 
  333.                      '(f a))
  334.               (not (member_string
  335.                 (item.feat seg "p.ph_cplace") 
  336.                 '(d b g))))
  337.          t;; don't delete schwa
  338.          (item.delete seg))
  339.          (if (string-equal "-" (item.feat seg "p.ph_cvox"))
  340.          (item.set_name seg "s")))));; from "z"
  341.    (utt.relation.items utt 'Segment))
  342.   utt)
  343.  
  344. (provide 'postlex)
  345.