hlrc / server / src / MouthConfig.cpp @ 6dee6447
History | View | Annotate | Download (8.351 KB)
| 1 | 0c286af0 | Simon Schulz | /*
|
|---|---|---|---|
| 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 | |||
| 29 | #include "MouthConfig.h" |
||
| 30 | using namespace std; |
||
| 31 | |||
| 32 | MouthConfig::MouthConfig(){
|
||
| 33 | init_by_symbol("");
|
||
| 34 | } |
||
| 35 | |||
| 36 | MouthConfig::MouthConfig(string symbol){
|
||
| 37 | init_by_symbol(symbol); |
||
| 38 | } |
||
| 39 | |||
| 40 | |||
| 41 | MouthConfig::~MouthConfig(){
|
||
| 42 | } |
||
| 43 | |||
| 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;
|
||
| 64 | |||
| 65 | case('_'): //pause |
||
| 66 | break;
|
||
| 67 | |||
| 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;
|
||
| 74 | |||
| 75 | case('u'): //en: l_o_se |
||
| 76 | override[CENTER] = true;
|
||
| 77 | opening[CENTER] = 13.0; |
||
| 78 | |||
| 79 | case('e'): //en: r_ai_se |
||
| 80 | override[CENTER] = true;
|
||
| 81 | opening[CENTER] = 5.0; |
||
| 82 | break;
|
||
| 83 | |||
| 84 | case('V'): //en: c_u_t |
||
| 85 | override[CENTER] = true;
|
||
| 86 | opening[CENTER] = 3.0; |
||
| 87 | break;
|
||
| 88 | |||
| 89 | case('{'): //en: p_a_t |
||
| 90 | //open mouth
|
||
| 91 | override[CENTER] = true;
|
||
| 92 | opening[CENTER] = 12.0; |
||
| 93 | break;
|
||
| 94 | |||
| 95 | case('w'): //en: _w_asp |
||
| 96 | //mouth nearly closed:
|
||
| 97 | override[CENTER] = true;
|
||
| 98 | opening[CENTER] = 4.0; |
||
| 99 | break;
|
||
| 100 | |||
| 101 | case('p'): //Pein + en: _p_in |
||
| 102 | case('b'): //Bein |
||
| 103 | //close mouth at the center:
|
||
| 104 | override[CENTER] = true;
|
||
| 105 | break;
|
||
| 106 | |||
| 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;
|
||
| 115 | |||
| 116 | case('?'): //global stop?! ignore |
||
| 117 | break;
|
||
| 118 | |||
| 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;
|
||
| 125 | |||
| 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;
|
||
| 136 | |||
| 137 | case('S'): //waschen |
||
| 138 | case('O'): //Trotz |
||
| 139 | case('9'): //plötzlich |
||
| 140 | override[CENTER] = true;
|
||
| 141 | opening[CENTER] = 11.0; |
||
| 142 | break;
|
||
| 143 | |||
| 144 | case('m'): //mein |
||
| 145 | override[CENTER] = true;
|
||
| 146 | break;
|
||
| 147 | |||
| 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;
|
||
| 162 | |||
| 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 | } |
||
| 257 | |||
| 258 | |||
| 259 | } |
||
| 260 | |||
| 261 | |||
| 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 | } |
||
| 274 | |||
| 275 | if (override[RIGHT]){
|
||
| 276 | m->opening_right = opening[RIGHT]; |
||
| 277 | }else{
|
||
| 278 | m->opening_right += opening[RIGHT]; |
||
| 279 | } |
||
| 280 | } |