| 1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2 |
;;; ;; |
| 3 |
;;; Accent and F0 prediction ;; |
| 4 |
;;; ;; |
| 5 |
;;; Phrase breaks use punctuation ;; |
| 6 |
;;; ;; |
| 7 |
;;; Copyright (c) 2005, DONLab, Dept. of CS&E, ;; |
| 8 |
;;; IIT Madras <[email protected]> ;; |
| 9 |
;;; ;; |
| 10 |
;;; This program is a part of festival-hi. ;; |
| 11 |
;;; ;; |
| 12 |
;;; festival-hi is free software; you can redistribute it and/or modify ;; |
| 13 |
;;; it under the terms of the GNU General Public License as published by ;; |
| 14 |
;;; the Free Software Foundation; either version 2 of the License, or ;; |
| 15 |
;;; (at your option) any later version. ;; |
| 16 |
;;; ;; |
| 17 |
;;; This program is distributed in the hope that it will be useful, ;; |
| 18 |
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; |
| 19 |
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; |
| 20 |
;;; GNU General Public License for more details. ;; |
| 21 |
;;; ;; |
| 22 |
;;; You should have received a copy of the GNU General Public License ;; |
| 23 |
;;; along with this program; if not, write to the Free Software ;; |
| 24 |
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ;; |
| 25 |
;;; ;; |
| 26 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 27 |
|
| 28 |
(set! hindi_phrase_cart_tree |
| 29 |
' |
| 30 |
((lisp_token_end_punc in ("." ":" "?" "!" " ")) |
| 31 |
((BB)) |
| 32 |
((lisp_token_end_punc in ("'" "\"" "," ";")) |
| 33 |
((B)) |
| 34 |
((n.name is 0) ;; end of utterance |
| 35 |
((BB)) |
| 36 |
((NB)))))) |
| 37 |
|
| 38 |
(set! hindi_accent_cart_tree |
| 39 |
' |
| 40 |
( |
| 41 |
(R:SylStructure.gpos is content) |
| 42 |
( (stress is 1) |
| 43 |
((Accented)) |
| 44 |
((NONE)) |
| 45 |
) |
| 46 |
) |
| 47 |
) |
| 48 |
;;------------- Morph tagger Start ------------------------------------------- |
| 49 |
|
| 50 |
(define (since_punctuation word) |
| 51 |
"(since_punctuation word) |
| 52 |
Number of words since last punctuation or beginning of utterance." |
| 53 |
(cond |
| 54 |
((null word) 0) ;; beginning or utterance |
| 55 |
((not (string-equal "1" (item.feat word 'p.word_break))) 0) |
| 56 |
(t |
| 57 |
(+ 1 (since_punctuation (item.prev word)))))) |
| 58 |
|
| 59 |
(define (until_punctuation word) |
| 60 |
"(until_punctuation word) |
| 61 |
Number of words until next punctuation or end of utterance." |
| 62 |
(cond |
| 63 |
((null word) 0) ;; beginning or utterance |
| 64 |
((not (string-equal "1" (item.feat word 'word_break))) 0) |
| 65 |
(t |
| 66 |
(+ 1 (until_punctuation (item.next word)))))) |
| 67 |
|
| 68 |
(set! hindi_phrase_cart_tree_2 |
| 69 |
' |
| 70 |
((lisp_token_end_punc in ("?" "." ":")) |
| 71 |
((B)) |
| 72 |
((lisp_token_end_punc in ("'" "\"" "," ";")) |
| 73 |
((B)) |
| 74 |
((n.name is 0) ;; end of utterance |
| 75 |
((BB)) |
| 76 |
((lisp_since_punctuation > 5) |
| 77 |
((lisp_until_punctuation > 5) |
| 78 |
((gpos is content) |
| 79 |
((n.gpos content) |
| 80 |
((NB)) |
| 81 |
((B))) ;; not content so a function word |
| 82 |
((NB))) ;; this is a function word |
| 83 |
((NB))) ;; to close to punctuation |
| 84 |
((NB))) ;; to soon after punctuation |
| 85 |
((NB)))))) |
| 86 |
|
| 87 |
(set! hindi_guess_pos |
| 88 |
'((in of for in on that with by at from as if that against about |
| 89 |
before because if under after over into while without |
| 90 |
through new between among until per up down) |
| 91 |
(to to) |
| 92 |
(det the a an no some this that each another those every all any |
| 93 |
these both neither no many) |
| 94 |
(md will may would can could should must ought might) |
| 95 |
(cc and but or plus yet nor) |
| 96 |
(wp who what where how when) |
| 97 |
(pps her his their its our their its mine) |
| 98 |
(aux is am are was were has have had be) |
| 99 |
; (punc "." "," ":" ";" "\"" "'" "(" "?" ")" "!") |
| 100 |
)) |
| 101 |
|
| 102 |
(define (morph_tag word) |
| 103 |
"(morph_tag word) |
| 104 |
Return the appropriate morph tag for the word." |
| 105 |
(cond |
| 106 |
((string-matches (item.name word) ".*lO") 'lO) |
| 107 |
((string-matches (item.name word) ".*tO") 'tO) |
| 108 |
((string-matches (item.name word) ".*Aru") 'Aru) |
| 109 |
((string-matches (item.name word) ".*ndi") 'ndi) |
| 110 |
((string-matches (item.name word) ".*ani") 'ani) |
| 111 |
((string-matches (item.name word) ".*lu") 'lu) |
| 112 |
((string-matches (item.name word) ".*nni") 'nni) |
| 113 |
((string-matches (item.name word) ".*Oni") 'Oni) |
| 114 |
((string-matches (item.name word) ".*chi") 'chi) |
| 115 |
((string-matches (item.name word) ".*nna") 'nna) |
| 116 |
((string-matches (item.name word) ".*na") 'na) |
| 117 |
((string-matches (item.name word) ".*ki") 'ki) |
| 118 |
((string-matches (item.name word) ".*ini") 'ini) |
| 119 |
((string-matches (item.name word) ".*gA") 'gA) |
| 120 |
((string-matches (item.name word) ".*ku") 'ku) |
| 121 |
((string-matches (item.name word) ".*nu") 'nu) |
| 122 |
((string-matches (item.name word) ".*pai") 'pai) |
| 123 |
((string-matches (item.name word) ".*la") 'la) |
| 124 |
((string-matches (item.name word) ".*.n") '.n) |
| 125 |
(t |
| 126 |
'fn) |
| 127 |
)) |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
;;---------------- Morph tagger End ------------------------------------------ |
| 132 |
|
| 133 |
;;---------------- Power contour targets -------------------------------------- |
| 134 |
|
| 135 |
(define (find_power_targets utt) |
| 136 |
"(find_power_targets utt) |
| 137 |
gives the power targets for the utt ." |
| 138 |
;(set! SEG (utt.relation.first utt 'Segment)) |
| 139 |
(set! seg (utt.relation.first utt 'Segment)) |
| 140 |
|
| 141 |
;(let ((tmpfile (make_tmp_filename)) |
| 142 |
;(ofd)) |
| 143 |
(set! ofd (fopen "tmpfile" "w")) |
| 144 |
;(let (ofd (fopen "TMP_POWER_TARGETS" "w")) |
| 145 |
;(format ofd "#\n") |
| 146 |
(while seg |
| 147 |
; (set! dur (item.feat seg 'segment_duration)) |
| 148 |
(if (string-equal (item.feat seg 'ph_vc) "+") |
| 149 |
(begin |
| 150 |
(set! dur (item.feat seg 'segment_end)) |
| 151 |
(set! pred_ene (wagon_predict seg hindi_NSK::zene_treeMAX2)) |
| 152 |
(set! mean_ene (wagon_predict seg hindi_NSK::phone_enesMAX2)) |
| 153 |
;(format t "%s %f %f %f\n" (item.name seg) dur mean_ene pred_ene) |
| 154 |
;(format ofd "%s %f %f %f\n" (item.name seg) dur mean_ene pred_ene) |
| 155 |
(format ofd "%f 123 %f\n" dur (/ pred_ene mean_ene)) |
| 156 |
;(format ofd "%s %f 123 %f\n" (item.name seg) dur (/ pred_ene mean_ene)) |
| 157 |
(format t "%s %f 123 %f\n" (item.name seg) dur (/ pred_ene mean_ene)) |
| 158 |
)) |
| 159 |
(set! seg (item.next seg)) |
| 160 |
) |
| 161 |
(fclose ofd) |
| 162 |
) |
| 163 |
|
| 164 |
|
| 165 |
;;---------------- Power contour targets -------------------------------------- |
| 166 |
|
| 167 |
;; ADDED BY NSK |
| 168 |
|
| 169 |
|
| 170 |
(set! hindi_el_int_simple_params |
| 171 |
'( |
| 172 |
;; These number may be modified the speakers range. |
| 173 |
;; Even though we offer an automatic way to do this |
| 174 |
;; hand tuning often allows a better voice |
| 175 |
(target_f0_mean 120) ;; speaker's mean F0 |
| 176 |
(target_f0_std 14) ;; speaker's range |
| 177 |
;; These number should remain as they are |
| 178 |
(f0_mean 180) (f0_std 50))) |
| 179 |
|
| 180 |
(define (After_Each_Word_Pauses utt) |
| 181 |
"(Pauses UTT) |
| 182 |
Predict pause insertion." |
| 183 |
(let ((words (utt.relation.items utt 'Word)) lastword tpname) |
| 184 |
(if words |
| 185 |
(begin |
| 186 |
(insert_initial_pause utt) ;; always have a start pause |
| 187 |
(set! lastword (car (last words))) |
| 188 |
(mapcar |
| 189 |
(lambda (w) |
| 190 |
(let ((pbreak (item.feat w "pbreak")) |
| 191 |
(emph (item.feat w "R:Token.parent.EMPH"))) |
| 192 |
(cond |
| 193 |
((equal? w lastword) |
| 194 |
(insert_pause utt w)) |
| 195 |
|
| 196 |
(t |
| 197 |
(set! s (insert_pause utt w)) |
| 198 |
;; but make it a little pause |
| 199 |
(item.set_feat s "emph_sil" "+"))))) |
| 200 |
words) |
| 201 |
;; The embarassing bit. Remove any words labelled as punc or fpunc |
| 202 |
(mapcar |
| 203 |
(lambda (w) |
| 204 |
(let ((pos (item.feat w "pos"))) |
| 205 |
(if (or (string-equal "punc" pos) |
| 206 |
(string-equal "fpunc" pos)) |
| 207 |
(let ((pbreak (item.feat w "pbreak")) |
| 208 |
(wp (item.relation w 'Phrase))) |
| 209 |
(if (and (string-matches pbreak "BB?") |
| 210 |
(item.relation.prev w 'Word)) |
| 211 |
(item.set_feat |
| 212 |
(item.relation.prev w 'Word) "pbreak" pbreak)) |
| 213 |
(item.relation.remove w 'Word) |
| 214 |
;; can't refer to w as we've just deleted it |
| 215 |
(item.relation.remove wp 'Phrase))))) |
| 216 |
words))) |
| 217 |
utt)) |
| 218 |
|
| 219 |
|
| 220 |
;;;;;;;;;;;;; ADDED BY NSK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 221 |
|
| 222 |
|
| 223 |
(define (hindi_NSK_targ_func1 utt syl) |
| 224 |
"(hindi_NSK_targ_func1 utt syl) |
| 225 |
Simple hat accents." |
| 226 |
(let ((start (item.feat syl 'syllable_start)) |
| 227 |
(end (item.feat syl 'syllable_end)) |
| 228 |
(ulen (item.feat (utt.relation.last utt 'Segment ) 'segment_end)) |
| 229 |
nstart nend fustart fuend fuend fstart fend) |
| 230 |
(set! nstart (/ start ulen)) |
| 231 |
(set! nend (/ end ulen)) |
| 232 |
(set! fustart '125) |
| 233 |
(set! fuend '120) |
| 234 |
(set! fstart (+ (* (- fuend fustart) nstart) fustart)) |
| 235 |
(set! fend (+ (* (- fuend fustart) nend) fustart)) |
| 236 |
;; (set! fstart '130) |
| 237 |
;; (set! fend '130) |
| 238 |
(set! tstart (* (- end start) 0.333)) |
| 239 |
(set! tend (* (- end start) 0.333)) |
| 240 |
(cond |
| 241 |
;; ((equal? (item.feat syl "R:Intonation.daughter1.name") "Accented") |
| 242 |
(t |
| 243 |
(list |
| 244 |
(list start fstart) |
| 245 |
;; (list (+ start 0.030) (+ fstart 25 )) |
| 246 |
;; (list (- end 0.030) (+ fstart 20 )) |
| 247 |
(list (+ start tstart) (+ fstart 15 )) |
| 248 |
(list (- end tend) (+ fstart 12 )) |
| 249 |
;; (list (/ (+ fstart fend) 2.0) 150) ;;;;; ADDED on 18-02-02 |
| 250 |
;; (list (/ (+ fstart fend) 2.0) 150) ;;;;; ADDED on 18-02-02 |
| 251 |
(list end fend) |
| 252 |
)) |
| 253 |
((not (item.next syl)) |
| 254 |
(list |
| 255 |
(list end fuend))) |
| 256 |
((not (item.prev syl)) |
| 257 |
(list |
| 258 |
(list start fustart))) |
| 259 |
(t |
| 260 |
nil)))) |
| 261 |
|
| 262 |
(define (phrase_int_factor syl sylpos int_table) |
| 263 |
"(phrase_int_factor ITEM STREAMPOS) |
| 264 |
Returns the phrase intonation factor." |
| 265 |
|
| 266 |
(let |
| 267 |
((start (item.feat syl "syllable_start")) |
| 268 |
(end (item.feat syl "syllable_end")) |
| 269 |
(phrase_start (item.feat syl "R:SylStructure.parent.R:Phrase.first.word_start")) |
| 270 |
(phrase_end (item.feat syl "R:SylStructure.parent.R:Phrase.last.word_end")) |
| 271 |
(dur) |
| 272 |
(ref) |
| 273 |
(last_pair)) |
| 274 |
|
| 275 |
(set! dur (- phrase_end phrase_start)) |
| 276 |
|
| 277 |
(set! target_pos (- (+ start (* (- end start) sylpos)) phrase_start)) |
| 278 |
(set! ref (/ target_pos dur)) |
| 279 |
(set! last_pair (car int_table)) |
| 280 |
|
| 281 |
|
| 282 |
(mapcar |
| 283 |
(lambda (pair) |
| 284 |
(if (> ref (car last_pair)) |
| 285 |
(set! factor (interpolate last_pair pair ref )) |
| 286 |
) |
| 287 |
(set! last_pair pair) |
| 288 |
) |
| 289 |
(cdr int_table)) |
| 290 |
|
| 291 |
factor |
| 292 |
)) |
| 293 |
|
| 294 |
(define (interpolate last_pair pair ref ) |
| 295 |
(set! m (/(- (cadr pair) (cadr last_pair)) (- (car pair) (car last_pair)))) |
| 296 |
(set! m (+ (cadr last_pair) (* m (- ref (car last_pair))))) |
| 297 |
m |
| 298 |
) |
| 299 |
|
| 300 |
|
| 301 |
(set! normal_int_table |
| 302 |
'( (0.00 0.98) |
| 303 |
(0.10 1.00) |
| 304 |
(0.20 1.01) |
| 305 |
(0.46 0.98) |
| 306 |
(0.65 1.01) |
| 307 |
(0.97 0.96) |
| 308 |
(0.98 0.97) |
| 309 |
(0.99 0.93) |
| 310 |
(1.00 0.82))) |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
(set! normal_int_table |
| 315 |
'( (0.00 0.98) |
| 316 |
(0.10 1.02) |
| 317 |
(0.20 0.98) |
| 318 |
(0.30 1.02) |
| 319 |
(0.40 0.98) |
| 320 |
(0.50 1.01) |
| 321 |
(0.60 0.98) |
| 322 |
(0.70 1.02) |
| 323 |
(0.80 0.98) |
| 324 |
(0.90 1.01) |
| 325 |
(0.91 0.96) |
| 326 |
(0.94 0.97) |
| 327 |
(0.96 0.86) |
| 328 |
(1.00 0.82))) |
| 329 |
|
| 330 |
(set! flat_int_table |
| 331 |
'( (0.00 1.00) |
| 332 |
(0.50 1.00) |
| 333 |
(1.00 1.00))) |
| 334 |
|
| 335 |
(set! exclam_int_table |
| 336 |
'( (0.00 0.82) |
| 337 |
(0.10 0.86) |
| 338 |
(0.50 1.05) |
| 339 |
(0.98 0.90) |
| 340 |
(0.99 0.91) |
| 341 |
(1.00 0.80))) |
| 342 |
|
| 343 |
(set! word_int_table |
| 344 |
'( (0.00 0.90) |
| 345 |
(0.10 0.91) |
| 346 |
(0.90 0.91) |
| 347 |
(0.97 0.89) |
| 348 |
(1.00 0.83))) |
| 349 |
|
| 350 |
|
| 351 |
(set! comma_int_table |
| 352 |
'( (0.00 0.88) |
| 353 |
(0.10 0.97) |
| 354 |
(0.90 1.00) |
| 355 |
(0.98 1.10) |
| 356 |
(1.00 1.20))) |
| 357 |
|
| 358 |
(set! question_int_table |
| 359 |
'( (0.00 0.95) |
| 360 |
(0.10 1.03) |
| 361 |
(0.20 1.10) |
| 362 |
(0.30 1.06) |
| 363 |
(0.40 1.03) |
| 364 |
(0.50 1.00) |
| 365 |
(0.60 0.90) |
| 366 |
(0.70 0.86) |
| 367 |
(0.80 0.86) |
| 368 |
(0.90 0.88) |
| 369 |
(0.96 0.90) |
| 370 |
(0.98 1.10) |
| 371 |
(0.99 1.20) |
| 372 |
(1.00 1.50))) |
| 373 |
|
| 374 |
;---------------------------------------------------------------------------- |
| 375 |
|
| 376 |
|
| 377 |
(provide 'hindi_NSK_int) |
| 378 |
|
| 379 |
|
| 380 |
|