| 1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2 |
;;; ;; |
| 3 |
;;; A diphone voice for Hindi language ;; |
| 4 |
;;; ;; |
| 5 |
;;; Copyright (c) 2005, DONLab, Dept. of CS&E, ;; |
| 6 |
;;; IIT Madras <[email protected]> ;; |
| 7 |
;;; Copyright (c) 2005, Chaitanya Kamisetty <[email protected]> ;; |
| 8 |
;;; ;; |
| 9 |
;;; Copyright (c) 2006, Priti Patil, janabhaaratii, C-DAC, Mumbai ;; |
| 10 |
;;; <[email protected]>, <[email protected]> ;; |
| 11 |
;;; ;; |
| 12 |
;;; This program is a part of festival-hi. ;; |
| 13 |
;;; ;; |
| 14 |
;;; festival-hi is free software; you can redistribute it and/or modify ;; |
| 15 |
;;; it under the terms of the GNU General Public License as published by ;; |
| 16 |
;;; the Free Software Foundation; either version 2 of the License, or ;; |
| 17 |
;;; (at your option) any later version. ;; |
| 18 |
;;; ;; |
| 19 |
;;; This program is distributed in the hope that it will be useful, ;; |
| 20 |
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; |
| 21 |
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; |
| 22 |
;;; GNU General Public License for more details. ;; |
| 23 |
;;; ;; |
| 24 |
;;; You should have received a copy of the GNU General Public License ;; |
| 25 |
;;; along with this program; if not, write to the Free Software ;; |
| 26 |
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ;; |
| 27 |
;;; ;; |
| 28 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 29 |
|
| 30 |
|
| 31 |
;;; Try to find out where we are |
| 32 |
(if (assoc 'hindi_NSK_diphone voice-locations) |
| 33 |
(defvar hindi_dir |
| 34 |
(cdr (assoc 'hindi_NSK_diphone voice-locations))) |
| 35 |
;;; Not installed in Festival yet so assume running in place |
| 36 |
(defvar hindi_dir (pwd))) |
| 37 |
|
| 38 |
(if (not (probe_file (path-append hindi_dir "festvox/"))) |
| 39 |
(begin |
| 40 |
(format stderr "hindi_NSK_diphone Can't find voice scm files they are not in\n") |
| 41 |
(format stderr " %s\n" (path-append hindi_dir "festvox/")) |
| 42 |
(format stderr " Either the voice isn't linked into Festival\n") |
| 43 |
(format stderr " or you are starting festival in the wrong directory\n") |
| 44 |
(error))) |
| 45 |
|
| 46 |
;;; Add the directory contains general voice stuff to load-path |
| 47 |
(set! load-path (cons (path-append hindi_dir "festvox/") load-path)) |
| 48 |
;;; Path for common hindi modules |
| 49 |
;;; Debian distribution defines datadir, others use libdir |
| 50 |
(if (symbol-bound? 'datadir) |
| 51 |
(set! load-path (cons (path-append datadir "hindi_scm/") load-path))) |
| 52 |
(set! load-path (cons (path-append libdir "hindi_scm/") load-path)) |
| 53 |
|
| 54 |
;;; other files we need |
| 55 |
(require 'hindi_phones) |
| 56 |
(require 'hindi_lex) |
| 57 |
(require 'hindi_token) |
| 58 |
(require 'hindi_NSK_int) |
| 59 |
(require 'hindi_NSK_dur) |
| 60 |
(require 'hindi_NSK_ene) |
| 61 |
|
| 62 |
;;; Ensure we have a festival with the right diphone support compiled in |
| 63 |
(require_module 'UniSyn) |
| 64 |
|
| 65 |
(set! hindi_lpc_sep |
| 66 |
(list |
| 67 |
'(name "hindi_lpc_sep") |
| 68 |
(list 'index_file (path-append hindi_dir "dic/NSKdiph.est")) |
| 69 |
'(grouped "false") |
| 70 |
(list 'coef_dir (path-append hindi_dir "lpc")) |
| 71 |
(list 'sig_dir (path-append hindi_dir "lpc")) |
| 72 |
'(coef_ext ".lpc") |
| 73 |
'(sig_ext ".res") |
| 74 |
(list 'default_diphone |
| 75 |
(string-append |
| 76 |
(car (cadr (car (PhoneSet.description '(silences))))) |
| 77 |
"-" |
| 78 |
(car (cadr (car (PhoneSet.description '(silences))))))))) |
| 79 |
|
| 80 |
(set! hindi_lpc_group |
| 81 |
(list |
| 82 |
'(name "NSK_lpc_group") |
| 83 |
(list 'index_file |
| 84 |
(path-append hindi_dir "group/NSKlpc.group")) |
| 85 |
'(grouped "true") |
| 86 |
(list 'default_diphone |
| 87 |
(string-append |
| 88 |
(car (cadr (car (PhoneSet.description '(silences))))) |
| 89 |
"-" |
| 90 |
(car (cadr (car (PhoneSet.description '(silences))))))))) |
| 91 |
|
| 92 |
;;Go ahead and set up the diphone db |
| 93 |
;(set! hindi_db_name (us_diphone_init hindi_lpc_sep)) |
| 94 |
;;Once you've built the group file you can comment out the above and |
| 95 |
;;uncomment the following. |
| 96 |
(set! hindi_db_name (us_diphone_init hindi_lpc_group)) |
| 97 |
|
| 98 |
|
| 99 |
(define (hindi_NSK_diphone_fix utt) |
| 100 |
"(hindi_NSK_diphone_fix UTT) |
| 101 |
Map phones to phonological variants if the diphone database supports |
| 102 |
them." |
| 103 |
(mapcar |
| 104 |
(lambda (s) |
| 105 |
(let ((name (item.name s))) |
| 106 |
;; Check and do something maybe |
| 107 |
)) |
| 108 |
(utt.relation.items utt 'Segment)) |
| 109 |
utt) |
| 110 |
|
| 111 |
(define (hindi_voice_reset) |
| 112 |
"(hindi_voice_reset) |
| 113 |
Reset global variables back to previous voice." |
| 114 |
;; whatever |
| 115 |
) |
| 116 |
|
| 117 |
|
| 118 |
(define (hindi_NSK_diphone_fix_phone_name utt seg) |
| 119 |
"(hindi_fix_phone_name UTT SEG) |
| 120 |
Add the feature diphone_phone_name to given segment with the appropriate |
| 121 |
name for constructing a diphone. Basically adds _ if either side is part |
| 122 |
of the same consonant cluster, adds $ either side if in different |
| 123 |
syllable for preceding/succeeding vowel syllable." |
| 124 |
(let ((name (item.name seg))) |
| 125 |
(cond |
| 126 |
((string-equal name "pau") t) |
| 127 |
((string-equal "-" (item.feat seg 'ph_vc)) |
| 128 |
(if (and (member_string name '(r w y l)) |
| 129 |
(member_string (item.feat seg "p.name") '(p t k b d g)) |
| 130 |
(item.relation.prev seg "SylStructure")) |
| 131 |
(item.set_feat seg "us_diphone_right" (format nil "_%s" name))) |
| 132 |
(if (and (member_string name '(w y l m n p t k)) |
| 133 |
(string-equal (item.feat seg "p.name") 's) |
| 134 |
(item.relation.prev seg "SylStructure")) |
| 135 |
(item.set_feat seg "us_diphone_right" (format nil "_%s" name))) |
| 136 |
(if (and (string-equal name 's) |
| 137 |
(member_string (item.feat seg "n.name") '(w y l m n p t k)) |
| 138 |
(item.relation.next seg "SylStructure")) |
| 139 |
(item.set_feat seg "us_diphone_left" (format nil "%s_" name))) |
| 140 |
(if (and (string-equal name 'hh) |
| 141 |
(string-equal (item.feat seg "n.name") 'y)) |
| 142 |
(item.set_feat seg "us_diphone_left" (format nil "%s_" name))) |
| 143 |
(if (and (string-equal name 'y) |
| 144 |
(string-equal (item.feat seg "p.name") 'hh)) |
| 145 |
(item.set_feat seg "us_diphone_right" (format nil "_%s" name))) |
| 146 |
(if (and (member_string name '(p t k b d g)) |
| 147 |
(member_string (item.feat seg "n.name") '(r w y l)) |
| 148 |
(item.relation.next seg "SylStructure")) |
| 149 |
(item.set_feat seg "us_diphone_left" (format nil "%s_" name))) |
| 150 |
) |
| 151 |
((string-equal "ah" (item.name seg)) |
| 152 |
(item.set_feat seg "us_diphone" "aa")) |
| 153 |
|
| 154 |
))) |
| 155 |
|
| 156 |
|
| 157 |
;;; Full voice definition |
| 158 |
(define (voice_hindi_NSK_diphone) |
| 159 |
"(voice_hindi_NSK_diphone) |
| 160 |
Set speaker to NSK in hindi from DON." |
| 161 |
(voice_reset) |
| 162 |
(Parameter.set 'Language 'hindi) |
| 163 |
;; Phone set |
| 164 |
(Parameter.set 'PhoneSet 'hindi) |
| 165 |
(PhoneSet.select 'hindi) |
| 166 |
|
| 167 |
;; token expansion (numbers, symbols, compounds etc) |
| 168 |
(Parameter.set 'Token_Method 'Token_Any) |
| 169 |
(set! token_to_words hindi_token_to_words) |
| 170 |
|
| 171 |
;; No pos prediction (get it from lexicon) |
| 172 |
(set! pos_lex_name nil) |
| 173 |
(set! guess_pos hindi_guess_pos) |
| 174 |
;; Phrase break prediction by punctuation |
| 175 |
(set! pos_supported nil) ;; well not real pos anyhow |
| 176 |
;; Phrasing |
| 177 |
(set! phrase_cart_tree hindi_phrase_cart_tree_2) |
| 178 |
(Parameter.set 'Phrase_Method 'cart_tree) |
| 179 |
;; Lexicon selection |
| 180 |
(lex.select "hindi") |
| 181 |
|
| 182 |
;; No postlexical rules |
| 183 |
(set! postlex_rules_hooks nil) |
| 184 |
|
| 185 |
;; Accent and tone prediction |
| 186 |
|
| 187 |
(set! int_accent_cart_tree hindi_accent_cart_tree) |
| 188 |
(Parameter.set 'Int_Target_Method 'Simple) |
| 189 |
|
| 190 |
;; Duration prediction |
| 191 |
(set! duration_cart_tree hindi_NSK::zdur_tree) |
| 192 |
|
| 193 |
;;(set! duration_ph_info hindi_NSK::phone_data) |
| 194 |
(set! duration_ph_info hindi_NSK::phone_durs) |
| 195 |
(Parameter.set 'Duration_Method 'Tree_ZScores) |
| 196 |
(Parameter.set 'Duration_Stretch 1.4) |
| 197 |
|
| 198 |
|
| 199 |
;; Energy prediction |
| 200 |
(set! energy_cart_tree hindi_NSK::zene_treeMAX2) |
| 201 |
(set! energy_ph_info hindi_NSK::phone_enesMAX2) |
| 202 |
(Parameter.set 'Energy_Method 'Tree_ZScores) |
| 203 |
|
| 204 |
;; Waveform synthesizer: diphones |
| 205 |
(set! UniSyn_module_hooks (list hindi_NSK_diphone_fix)) |
| 206 |
(set! us_abs_offset 0.0) |
| 207 |
(set! window_factor 1.0) |
| 208 |
(set! us_rel_offset 0.0) |
| 209 |
(set! us_gain 0.9) |
| 210 |
|
| 211 |
(Parameter.set 'Synth_Method 'UniSyn) |
| 212 |
(Parameter.set 'us_sigpr 'lpc) |
| 213 |
(us_db_select hindi_db_name) |
| 214 |
|
| 215 |
|
| 216 |
;; set callback to restore some original values changed by this voice |
| 217 |
(set! current_voice_reset hindi_voice_reset) |
| 218 |
|
| 219 |
(set! current-voice 'hindi_NSK_diphone) |
| 220 |
) |
| 221 |
|
| 222 |
(proclaim_voice |
| 223 |
|
| 224 |
'hindi_NSK_diphone |
| 225 |
'((language hindi) |
| 226 |
(gender male) |
| 227 |
(dialect COMMENT) |
| 228 |
(description |
| 229 |
"COMMENT" |
| 230 |
) |
| 231 |
(builtwith festvox-1.2) |
| 232 |
(coding UTF-8) |
| 233 |
)) |
| 234 |
(provide 'hindi_NSK_diphone) |