Debian Codegraph @

lib/voices/spanish/el_diphone/festvox/el_diphone.scm

raw symbols SCIP
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 ;;; A Castilian Spanish male voice
35 ;;;
36 ;;; Authors: Alistair Conkie (initially), Borja Etxebarria, Alan W Black
37 ;;; Eduardo Lopez (who did the diphones)
38 ;;;
39 ;;; Eduardo Lopez, MSc student DAI 1992 made (and spoke) the diphones.
40 ;;;
41 ;;; Note although the front end is free the diphones are restricted to
42 ;;; non-commercial use only.
43 ;;;
44 ;;; This is by no means complete:
45 ;;; Intonation is pretty weak and without good phrase breaks
46 ;;; the continous downward slope with small accents is not good
47 ;;; Numbers are not dealt with properly when they are supposed to
48 ;;; inflect for gender.
49 ;;; There's no part of speech tagging which woudl allow number matching
50 ;;; phrasing etc.
51 ;;; The diphone database is missing accented vowels and diphthongs
52 ;;; making small but not as good as it could be.
53 ;;; It hasn't really been tested thoroughly
54 ;;;
55
56 ;;; Add the directory contains general spanish stuff to load-path
57 (defvar spanish_el_dir (cdr (assoc 'el_diphone voice-locations)))
58 (set! load-path (cons (path-append spanish_el_dir "festvox/") load-path))
59
60 ;;; other files we need
61 (require 'spanlex)
62 (require 'spanint)
63 (require 'sptoken)
64 (require_module 'UniSyn)
65
66 (defPhoneSet
67 spanish
68 ;;; Phone Features
69 (;; vowel or consonant
70 (vc + -)
71 ;; vowel length: short long dipthong schwa
72 (vlng s l d a 0)
73 ;; vowel height: high mid low
74 (vheight 1 2 3 -)
75 ;; vowel frontness: front mid back
76 (vfront 1 2 3 -)
77 ;; lip rounding
78 (vrnd + -)
79 ;; consonant type: stop fricative affricative nasal liquid
80 (ctype s f a n l 0)
81 ;; place of articulation: labial alveolar palatal labio-dental
82 ;; dental velar
83 (cplace l a p b d v 0)
84 ;; consonant voicing
85 (cvox + -)
86 )
87 ;; borja: all the features are almost ok, only some problems:
88 ;; r is a tap, rr is a trill. We would need "vibrant". Now, coded as liquid.
89 ;; l and ll are lateral. Now, coded as liquid (probably it's the samething)
90 ;; The bdg/BDG distinction (stop/aproximant) is not done.
91 ;; The i and u aproximants (sampa j and w, labio, agua) are not considered,
92 ;; normal i and u used instead.
93 ;; The ficative 'y' (sampa jj, ayer) is not considered, ll used instead.
94 (
95 (# - 0 - - - 0 0 -)
96 (a + l 3 2 - 0 0 -)
97 (e + l 2 1 - 0 0 -)
98 (i + l 1 1 - 0 0 -)
99 (o + l 2 3 + 0 0 -)
100 (u + l 1 3 + 0 0 -)
101 (i0 + s 1 1 - 0 0 -) ;; weak vowels in dipthongs
102 (u0 + s 1 3 + 0 0 -) ;; weak vowels in dipthongs
103
104 (a1 + l 3 2 - 0 0 -)
105 (e1 + l 2 1 - 0 0 -)
106 (i1 + l 1 1 - 0 0 -)
107 (o1 + l 2 3 + 0 0 -)
108 (u1 + l 1 3 + 0 0 -)
109
110 (p - 0 - - - s l -)
111 (t - 0 - - - s d -)
112 (k - 0 - - - s v -)
113 (b - 0 - - - s l +)
114 (d - 0 - - - s d +)
115 (g - 0 - - - s v +)
116
117 (f - 0 - - - f b -)
118 (th - 0 - - - f d -)
119 (s - 0 - - - f a -)
120 (x - 0 - - - f v -)
121
122 (ch - 0 - - - a p -)
123
124 (m - 0 - - - n l +)
125 (n - 0 - - - n a +)
126 (ny - 0 - - - n p +)
127
128 (l - 0 - - - l a +)
129 (ll - 0 - - - l p +)
130
131 (r - 0 - - - l a +)
132 (rr - 0 - - - l a +)
133 )
134 )
135 (PhoneSet.silences '(#))
136
137 ;;; Part of speech down by crude lookup using gpos
138 (set! spanish_guess_pos
139 '((fn
140 el la lo los las
141 un una unos unas
142 ;;
143 mi tu su mis tus sus
144 nuestra vuestra nuestras vuestras nuestro vuestro nuestros vuestros
145 me te le nos os les se
146 al del
147 ;;
148 a ante bajo cabe con contra de desde en entre
149 hacia hasta para por sin sobre tras mediante
150 ;;
151 y e ni mas o "\'o" u pero aunque si
152 porque que quien cuando como donde cual cuan
153 aun pues tan mientras sino )
154 (partnums
155 dieci venti trentai cuarentai cincuentai sesentai ochentai noventai)
156 )
157 )
158
159 ;;; Phrase breaks
160 ;;; use punctuation
161 (set! spanish_phrase_cart_tree
162 '
163 ((lisp_token_end_punc in ("'" "\"" "?" "." "," ":" ";"))
164 ((B))
165 ((n.name is 0)
166 ((B))
167 ((NB)))))
168
169 ;;; Intonation
170 (set! spanish_accent_cart_tree
171 '
172 (
173 (R:SylStructure.parent.gpos is content)
174 ( (stress is 1)
175 ((Accented))
176 ((NONE))
177 )
178 )
179 )
180
181
182 ;;; Duration
183 (set! spanish_dur_tree
184 '
185 ((R:SylStructure.parent.R:Syllable.p.syl_break > 1 ) ;; clause initial
186 ((R:SylStructure.parent.stress is 1)
187 ((1.5))
188 ((1.2)))
189 ((R:SylStructure.parent.syl_break > 1) ;; clause final
190 ((R:SylStructure.parent.stress is 1)
191 ((1.5))
192 ((1.2)))
193 ((R:SylStructure.parent.stress is 1)
194 ((ph_vc is +)
195 ((1.2))
196 ((1.0)))
197 ((1.0))))))
198
199 (set! spanish_el_phone_data
200 '(
201 (# 0.0 0.250)
202 (a 0.0 0.080)
203 (e 0.0 0.080)
204 (i 0.0 0.070)
205 (o 0.0 0.080)
206 (u 0.0 0.070)
207 (i0 0.0 0.040)
208 (u0 0.0 0.040)
209 (a1 0.0 0.090)
210 (e1 0.0 0.090)
211 (i1 0.0 0.080)
212 (o1 0.0 0.090)
213 (u1 0.0 0.080)
214 (b 0.0 0.065)
215 (ch 0.0 0.135)
216 (d 0.0 0.060)
217 (f 0.0 0.100)
218 (g 0.0 0.080)
219 (j 0.0 0.100)
220 (k 0.0 0.100)
221 (l 0.0 0.080)
222 (ll 0.0 0.105)
223 (m 0.0 0.070)
224 (n 0.0 0.080)
225 (ny 0.0 0.110)
226 (p 0.0 0.100)
227 (r 0.0 0.030)
228 (rr 0.0 0.080)
229 (s 0.0 0.110)
230 (t 0.0 0.085)
231 (th 0.0 0.100)
232 (x 0.0 0.130)
233 ))
234
235 (set! el_lpc_sep
236 (list
237 '(name "el_lpc_sep")
238 (list 'index_file (path-append spanish_el_dir "dic/eldiph.est"))
239 '(grouped "false")
240 (list 'coef_dir (path-append spanish_el_dir "lpc"))
241 (list 'sig_dir (path-append spanish_el_dir "lpc"))
242 '(coef_ext ".lpc")
243 '(sig_ext ".res")
244 '(default_diphone "#-#")))
245
246 (set! el_lpc_group
247 (list
248 '(name "el_lpc_group")
249 (list 'index_file
250 (path-append spanish_el_dir "group/ellpc11k.group"))
251 '(grouped "true")
252 '(default_diphone "#-#")))
253
254 ;; Go ahead and set up the diphone db
255 (us_diphone_init el_lpc_group)
256
257 (define (el_diphone_fix utt)
258 "(el_diphone_fix UTT)
259 Map accents vowels to unaccented ones because the db doesn't
260 have them."
261 (mapcar
262 (lambda (s)
263 (let ((name (item.name s)))
264 (cond
265 ((string-matches name ".1")
266 (item.set_feat s "us_diphone" (string-before name "1")))
267 ((string-matches name ".0")
268 (item.set_feat s "us_diphone" (string-before name "0"))))))
269 (utt.relation.items utt 'Segment))
270 utt)
271
272 (define (spanish_voice_reset)
273 "(spanish_voice_reset)
274 Reset global variables back to previous voice."
275 (set! token.prepunctuation spanish_previous_tok_prepunc)
276 )
277
278 ;;; Full voice definition
279 (define (voice_el_diphone)
280 "(voice_spanish_el)
281 Set up synthesis for Male Spanish speaker: Eduardo Lopez"
282 (voice_reset)
283 (Parameter.set 'Language 'spanish)
284 ;; Phone set
285 (Parameter.set 'PhoneSet 'spanish)
286 (PhoneSet.select 'spanish)
287
288 ;; numeric expansion
289 (Parameter.set 'Token_Method 'Token_Any)
290 (set! token_to_words spanish_token_to_words)
291
292 ;; Because of use of ' for accents remove it from prepunctuation
293 (set! spanish_previous_tok_prepunc token.prepunctuation)
294 (set! token.prepunctuation "\"`({[")
295
296 ;; No pos prediction (get it from lexicon)
297 (set! pos_lex_name nil)
298 ;; Phrase break prediction by punctuation
299 (set! pos_supported nil) ;; well not real pos anyhow
300 ;; Phrasing
301 (set! phrase_cart_tree spanish_phrase_cart_tree)
302 (Parameter.set 'Phrase_Method 'cart_tree)
303 ;; Lexicon selection
304 (lex.select "spanish")
305
306 ;; Accent and tone prediction
307 (set! int_accent_cart_tree spanish_accent_cart_tree)
308
309 (Parameter.set 'Int_Target_Method 'Simple)
310
311 (Parameter.set 'Int_Method 'General)
312 (set! int_general_params (list (list 'targ_func targ_func1)))
313 (set! guess_pos spanish_guess_pos)
314
315 ;; Duration prediction
316 (set! duration_cart_tree spanish_dur_tree)
317 (set! duration_ph_info spanish_el_phone_data)
318 (Parameter.set 'Duration_Method 'Tree_ZScores)
319
320 ;; Waveform synthesizer: diphones
321 (set! UniSyn_module_hooks (list el_diphone_fix))
322 (set! us_abs_offset 0.0)
323 (set! window_factor 1.0)
324 (set! us_rel_offset 0.0)
325 (set! us_gain 0.9)
326
327 (Parameter.set 'Synth_Method 'UniSyn)
328 (Parameter.set 'us_sigpr 'lpc)
329 (us_db_select 'el_lpc_group)
330
331 ;; set callback to restore some original values changed by the spanish voice
332 (set! current_voice_reset spanish_voice_reset)
333
334 (set! current-voice 'el_diphone)
335 )
336
337 (proclaim_voice
338 'el_diphone
339 '((language spanish)
340 (gender male)
341 (dialect castilian)
342 (description
343 "This voice provides a Castilian Spanish male voice using a
344 residual excited LPC diphone synthesis method. The lexicon
345 is provived by a set of letter to sound rules producing pronunciation
346 accents and syllabification. The durations, intonation and
347 prosodic phrasing are minimal but are acceptable for simple
348 examples.")))
349
350 (provide 'el_diphone)