home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / fest-141.zip / festival / lib / intonation.scm < prev    next >
Text File  |  1999-05-30  |  7KB  |  152 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. ;;;  Basic Intonation modules.  These call appropriate sub-modules
  35. ;;;  depending on the chosen intonation methods
  36. ;;;
  37. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  38.  
  39. ;;;  These modules should predict intonation events/labels
  40. ;;;  based on information in the phrase and word streams
  41.  
  42. (define (Intonation utt)
  43. "(Intonation utt)                                
  44. Select between different intonation modules depending on the Parameter
  45. Int_Method.  Currently offers three types: Simple, hats on each content
  46. word; ToBI, a tree method for predicting ToBI accents; and Default a
  47. really bad method with a simple downward sloping F0.  This is the first
  48. of a two-stage intonation prediction process.  This adds accent-like
  49. features to syllables, the second, Int_Targets generates the F0 contour
  50. itself. [see Intonation]"
  51.   (let ((rval (apply_method 'Int_Method utt)))
  52.     (Parameter.get 'Int_Method)
  53.     (cond   
  54.      (rval rval) ;; new style
  55.      ((eq 'Simple (Parameter.get 'Int_Method))
  56.       (Intonation_Simple utt))
  57.      ((eq 'ToBI (Parameter.get 'Int_Method))
  58.       (Intonation_Tree utt))
  59.      ((eq 'General (Parameter.get 'Int_Method))
  60.       (Intonation_Simple utt))  ;; yes this is a duplication
  61.      (t
  62.       (Intonation_Default utt)))))
  63.  
  64.  
  65. ;;;  These modules should create an actual F0 contour based on the
  66. ;;;  the existing intonational events/labels etc
  67. ;;;  Specifically this is called after durations have been predicted
  68.  
  69. (define (Int_Targets utt)
  70. "(Int_Targets utt)
  71. The second stage in F0 prediction.  This generates F0 targets 
  72. related to segments using one of three methods, a simple hat, 
  73. linear regression based on ToBI markings, and a simple declining
  74. slope.  This second part deals with actual F0 values and durations,
  75. while the previous section only deals with accent (and boundary tone)
  76. assignment. [see Intonation]"
  77.   (let ((rval (apply_method 'Int_Target_Method utt)))
  78.     (cond
  79.      (rval rval) ;; new style
  80.      ((eq 'Simple (Parameter.get 'Int_Method))
  81.       (Int_Targets_Simple utt))
  82.      ((eq 'ToBI (Parameter.get 'Int_Method))
  83.       (Int_Targets_LR utt))
  84.      ((eq 'General (Parameter.get 'Int_Method))
  85.       (Int_Targets_General utt))
  86.      (t
  87.       (Int_Targets_Default utt)))))
  88.  
  89. ;;;
  90. ;;;  A tree that adds accents (H) to all content words
  91. ;;;  simple but better than nothing at all
  92. ;;;
  93. (set! simple_accent_cart_tree
  94.  '
  95.   ((R:SylStructure.parent.gpos is content)
  96.    ((stress is 1)
  97.     ((Accented))
  98.     ((position_type is single)
  99.      ((Accented))
  100.      ((NONE))))
  101.    ((NONE))))
  102.  
  103. (defvar duffint_params '((start 130) (end 110))
  104.   "duffint_params
  105. Default parameters for Default (duff) intonation target generation.
  106. This is an assoc list of parameters.  Two parameters are supported
  107. start specifies the start F0 in Hertz for an utterance, and end specifies
  108. the end.")
  109.  
  110. ;;;
  111. ;;;  For simple testing, this function adds fixed duration and 
  112. ;;;  monotone intonation to a set of phones
  113. ;;;
  114. (defvar FP_F0 120
  115. "FP_F0
  116. In using Fixed_Prosody as used in Phones type utterances and hence
  117. SayPhones, this is the value in Hertz for the monotone F0.")
  118. (defvar FP_duration 100
  119. "FP_duration
  120. In using Fixed_Prosody as used in Phones type utterances and hence
  121. SayPhones, this is the fix value in ms for phone durations.")
  122.  
  123. (define (Fixed_Prosody utt)
  124. "(Fixed_Prosody UTT)
  125. Add fixed duration and fixed monotone F0 to the sgements in UTT.
  126. Uses values of FP_duration and FP_F0 as fixed values."
  127.   (let (utt1
  128.     (dur_stretch (Parameter.get 'Duration_Stretch))
  129.     (orig_duffint_params duffint_params))
  130.     (Parameter.set 'Duration_Stretch (/ FP_duration 100.0))
  131.     (set! duffint_params (list (list 'start FP_F0) (list 'end FP_F0)))
  132.  
  133.     (set! utt1 (Duration_Default utt))
  134.     (set! utt1 (Int_Targets_Default utt1))
  135.  
  136.     ;; Reset Parameter values back
  137.     (Parameter.set 'Duration_Stretch dur_stretch)
  138.     (set! duffint_params orig_duffint_params)
  139.  
  140.     utt1
  141.     )
  142. )
  143.  
  144. (define (segment_dpitch seg)
  145. "(segment_dpitch UTT SEG)
  146. Returns delta pitch, this pitch minus previous pitch."
  147.   (- 
  148.    (parse-number (item.feat utt seg 'seg_pitch))
  149.    (parse-number (item.feat utt seg 'R:Segment.p.seg_pitch))))
  150.  
  151. (provide 'intonation)
  152.