Debian Codegraph @

3rdparty/flite_hts_engine/flite/src/synth/cst_phoneset.c

raw symbols SCIP
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 1999 */
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: December 2000 */
35 /*************************************************************************/
36 /* */
37 /* Voice definition */
38 /* */
39 /*************************************************************************/
40
41 /* ----------------------------------------------------------------- */
42 /* The English TTS System "Flite+hts_engine" */
43 /* developed by HTS Working Group */
44 /* http://hts-engine.sourceforge.net/ */
45 /* ----------------------------------------------------------------- */
46 /* */
47 /* Copyright (c) 2005-2013 Nagoya Institute of Technology */
48 /* Department of Computer Science */
49 /* */
50 /* 2005-2008 Tokyo Institute of Technology */
51 /* Interdisciplinary Graduate School of */
52 /* Science and Engineering */
53 /* */
54 /* All rights reserved. */
55 /* */
56 /* Redistribution and use in source and binary forms, with or */
57 /* without modification, are permitted provided that the following */
58 /* conditions are met: */
59 /* */
60 /* - Redistributions of source code must retain the above copyright */
61 /* notice, this list of conditions and the following disclaimer. */
62 /* - Redistributions in binary form must reproduce the above */
63 /* copyright notice, this list of conditions and the following */
64 /* disclaimer in the documentation and/or other materials provided */
65 /* with the distribution. */
66 /* - Neither the name of the HTS working group nor the names of its */
67 /* contributors may be used to endorse or promote products derived */
68 /* from this software without specific prior written permission. */
69 /* */
70 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
71 /* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
72 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
73 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
74 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
75 /* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
76 /* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
77 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
78 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
79 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
80 /* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
81 /* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
82 /* POSSIBILITY OF SUCH DAMAGE. */
83 /* ----------------------------------------------------------------- */
84
85 #include "cst_val.h"
86 #include "cst_utterance.h"
87 #include "cst_item.h"
88 #include "cst_phoneset.h"
89
90 CST_VAL_REGISTER_TYPE_NODEL(phoneset,cst_phoneset)
91
92 #ifndef FLITE_PLUS_HTS_ENGINE
93 cst_phoneset *new_phoneset()
94 {
95 /* These aren't going to be supported dynamically */
96 cst_phoneset *v = cst_alloc(struct cst_phoneset_struct,1);
97
98 return v;
99 }
100
101 void delete_phoneset(cst_phoneset *v)
102 {
103 if (v)
104 {
105 cst_free(v);
106 }
107 }
108 #endif /* !FLITE_PLUS_HTS_ENGINE */
109
110 int phone_id(const cst_phoneset *ps,const char* phonename)
111 {
112 int i;
113
114 for (i=0; i< ps->num_phones; i++)
115 if (cst_streq(ps->phonenames[i],phonename))
116 return i;
117 /* Wonder if I should print an error here or not */
118
119 return 0;
120 }
121
122 int phone_feat_id(const cst_phoneset *ps,const char* featname)
123 {
124 int i;
125
126 for (i=0; ps->featnames[i]; i++)
127 if (cst_streq(ps->featnames[i],featname))
128 return i;
129
130 /* Wonder if I should print an error here or not */
131 return 0;
132 }
133
134 const cst_val *phone_feature(const cst_phoneset *ps,
135 const char* phonename,
136 const char *featname)
137 {
138 return ps->featvals[ps->fvtable[phone_id(ps,phonename)]
139 [phone_feat_id(ps,featname)]];
140 }
141
142 const char *phone_feature_string(const cst_phoneset *ps,
143 const char* phonename,
144 const char *featname)
145 {
146 return val_string(phone_feature(ps,phonename,featname));
147 }
148
149
150 const cst_phoneset *item_phoneset(const cst_item *p)
151 {
152 return val_phoneset(feat_val(item_utt(p)->features,"phoneset"));
153 }