Debian Codegraph @

lib/voices/english/rab_diphone/festvox/rab_diphone.scm

raw
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 ;;; Set up rab_diphones using the standard UniSyn diphone synthesizer
34 ;;;
35 ;;; Roger diphones: male RP English collected October 1996
36 ;;;
37
38 (defvar rab_diphone_dir (cdr (assoc 'rab_diphone voice-locations))
39 "rab_diphone_dir
40 The default directory for the rab diphone database.")
41
42 (require 'mrpa_phones)
43 (require 'pos)
44 (require 'phrase)
45 (require 'tobi)
46 (require 'f2bf0lr)
47 (require 'mrpa_durs)
48 (require 'gswdurtreeZ)
49 (require_module 'UniSyn)
50
51 (setup_oald_lex)
52
53 ;; set this to lpc or psola
54 (defvar rab_sigpr 'lpc)
55 ;; Rset this to ungroup for ungrouped version
56 (defvar rab_groupungroup 'group)
57
58 (if (probe_file (path-append rab_diphone_dir "group/rablpc16k.group"))
59 (defvar rab_index_file
60 (path-append rab_diphone_dir "group/rablpc16k.group"))
61 (defvar rab_index_file
62 (path-append rab_diphone_dir "group/rablpc8k.group")))
63
64 (set! rab_psola_sep
65 (list
66 '(name "rab_psola_sep")
67 (list 'index_file (path-append rab_diphone_dir "dic/diphdic_full.est"))
68 '(grouped "false")
69 (list 'coef_dir (path-append rab_diphone_dir "pm"))
70 (list 'sig_dir (path-append rab_diphone_dir "wav"))
71 '(coef_ext ".pm")
72 '(sig_ext ".wav")))
73
74 (set! rab_lpc_sep
75 (list
76 '(name "rab_lpc_sep")
77 (list 'index_file (path-append rab_diphone_dir "dic/diphdic_full.est"))
78 '(grouped "false")
79 (list 'coef_dir (path-append rab_diphone_dir "lpc"))
80 (list 'sig_dir (path-append rab_diphone_dir "lpc"))
81 '(coef_ext ".lpc")
82 '(sig_ext ".res")))
83
84 (set! rab_psola_group
85 (list
86 '(name "rab_psola_group")
87 (list 'index_file
88 (path-append rab_diphone_dir "group/rab.group"))
89 '(grouped "true")))
90
91 (set! rab_lpc_group
92 (list
93 '(name "rab_lpc_group")
94 (list 'index_file rab_index_file)
95 '(alternates_left ((i ii) (ll l) (u uu) (i@ ii) (uh @) (a aa)
96 (u@ uu) (w @) (o oo) (e@ ei) (e ei)
97 (r @)))
98 '(alternates_right ((i ii) (ll l) (u uu) (i@ ii)
99 (y i) (uh @) (r @) (w @)))
100 '(default_diphone @-@@)
101 '(grouped "true")))
102
103 ;;; Setup the desried DB
104 (cond
105 ((and (eq rab_sigpr 'psola)
106 (eq rab_groupungroup 'group))
107 (set! rab_db_name (us_diphone_init rab_psola_group)))
108 ((and (eq rab_sigpr 'psola)
109 (eq rab_groupungroup 'ungroup))
110 (set! rab_db_name (us_diphone_init rab_psola_sep)))
111 ((and (eq rab_sigpr 'lpc)
112 (eq rab_groupungroup 'group))
113 (set! rab_db_name (us_diphone_init rab_lpc_group)))
114 ((and (eq rab_sigpr 'lpc)
115 (eq rab_groupungroup 'ungroup))
116 (set! rab_db_name (us_diphone_init rab_lpc_sep))))
117
118 (define (rab_postlex_syllabics utt)
119 "(rab_postlex_syllabics utt)
120 Because the lexicon is somewhat random in its used of syllable l n and
121 m this is designed to post process the output inserting schwa before
122 them. Ideally the lexicon should be fixed."
123 (mapcar
124 (lambda (s)
125 (if (and (member_string (item.name s) '("l" "n" "m"))
126 (string-equal "coda" (item.feat s "seg_onsetcoda"))
127 (not (member_string (item.feat s "p.name") '(l r)))
128 (string-equal "-" (item.feat s "p.ph_vc")))
129 (item.relation.insert
130 s 'SylStructure
131 (item.insert s (list "@") 'before)
132 'before)))
133 (utt.relation.items utt 'Segment)))
134
135 (define (rab_diphone_const_clusters utt)
136 "(rab_diphone_const_clusters UTT)
137 Identify consonant clusters, dark ls etc in the segment item
138 ready for diphone resynthesis. This may be called as a post lexical
139 rule through poslex_rule_hooks."
140 (mapcar
141 (lambda (s) (rab_diphone_fix_phone_name utt s))
142 (utt.relation.items utt 'Segment))
143 utt)
144
145 (define (rab_diphone_fix_phone_name utt seg)
146 "(rab_diphone_fix_phone_name UTT SEG)
147 Add the feature diphone_phone_name to given segment with the appropriate
148 name for constructing a diphone. Basically adds _ if either side is part
149 of the same consonant cluster, adds $ either side if in different
150 syllable for preceding/succeeding vowel syllable, and converts l to ll
151 in coda part of syllables."
152 (let ((name (item.name seg)))
153 (cond
154 ((string-equal name "#") t)
155 ((string-equal "-" (item.feat seg 'ph_vc))
156 (if (and (member_string name '(r w y l))
157 (member_string (item.feat seg "p.name") '(p t k b d g))
158 (item.relation.prev seg "SylStructure"))
159 (item.set_feat seg "us_diphone_right" (format nil "_%s" name)))
160 (if (and (member_string name '(w y l m n p t k))
161 (string-equal (item.feat seg "p.name") 's)
162 (item.relation.prev seg "SylStructure"))
163 (item.set_feat seg "us_diphone_right" (format nil "_%s" name)))
164 (if (and (string-equal name 's)
165 (member_string (item.feat seg "n.name") '(w y l m n p t k))
166 (item.relation.next seg "SylStructure"))
167 (item.set_feat seg "us_diphone_left" (format nil "%s_" name)))
168 (if (and (member_string name '(p t k b d g))
169 (member_string (item.feat seg "n.name") '(r w y l))
170 (item.relation.next seg "SylStructure"))
171 (item.set_feat seg "us_diphone_left" (format nil "%s_" name)))
172 (if (and (member_string name '(p k b d g))
173 (string-equal "+" (item.feat seg 'p.ph_vc))
174 (not (member_string (item.feat seg "p.name") '(@ aa o)))
175 (not (item.relation.prev seg "SylStructure")))
176 (item.set_feat seg "us_diphone_right" (format nil "$%s" name)))
177 (if (and (member_string name '(p t k b d g))
178 (string-equal "+" (item.feat seg 'n.ph_vc))
179 (not (member_string (item.feat seg "n.name") '(@ aa)))
180 (not (item.relation.next seg "SylStructure")))
181 (item.set_feat seg "us_diphone_left" (format nil "%s$" name)))
182 (if (and (string-equal "l" name)
183 (string-equal "+" (item.feat seg "p.ph_vc"))
184 (not (string-equal "a" (item.feat seg "p.ph_vlng")))
185 (item.relation.prev seg 'SylStructure))
186 (item.set_feat seg "us_diphone_right" "ll"))
187 (if (and (member_string name '(ch jh))
188 (string-equal "+" (item.feat seg 'p.ph_vc)))
189 (item.set_feat seg "us_diphone_right" "t"))
190 )
191 )))
192
193 (define (voice_rab_diphone)
194 "(voice_rab_diphone)
195 Set up the current voice to be a British male RP (Roger) speaker using
196 the rab diphone set."
197 (voice_reset)
198 (Parameter.set 'Language 'britishenglish)
199 ;; Phone set
200 (Parameter.set 'PhoneSet 'mrpa)
201 (PhoneSet.select 'mrpa)
202 ;; Tokenization rules
203 (set! token_to_words english_token_to_words)
204 ;; POS tagger
205 (set! pos_lex_name "english_poslex")
206 (set! pos_ngram_name 'english_pos_ngram)
207 (set! pos_supported t)
208 (set! guess_pos english_guess_pos) ;; need this for accents
209 ;; Lexicon selection
210 (lex.select "oald")
211 (set! postlex_rules_hooks (list postlex_apos_s_check
212 rab_postlex_syllabics))
213 ;; Phrase prediction
214 (Parameter.set 'Phrase_Method 'prob_models)
215 (set! phr_break_params english_phr_break_params)
216 ;; Accent and tone prediction
217 (set! int_tone_cart_tree f2b_int_tone_cart_tree)
218 (set! int_accent_cart_tree f2b_int_accent_cart_tree)
219 ;; F0 prediction
220 (set! f0_lr_start f2b_f0_lr_start)
221 (set! f0_lr_mid f2b_f0_lr_mid)
222 (set! f0_lr_end f2b_f0_lr_end)
223 (Parameter.set 'Int_Method Intonation_Tree)
224 (set! int_lr_params
225 '((target_f0_mean 105) (target_f0_std 14)
226 (model_f0_mean 170) (model_f0_std 34)))
227 (Parameter.set 'Int_Target_Method Int_Targets_LR)
228 ;; Duration prediction -- use gsw durations
229 (set! duration_cart_tree gsw_duration_cart_tree)
230 (set! duration_ph_info gsw_durs)
231 (Parameter.set 'Duration_Method Duration_Tree_ZScores)
232 (Parameter.set 'Duration_Stretch 1.05)
233 ;; Waveform synthesizer: Roger diphones
234 ;; This assigned the diphone names from their context (_ $ etc)
235 (set! UniSyn_module_hooks (list rab_diphone_const_clusters ))
236 (set! us_abs_offset 0.0)
237 (set! window_factor 1.0)
238 (set! us_rel_offset 0.0)
239 (set! us_gain 0.9)
240
241 (Parameter.set 'Synth_Method 'UniSyn)
242 (Parameter.set 'us_sigpr rab_sigpr)
243 (us_db_select rab_db_name)
244
245 (set! current-voice 'rab_diphone)
246 )
247
248 (proclaim_voice
249 'rab_diphone
250 '((language english)
251 (gender male)
252 (dialect british)
253 (description
254 "This voice provides a British RP English male voice using a
255 residual excited LPC diphone synthesis method. It uses a
256 modified Oxford Advanced Learners' Dictionary for pronunciations.
257 Prosodic phrasing is provided by a statistically trained model
258 using part of speech and local distribution of breaks. Intonation
259 is provided by a CART tree predicting ToBI accents and an F0
260 contour generated from a model trained from natural speech. The
261 duration model is also trained from data using a CART tree.")))
262
263 (provide 'rab_diphone)