hlrc / server / src / MouthConfig.cpp @ d8feb404
History | View | Annotate | Download (6.761 KB)
1 | 0c286af0 | Simon Schulz | /*
|
---|---|---|---|
2 | f150aab5 | Robert Haschke | * This file is part of hlrc_server
|
3 | *
|
||
4 | * Copyright(c) sschulz <AT> techfak.uni-bielefeld.de
|
||
5 | * http://opensource.cit-ec.de/projects/hlrc_server
|
||
6 | *
|
||
7 | * This file may be licensed under the terms of the
|
||
8 | * GNU General Public License Version 3 (the ``GPL''),
|
||
9 | * or (at your option) any later version.
|
||
10 | *
|
||
11 | * Software distributed under the License is distributed
|
||
12 | * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
||
13 | * express or implied. See the GPL for the specific language
|
||
14 | * governing rights and limitations.
|
||
15 | *
|
||
16 | * You should have received a copy of the GPL along with this
|
||
17 | * program. If not, go to http://www.gnu.org/licenses/gpl.html
|
||
18 | * or write to the Free Software Foundation, Inc.,
|
||
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * The development of this software was supported by the
|
||
22 | * Excellence Cluster EXC 277 Cognitive Interaction Technology.
|
||
23 | * The Excellence Cluster EXC 277 is a grant of the Deutsche
|
||
24 | * Forschungsgemeinschaft (DFG) in the context of the German
|
||
25 | * Excellence Initiative.
|
||
26 | *
|
||
27 | */
|
||
28 | 0c286af0 | Simon Schulz | |
29 | #include "MouthConfig.h" |
||
30 | using namespace std; |
||
31 | |||
32 | f150aab5 | Robert Haschke | MouthConfig::MouthConfig() { |
33 | init_by_symbol("");
|
||
34 | 0c286af0 | Simon Schulz | } |
35 | |||
36 | f150aab5 | Robert Haschke | MouthConfig::MouthConfig(string symbol) {
|
37 | init_by_symbol(symbol); |
||
38 | 0c286af0 | Simon Schulz | } |
39 | |||
40 | f150aab5 | Robert Haschke | MouthConfig::~MouthConfig() { |
41 | 0c286af0 | Simon Schulz | } |
42 | |||
43 | f150aab5 | Robert Haschke | void MouthConfig::init_by_symbol(string symbol) { |
44 | // default is no change:
|
||
45 | for (int i = 0; i < 2; i++) { |
||
46 | opening[i] = 0.0; |
||
47 | override[i] = 0.0; |
||
48 | } |
||
49 | 0c286af0 | Simon Schulz | |
50 | f150aab5 | Robert Haschke | // default?
|
51 | if (symbol.length() == 0) { |
||
52 | return;
|
||
53 | } |
||
54 | 0c286af0 | Simon Schulz | |
55 | f150aab5 | Robert Haschke | // see http://www.phon.ucl.ac.uk/home/sampa/german.htm
|
56 | if (symbol.length() == 1) { |
||
57 | // single digit phonemes:
|
||
58 | unsigned char sc = symbol.c_str()[0]; |
||
59 | switch (sc) {
|
||
60 | default:
|
||
61 | printf("> ignoring unknown phoneme '%c'\n", sc);
|
||
62 | break;
|
||
63 | 0c286af0 | Simon Schulz | |
64 | f150aab5 | Robert Haschke | case ('_'): // pause |
65 | break;
|
||
66 | 0c286af0 | Simon Schulz | |
67 | f150aab5 | Robert Haschke | case ('T'): // en: _th_in |
68 | case ('D'): // en: _th_is |
||
69 | // as we dont have a tongue, only open the mouth slighly
|
||
70 | override[CENTER] = true;
|
||
71 | opening[CENTER] = 4.0; |
||
72 | break;
|
||
73 | 0c286af0 | Simon Schulz | |
74 | f150aab5 | Robert Haschke | case ('u'): // en: l_o_se |
75 | override[CENTER] = true;
|
||
76 | opening[CENTER] = 13.0; |
||
77 | 0c286af0 | Simon Schulz | |
78 | f150aab5 | Robert Haschke | case ('e'): // en: r_ai_se |
79 | override[CENTER] = true;
|
||
80 | opening[CENTER] = 5.0; |
||
81 | break;
|
||
82 | 0c286af0 | Simon Schulz | |
83 | f150aab5 | Robert Haschke | case ('V'): // en: c_u_t |
84 | override[CENTER] = true;
|
||
85 | opening[CENTER] = 3.0; |
||
86 | break;
|
||
87 | 0c286af0 | Simon Schulz | |
88 | f150aab5 | Robert Haschke | case ('{'): // en: p_a_t |
89 | // open mouth
|
||
90 | override[CENTER] = true;
|
||
91 | opening[CENTER] = 12.0; |
||
92 | break;
|
||
93 | 0c286af0 | Simon Schulz | |
94 | f150aab5 | Robert Haschke | case ('w'): // en: _w_asp |
95 | // mouth nearly closed:
|
||
96 | override[CENTER] = true;
|
||
97 | opening[CENTER] = 4.0; |
||
98 | break;
|
||
99 | 0c286af0 | Simon Schulz | |
100 | f150aab5 | Robert Haschke | case ('p'): // Pein + en: _p_in |
101 | case ('b'): // Bein |
||
102 | // close mouth at the center:
|
||
103 | override[CENTER] = true;
|
||
104 | break;
|
||
105 | 0c286af0 | Simon Schulz | |
106 | f150aab5 | Robert Haschke | case ('t'): // Teich |
107 | case ('d'): // Deich |
||
108 | case ('k'): // Kunst |
||
109 | case ('g'): // Gunst |
||
110 | // open mouth at the center
|
||
111 | override[CENTER] = true;
|
||
112 | opening[CENTER] = 11.0; |
||
113 | break;
|
||
114 | 0c286af0 | Simon Schulz | |
115 | f150aab5 | Robert Haschke | case ('?'): // global stop?! ignore |
116 | break;
|
||
117 | 0c286af0 | Simon Schulz | |
118 | f150aab5 | Robert Haschke | case ('f'): // fast |
119 | case ('v'): // was |
||
120 | case ('@'): // unstressed "schwa" vowel is |
||
121 | override[CENTER] = true;
|
||
122 | opening[CENTER] = 4.0; |
||
123 | break;
|
||
124 | 0c286af0 | Simon Schulz | |
125 | f150aab5 | Robert Haschke | case ('z'): // Tasse |
126 | case ('s'): // Tasse |
||
127 | case ('Z'): // Genie |
||
128 | case ('C'): // Ich |
||
129 | case ('j'): // Jahr |
||
130 | case ('x'): // Buch |
||
131 | case ('h'): // Hand |
||
132 | override[CENTER] = true;
|
||
133 | opening[CENTER] = 7.0; |
||
134 | break;
|
||
135 | 0c286af0 | Simon Schulz | |
136 | f150aab5 | Robert Haschke | case ('S'): // waschen |
137 | case ('O'): // Trotz |
||
138 | case ('9'): // plötzlich |
||
139 | override[CENTER] = true;
|
||
140 | opening[CENTER] = 11.0; |
||
141 | break;
|
||
142 | 0c286af0 | Simon Schulz | |
143 | f150aab5 | Robert Haschke | case ('m'): // mein |
144 | override[CENTER] = true;
|
||
145 | break;
|
||
146 | 0c286af0 | Simon Schulz | |
147 | f150aab5 | Robert Haschke | case ('n'): // nein |
148 | case ('N'): // Ding |
||
149 | case ('l'): // leim |
||
150 | case ('R'): // Reim |
||
151 | case ('r'): // en: wrong |
||
152 | case ('I'): // Sitz |
||
153 | case ('i'): // en: _ea_se |
||
154 | case ('E'): // gesetz |
||
155 | case ('a'): // Satz |
||
156 | case ('U'): // Schutz |
||
157 | case ('Y'): // hübsch |
||
158 | override[CENTER] = true;
|
||
159 | opening[CENTER] = 7.0; |
||
160 | break;
|
||
161 | 0c286af0 | Simon Schulz | |
162 | f150aab5 | Robert Haschke | case ('o'): // en: n_o_se |
163 | case ('Q'): // gb: p_o_t |
||
164 | case ('A'): // english o |
||
165 | override[CENTER] = true;
|
||
166 | opening[CENTER] = 13.0; |
||
167 | break;
|
||
168 | // r:
|
||
169 | case ('6'): // besser |
||
170 | override[CENTER] = true;
|
||
171 | opening[CENTER] = 3.0; |
||
172 | break;
|
||
173 | } |
||
174 | } |
||
175 | else if (symbol.length() == 2) { |
||
176 | if (symbol == "pf") { // Pfahl |
||
177 | override[CENTER] = true;
|
||
178 | } |
||
179 | else if (symbol == "ts") { // Zahl |
||
180 | override[CENTER] = true;
|
||
181 | opening[CENTER] = 11.0; |
||
182 | } |
||
183 | else if (symbol == "tS") { // deutsch |
||
184 | override[CENTER] = true;
|
||
185 | opening[CENTER] = 10.5; |
||
186 | } |
||
187 | else if (symbol == "dZ") { // Dschungel |
||
188 | override[CENTER] = true;
|
||
189 | opening[CENTER] = 11.0; |
||
190 | } |
||
191 | else if ((symbol == "OI") || // en: n_oi_se |
||
192 | (symbol == "@`") || // en: c_o_rner |
||
193 | (symbol == "@U") || // gb: n_o_se |
||
194 | (symbol == "o:") || // rot |
||
195 | (symbol == "O:") || // gb: c_au_se |
||
196 | (symbol == "U@") || // gb: c_u_res |
||
197 | (symbol == "u:") || // Blut |
||
198 | (symbol == "y:") || // süß |
||
199 | (symbol == "2:") || // blöd |
||
200 | (symbol == "aU") // Haus |
||
201 | ) { |
||
202 | override[CENTER] = true;
|
||
203 | opening[CENTER] = 13.0; |
||
204 | } |
||
205 | else if ((symbol == "i:") || // Lied |
||
206 | (symbol == "I@") || // gb: f_ea_rs |
||
207 | (symbol == "e:") || // Beet |
||
208 | (symbol == "E:") || // spät |
||
209 | (symbol == "a:") || // Tat |
||
210 | (symbol == "A:") // gb: st_a_rs |
||
211 | ) { |
||
212 | override[CENTER] = true;
|
||
213 | opening[CENTER] = 9.0; |
||
214 | } |
||
215 | else if ((symbol == "aI") || // Eis |
||
216 | (symbol == "eI") // gb: r_ai_se |
||
217 | ) { |
||
218 | override[CENTER] = true;
|
||
219 | opening[CENTER] = 5.0; |
||
220 | } |
||
221 | else if ((symbol == "OY") || // Kreuz |
||
222 | (symbol == "3:") || // gb: f_ur_s |
||
223 | (symbol == "3`") // en: f_ur_s |
||
224 | ) { |
||
225 | override[CENTER] = true;
|
||
226 | opening[CENTER] = 5.0; |
||
227 | } |
||
228 | else if ((symbol == "I6") || // Wirt |
||
229 | (symbol == "Y6") || // Türke |
||
230 | (symbol == "E6") || // Berg |
||
231 | (symbol == "96") || // Wörter |
||
232 | (symbol == "a6") || // hart |
||
233 | (symbol == "U6") || // kurz |
||
234 | (symbol == "e@") || // gb: st_ai_rs |
||
235 | (symbol == "O6") // dort |
||
236 | ) { |
||
237 | override[CENTER] = true;
|
||
238 | opening[CENTER] = 5.0; |
||
239 | } |
||
240 | } |
||
241 | else if (symbol.length() == 3) { |
||
242 | if ((symbol == "i:6") || // Tier |
||
243 | (symbol == "y:6") || // Tür |
||
244 | (symbol == "e:6") || // schwer |
||
245 | (symbol == "E:6") || // Bär |
||
246 | (symbol == "2:6") || // Föhr |
||
247 | (symbol == "a:6") || // Haar |
||
248 | (symbol == "u:6") || // Kur |
||
249 | (symbol == "o:6") // Ohr |
||
250 | ) { |
||
251 | override[CENTER] = true;
|
||
252 | opening[CENTER] = 5.0; |
||
253 | } |
||
254 | else {
|
||
255 | printf("> invalid phoneme '%s' unhandled\n", symbol.c_str());
|
||
256 | } |
||
257 | } |
||
258 | else {
|
||
259 | printf("> invalid phoneme length, phoneme '%s' unhandled\n", symbol.c_str());
|
||
260 | } |
||
261 | 0c286af0 | Simon Schulz | } |
262 | |||
263 | f150aab5 | Robert Haschke | void MouthConfig::apply_on_mouth_state(humotion::MouthState* m) {
|
264 | if (override[LEFT]) {
|
||
265 | m->opening_left = opening[LEFT]; |
||
266 | } |
||
267 | else {
|
||
268 | m->opening_left += opening[LEFT]; |
||
269 | } |
||
270 | 0c286af0 | Simon Schulz | |
271 | f150aab5 | Robert Haschke | if (override[CENTER]) {
|
272 | m->opening_center = opening[CENTER]; |
||
273 | } |
||
274 | else {
|
||
275 | m->opening_center += opening[CENTER]; |
||
276 | } |
||
277 | 0c286af0 | Simon Schulz | |
278 | f150aab5 | Robert Haschke | if (override[RIGHT]) {
|
279 | m->opening_right = opening[RIGHT]; |
||
280 | } |
||
281 | else {
|
||
282 | m->opening_right += opening[RIGHT]; |
||
283 | } |
||
284 | 0c286af0 | Simon Schulz | } |