Debian Codegraph @

tools/VOICE_cg.c

raw
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 1999-2015 */
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 /* CARNEGIE MELLON UNIVERSITY 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 CARNEGIE MELLON UNIVERSITY 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 /* Author: Alan W Black ([email protected]) */
34 /* Date: November 2007 */
35 /*************************************************************************/
36 /* */
37 /* A clustergen voice defintion */
38 /* */
39 /*************************************************************************/
40
41 #include <string.h>
42 #include "flite.h"
43 #include "cst_cg.h"
44
45 #include "__FLITELANG__.h"
46 #include "__FLITELEX__.h"
47
48 extern cst_cg_db __VOICENAME___cg_db;
49 cst_voice *__VOICENAME___cg = NULL;
50
51 #ifdef CG_GRAPHEME
52 extern const cst_phoneset __VOICENAME___phoneset;
53 #endif
54
55 cst_voice *register___VOICENAME__(const char *voxdir)
56 {
57 cst_voice *vox;
58 cst_lexicon *lex;
59
60 if (__VOICENAME___cg)
61 return __VOICENAME___cg; /* Already registered */
62
63 vox = new_voice();
64 vox->name = "__NICKNAME__";
65
66 /* Sets up language specific parameters in the __VOICENAME__. */
67 __FLITELANG___init(vox);
68
69 /* Things that weren't filled in already. */
70 flite_feat_set_string(vox->features,"name","__VOICENAME__");
71
72 /* Voice specific features from ../etc/voice.feats */
73 #include "__VOICENAME___voice_feats.c"
74
75 /* Lexicon */
76 lex = __FLITELEX___init();
77 flite_feat_set(vox->features,"lexicon",lexicon_val(lex));
78 flite_feat_set(vox->features,"postlex_func",uttfunc_val(lex->postlex));
79
80 #ifdef CG_GRAPHEME
81 /* If grapheme link in grapheme specific info */
82 if (feat_present(vox->features,"grapheme"))
83 {
84 flite_feat_set(vox->features,"phoneset",phoneset_val(&__VOICENAME___phoneset));
85 }
86 #endif
87
88 /* No standard segment durations are needed as its done at the */
89 /* HMM state level */
90 flite_feat_set_string(vox->features,"no_segment_duration_model","1");
91 flite_feat_set_string(vox->features,"no_f0_target_model","1");
92
93 /* Waveform synthesis */
94 flite_feat_set(vox->features,"wave_synth_func",uttfunc_val(&cg_synth));
95 flite_feat_set(vox->features,"cg_db",cg_db_val(&__VOICENAME___cg_db));
96 flite_feat_set_int(vox->features,"sample_rate",__VOICENAME___cg_db.sample_rate);
97
98 __VOICENAME___cg = vox;
99
100 return __VOICENAME___cg;
101 }
102
103 void unregister___VOICENAME__(cst_voice *vox)
104 {
105 if (vox != __VOICENAME___cg)
106 return;
107 delete_voice(vox);
108 __VOICENAME___cg = NULL;
109 }
110