home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / fest-141.zip / festival / lib / voices / english / us3_mbrola / festvox / us3_mbrola.scm next >
Text File  |  1999-06-10  |  8KB  |  197 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;                                                                       ;;
  3. ;;;                Centre for Speech Technology Research                  ;;
  4. ;;;                     University of Edinburgh, UK                       ;;
  5. ;;;                       Copyright (c) 1996-1999                         ;;
  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. ;;;  A voice using the MBROLA us3 database
  34. ;;;  This uses the standard kal/ked top end and executes the external
  35. ;;;  mbrola program to form the waveform.
  36. ;;;
  37. ;;;  Note this requires MBROLA which has its own licence different
  38. ;;;  from the one above
  39. ;;;
  40. ;;;
  41. ;;;  To install
  42. ;;;  Get the mrbola programs and us3 database from 
  43. ;;;     http://tcts.fpms.ac.be/synthesis/mbrola.html
  44. ;;;  1) put the mbrola executable in festival/lib/etc/[OSTYPE]/
  45. ;;;     where [OSTYPE] is the os type of your installation, there
  46. ;;;     will already be a directory of the appropriate name in
  47. ;;;     festival/lib/etc/ after you have installed festival (if there
  48. ;;;     isn't just add mbrola to festival/lib/etc/ instead)
  49. ;;;     The directory you put it in should also contain audsp (the
  50. ;;;     the audio spooler) as that directory is already in Festival's
  51. ;;;     path.
  52. ;;;  2) put the us3 database is
  53. ;;;        festival/lib/voices/english/us2_mbrola/us3/us3
  54. ;;;     that is unpack the us3-XXXXXX.zip file in this directory
  55. ;;;  3) If you have an older version of mbrola you will need to change
  56. ;;;     the calling sequence for mbrola itself look below at *OLD MBROLA*
  57. ;;;
  58. ;;;  call (voice_us3_mrbola) in festival to select the voice or
  59. ;;;  add to siteinit.scm 
  60. ;;;     (set! voice_default 'voice_us3_mbrola)
  61. ;;;  to make it always select this voice as the default
  62.  
  63.  
  64. ;;; We need to know where the MBROLA us3 database and usradio file is
  65. ;;; You may need to change this unless you unpack this in 
  66. ;;; festival/lib/voices/english/us3_mbrola/
  67. (set! us3_mbrola_dir (cdr (assoc 'us3_mbrola voice-locations)))
  68. (set! load-path (cons (path-append us3_mbrola_dir "festvox/") load-path))
  69.  
  70. (require 'radio_phones)
  71. (require 'pos)
  72. (require 'phrase)
  73. (require 'tobi)
  74. (require 'f2bf0lr)
  75. (require 'mrpa_durs)
  76. (require 'mbrola)
  77.  
  78. (setup_cmu_lex)
  79.  
  80. (define (us3_postlex_syllabics utt)
  81. "(us3_postlex_syllabics utt)
  82. Becuase the lexicon is somewhat random in its used of syllable l n and
  83. m this is designed to post process the output inserting schwa before
  84. them.  Ideally the lexicon should be fixed."
  85.   (mapcar
  86.    (lambda (s)
  87.      (if (and (member_string (item.name s) '("l" "n" "m"))
  88.           (string-equal "coda" (item.feat s "seg_onsetcoda"))
  89.           ;; r wont exist for British English so this is OK
  90.           (string-equal "-" (item.feat s "p.ph_vc")))
  91.      (item.relation.insert 
  92.       s 'SylStructure
  93.       (item.insert s (list "@") 'before)
  94.       'before)))
  95.    (utt.relation.items utt 'Segment)))
  96.  
  97. (define (us3_hh-y_fix utt)
  98.   "(us3_hh-y-fix utt)
  99. This db is missing hh-y diphone so map y after hh to ih."
  100.   (mapcar
  101.    (lambda (s)
  102.      (if (and (string-equal "y" (item.name s))
  103.           (string-equal "hh" (item.feat s "p.name")))
  104.      (item.set_name s "ih")))
  105.    (utt.relation.items utt 'Segment)))
  106.  
  107. (define (voice_us3_mbrola)
  108. "(voice_us3_mbrola)
  109.  Set up the current voice to be an American Female speaker using
  110.  the MBROLA us3 diphone set."
  111.   (voice_reset)
  112.   (Parameter.set 'Language 'americanenglish)
  113.   (require 'radio_phones)
  114.   (Parameter.set 'PhoneSet 'radio)
  115.   (PhoneSet.select 'radio)
  116.   ;; Tokenization rules
  117.   (set! token_to_words english_token_to_words)
  118.   ;; POS tagger
  119.   (require 'pos)
  120.   (set! pos_lex_name "english_poslex")
  121.   (set! pos_ngram_name 'english_pos_ngram)
  122.   (set! pos_supported t)
  123.   (set! guess_pos english_guess_pos)   ;; need this for accents
  124.   ;; Lexicon selection
  125.   (lex.select "cmu")
  126.   (set! postlex_rules_hooks (list postlex_apos_s_check us3_hh-y_fix))
  127.   ;; Phrase prediction
  128.   (require 'phrase)
  129.   (Parameter.set 'Phrase_Method 'prob_models)
  130.   (set! phr_break_params english_phr_break_params)
  131.   ;; Accent and tone prediction
  132.   (require 'tobi)
  133.   (set! int_tone_cart_tree f2b_int_tone_cart_tree)
  134.   (set! int_accent_cart_tree f2b_int_accent_cart_tree)
  135.  
  136.   (set! postlex_vowel_reduce_cart_tree 
  137.     postlex_vowel_reduce_cart_data)
  138.   ;; F0 prediction
  139.   (require 'f2bf0lr)
  140.   (set! f0_lr_start f2b_f0_lr_start)
  141.   (set! f0_lr_mid f2b_f0_lr_mid)
  142.   (set! f0_lr_end f2b_f0_lr_end)
  143.   (Parameter.set 'Int_Method Intonation_Tree)
  144.   (set! int_lr_params
  145.     '((target_f0_mean 105) (target_f0_std 16)
  146.       (model_f0_mean 170) (model_f0_std 34)))
  147.   (Parameter.set 'Int_Target_Method Int_Targets_LR)
  148.   ;; Duration prediction
  149.   (require 'usdurtreeZ)
  150.   (set! duration_cart_tree us_duration_cart_tree)
  151.   (set! duration_ph_info us_durs)
  152.   (Parameter.set 'Duration_Method Duration_Tree_ZScores)
  153.   (Parameter.set 'Duration_Stretch 1.0)
  154.   ;; Waveform synthesizer: MBROLA us3 diphones
  155.   (Parameter.set 'Synth_Method MBROLA_Synth)
  156.   ;;  Because we need an extra parameter in the new version of mbrola
  157.   ;;  we add that parameter to the database "name"
  158.   (set! mbrola_progname "mbrola")
  159.   ;;  Newer versions of mbrola require the -I flag
  160.   (set! mbrola_database 
  161.     (format 
  162.      nil
  163.      "-I %s%s %s%s "
  164.          us3_mbrola_dir "usradio"
  165.      us3_mbrola_dir "us3/us3" 
  166.      ))
  167.   ;; *OLD MBROLA* doesn't require the -I flag and does it by argumnent order
  168.   ;; uncomment the following if you are using an older version of mbrola
  169. ;  (set! mbrola_database 
  170. ;    (format 
  171. ;     nil
  172. ;     "%s%s %s%s "
  173. ;     us3_mbrola_dir "us3/us3" 
  174. ;         us3_mbrola_dir "usradio"
  175. ;     ))
  176.  
  177.   (set! current-voice 'us3_mbrola)
  178. )
  179.  
  180. (proclaim_voice
  181.  'us3_mbrola
  182.  '((language english)
  183.    (gender male)
  184.    (dialect american)
  185.    (description
  186.     "This voice provides a American English male voice using the
  187.      MBROLA synthesis method.  It uses a 
  188.      modified CMU lexicon for pronunciations.
  189.      Prosodic phrasing is provided by a statistically trained model
  190.      using part of speech and local distribution of breaks.  Intonation
  191.      is provided by a CART tree predicting ToBI accents and an F0 
  192.      contour generated from a model trained from natural speech.  The
  193.      duration model is also trained from data using a CART tree.")))
  194.  
  195. (provide 'us3_mbrola)
  196.  
  197.