Revision f150aab5 server/src/MouthConfig.cpp
server/src/MouthConfig.cpp | ||
---|---|---|
1 | 1 |
/* |
2 |
* 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 |
*/ |
|
2 |
* 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 | 28 |
|
29 | 29 |
#include "MouthConfig.h" |
30 | 30 |
using namespace std; |
31 | 31 |
|
32 |
MouthConfig::MouthConfig(){ |
|
33 |
init_by_symbol("");
|
|
32 |
MouthConfig::MouthConfig() {
|
|
33 |
init_by_symbol("");
|
|
34 | 34 |
} |
35 | 35 |
|
36 |
MouthConfig::MouthConfig(string symbol){ |
|
37 |
init_by_symbol(symbol);
|
|
36 |
MouthConfig::MouthConfig(string symbol) {
|
|
37 |
init_by_symbol(symbol);
|
|
38 | 38 |
} |
39 | 39 |
|
40 |
|
|
41 |
MouthConfig::~MouthConfig(){ |
|
40 |
MouthConfig::~MouthConfig() { |
|
42 | 41 |
} |
43 | 42 |
|
44 |
void MouthConfig::init_by_symbol(string symbol){ |
|
45 |
//default is no change: |
|
46 |
for(int i=0; i<2; i++){ |
|
47 |
opening[i] = 0.0; |
|
48 |
override[i] = 0.0; |
|
49 |
} |
|
50 |
|
|
51 |
//default? |
|
52 |
if (symbol.length() == 0){ |
|
53 |
return; |
|
54 |
} |
|
55 |
|
|
56 |
//see http://www.phon.ucl.ac.uk/home/sampa/german.htm |
|
57 |
if (symbol.length() ==1){ |
|
58 |
//single digit phonemes: |
|
59 |
unsigned char sc = symbol.c_str()[0]; |
|
60 |
switch(sc){ |
|
61 |
default: |
|
62 |
printf("> ignoring unknown phoneme '%c'\n",sc); |
|
63 |
break; |
|
43 |
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 |
} |
|
64 | 49 |
|
65 |
case('_'): //pause |
|
66 |
break; |
|
50 |
// default? |
|
51 |
if (symbol.length() == 0) { |
|
52 |
return; |
|
53 |
} |
|
67 | 54 |
|
68 |
case('T'): //en: _th_in |
|
69 |
case('D'): //en: _th_is |
|
70 |
//as we dont have a tongue, only open the mouth slighly |
|
71 |
override[CENTER] = true; |
|
72 |
opening[CENTER] = 4.0; |
|
73 |
break; |
|
55 |
// 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; |
|
74 | 63 |
|
75 |
case('u'): //en: l_o_se |
|
76 |
override[CENTER] = true; |
|
77 |
opening[CENTER] = 13.0; |
|
64 |
case ('_'): // pause |
|
65 |
break; |
|
78 | 66 |
|
79 |
case('e'): //en: r_ai_se |
|
80 |
override[CENTER] = true; |
|
81 |
opening[CENTER] = 5.0; |
|
82 |
break; |
|
67 |
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; |
|
83 | 73 |
|
84 |
case('V'): //en: c_u_t |
|
85 |
override[CENTER] = true; |
|
86 |
opening[CENTER] = 3.0; |
|
87 |
break; |
|
74 |
case ('u'): // en: l_o_se |
|
75 |
override[CENTER] = true; |
|
76 |
opening[CENTER] = 13.0; |
|
88 | 77 |
|
89 |
case('{'): //en: p_a_t |
|
90 |
//open mouth |
|
91 |
override[CENTER] = true; |
|
92 |
opening[CENTER] = 12.0; |
|
93 |
break; |
|
78 |
case ('e'): // en: r_ai_se |
|
79 |
override[CENTER] = true; |
|
80 |
opening[CENTER] = 5.0; |
|
81 |
break; |
|
94 | 82 |
|
95 |
case('w'): //en: _w_asp |
|
96 |
//mouth nearly closed: |
|
97 |
override[CENTER] = true; |
|
98 |
opening[CENTER] = 4.0; |
|
99 |
break; |
|
83 |
case ('V'): // en: c_u_t |
|
84 |
override[CENTER] = true; |
|
85 |
opening[CENTER] = 3.0; |
|
86 |
break; |
|
100 | 87 |
|
101 |
case('p'): //Pein + en: _p_in
|
|
102 |
case('b'): //Bein
|
|
103 |
//close mouth at the center:
|
|
104 |
override[CENTER] = true;
|
|
105 |
break;
|
|
88 |
case ('{'): // en: p_a_t
|
|
89 |
// open mouth
|
|
90 |
override[CENTER] = true;
|
|
91 |
opening[CENTER] = 12.0;
|
|
92 |
break;
|
|
106 | 93 |
|
107 |
case('t'): //Teich |
|
108 |
case('d'): //Deich |
|
109 |
case('k'): //Kunst |
|
110 |
case('g'): //Gunst |
|
111 |
//open mouth at the center |
|
112 |
override[CENTER] = true; |
|
113 |
opening[CENTER] = 11.0; |
|
114 |
break; |
|
94 |
case ('w'): // en: _w_asp |
|
95 |
// mouth nearly closed: |
|
96 |
override[CENTER] = true; |
|
97 |
opening[CENTER] = 4.0; |
|
98 |
break; |
|
115 | 99 |
|
116 |
case('?'): //global stop?! ignore |
|
117 |
break; |
|
100 |
case ('p'): // Pein + en: _p_in |
|
101 |
case ('b'): // Bein |
|
102 |
// close mouth at the center: |
|
103 |
override[CENTER] = true; |
|
104 |
break; |
|
118 | 105 |
|
119 |
case('f'): //fast |
|
120 |
case('v'): //was |
|
121 |
case('@'): // unstressed "schwa" vowel is |
|
122 |
override[CENTER] = true; |
|
123 |
opening[CENTER] = 4.0; |
|
124 |
break; |
|
106 |
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; |
|
125 | 114 |
|
126 |
case('z'): //Tasse |
|
127 |
case('s'): //Tasse |
|
128 |
case('Z'): //Genie |
|
129 |
case('C'): //Ich |
|
130 |
case('j'): //Jahr |
|
131 |
case('x'): //Buch |
|
132 |
case('h'): //Hand |
|
133 |
override[CENTER] = true; |
|
134 |
opening[CENTER] = 7.0; |
|
135 |
break; |
|
115 |
case ('?'): // global stop?! ignore |
|
116 |
break; |
|
136 | 117 |
|
137 |
case('S'): //waschen
|
|
138 |
case('O'): //Trotz
|
|
139 |
case('9'): //plötzlich
|
|
140 |
override[CENTER] = true;
|
|
141 |
opening[CENTER] = 11.0;
|
|
142 |
break;
|
|
118 |
case ('f'): // fast
|
|
119 |
case ('v'): // was
|
|
120 |
case ('@'): // unstressed "schwa" vowel is
|
|
121 |
override[CENTER] = true;
|
|
122 |
opening[CENTER] = 4.0;
|
|
123 |
break;
|
|
143 | 124 |
|
144 |
case('m'): //mein |
|
145 |
override[CENTER] = true; |
|
146 |
break; |
|
125 |
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; |
|
147 | 135 |
|
148 |
case('n'): //nein |
|
149 |
case('N'): //Ding |
|
150 |
case('l'): //leim |
|
151 |
case('R'): //Reim |
|
152 |
case('r'): //en: wrong |
|
153 |
case('I'): //Sitz |
|
154 |
case('i'): //en: _ea_se |
|
155 |
case('E'): //gesetz |
|
156 |
case('a'): //Satz |
|
157 |
case('U'): //Schutz |
|
158 |
case('Y'): //hübsch |
|
159 |
override[CENTER] = true; |
|
160 |
opening[CENTER] = 7.0; |
|
161 |
break; |
|
136 |
case ('S'): // waschen |
|
137 |
case ('O'): // Trotz |
|
138 |
case ('9'): // plötzlich |
|
139 |
override[CENTER] = true; |
|
140 |
opening[CENTER] = 11.0; |
|
141 |
break; |
|
162 | 142 |
|
163 |
case('o'): //en: n_o_se |
|
164 |
case('Q'): //gb: p_o_t |
|
165 |
case('A'): //english o |
|
166 |
override[CENTER] = true; |
|
167 |
opening[CENTER] = 13.0; |
|
168 |
break; |
|
169 |
//r: |
|
170 |
case('6'): //besser |
|
171 |
override[CENTER] = true; |
|
172 |
opening[CENTER] = 3.0; |
|
173 |
break; |
|
174 |
|
|
175 |
} |
|
176 |
}else if (symbol.length() == 2){ |
|
177 |
if (symbol == "pf"){ //Pfahl |
|
178 |
override[CENTER] = true; |
|
179 |
}else if(symbol == "ts"){ //Zahl |
|
180 |
override[CENTER] = true; |
|
181 |
opening[CENTER] = 11.0; |
|
182 |
}else if(symbol == "tS"){ //deutsch |
|
183 |
override[CENTER] = true; |
|
184 |
opening[CENTER] = 10.5; |
|
185 |
}else if(symbol == "dZ"){ //Dschungel |
|
186 |
override[CENTER] = true; |
|
187 |
opening[CENTER] = 11.0; |
|
188 |
}else if ( |
|
189 |
(symbol == "OI") || //en: n_oi_se |
|
190 |
(symbol == "@`") || //en: c_o_rner |
|
191 |
(symbol == "@U") || //gb: n_o_se |
|
192 |
(symbol == "o:") || //rot |
|
193 |
(symbol == "O:") || //gb: c_au_se |
|
194 |
(symbol == "U@") || //gb: c_u_res |
|
195 |
(symbol == "u:") || //Blut |
|
196 |
(symbol == "y:") || //süß |
|
197 |
(symbol == "2:") || //blöd |
|
198 |
(symbol == "aU") //Haus |
|
199 |
){ |
|
200 |
override[CENTER] = true; |
|
201 |
opening[CENTER] = 13.0; |
|
202 |
}else if ( |
|
203 |
(symbol == "i:") || //Lied |
|
204 |
(symbol == "I@") || //gb: f_ea_rs |
|
205 |
(symbol == "e:") || //Beet |
|
206 |
(symbol == "E:") || //spät |
|
207 |
(symbol == "a:") || //Tat |
|
208 |
(symbol == "A:") //gb: st_a_rs |
|
209 |
){ |
|
210 |
override[CENTER] = true; |
|
211 |
opening[CENTER] = 9.0; |
|
212 |
}else if ( |
|
213 |
(symbol == "aI")|| //Eis |
|
214 |
(symbol == "eI") //gb: r_ai_se |
|
215 |
){ |
|
216 |
override[CENTER] = true; |
|
217 |
opening[CENTER] = 5.0; |
|
218 |
}else if( |
|
219 |
(symbol == "OY") || //Kreuz |
|
220 |
(symbol == "3:") || //gb: f_ur_s |
|
221 |
(symbol == "3`") //en: f_ur_s |
|
222 |
){ |
|
223 |
override[CENTER] = true; |
|
224 |
opening[CENTER] = 5.0; |
|
225 |
}else if ( |
|
226 |
(symbol == "I6") || //Wirt |
|
227 |
(symbol == "Y6") || //Türke |
|
228 |
(symbol == "E6") || //Berg |
|
229 |
(symbol == "96") || //Wörter |
|
230 |
(symbol == "a6") || //hart |
|
231 |
(symbol == "U6") || //kurz |
|
232 |
(symbol == "e@") || //gb: st_ai_rs |
|
233 |
(symbol == "O6") //dort |
|
234 |
){ |
|
235 |
override[CENTER] = true; |
|
236 |
opening[CENTER] = 5.0; |
|
237 |
} |
|
238 |
}else if (symbol.length() == 3){ |
|
239 |
if( |
|
240 |
(symbol == "i:6") || //Tier |
|
241 |
(symbol == "y:6") || //Tür |
|
242 |
(symbol == "e:6") || //schwer |
|
243 |
(symbol == "E:6") || //Bär |
|
244 |
(symbol == "2:6") || //Föhr |
|
245 |
(symbol == "a:6") || //Haar |
|
246 |
(symbol == "u:6") || //Kur |
|
247 |
(symbol == "o:6") //Ohr |
|
248 |
){ |
|
249 |
override[CENTER] = true; |
|
250 |
opening[CENTER] = 5.0; |
|
251 |
}else{ |
|
252 |
printf("> invalid phoneme '%s' unhandled\n",symbol.c_str()); |
|
253 |
} |
|
254 |
}else{ |
|
255 |
printf("> invalid phoneme length, phoneme '%s' unhandled\n",symbol.c_str()); |
|
256 |
} |
|
143 |
case ('m'): // mein |
|
144 |
override[CENTER] = true; |
|
145 |
break; |
|
257 | 146 |
|
147 |
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; |
|
258 | 161 |
|
162 |
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 |
} |
|
259 | 261 |
} |
260 | 262 |
|
263 |
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 |
} |
|
261 | 270 |
|
262 |
void MouthConfig::apply_on_mouth_state(humotion::MouthState *m){ |
|
263 |
if (override[LEFT]){ |
|
264 |
m->opening_left = opening[LEFT]; |
|
265 |
}else{ |
|
266 |
m->opening_left += opening[LEFT]; |
|
267 |
} |
|
268 |
|
|
269 |
if (override[CENTER]){ |
|
270 |
m->opening_center = opening[CENTER]; |
|
271 |
}else{ |
|
272 |
m->opening_center += opening[CENTER]; |
|
273 |
} |
|
271 |
if (override[CENTER]) { |
|
272 |
m->opening_center = opening[CENTER]; |
|
273 |
} |
|
274 |
else { |
|
275 |
m->opening_center += opening[CENTER]; |
|
276 |
} |
|
274 | 277 |
|
275 |
if (override[RIGHT]){ |
|
276 |
m->opening_right = opening[RIGHT]; |
|
277 |
}else{ |
|
278 |
m->opening_right += opening[RIGHT]; |
|
279 |
} |
|
278 |
if (override[RIGHT]) { |
|
279 |
m->opening_right = opening[RIGHT]; |
|
280 |
} |
|
281 |
else { |
|
282 |
m->opening_right += opening[RIGHT]; |
|
283 |
} |
|
280 | 284 |
} |
Also available in: Unified diff