| 1 |
/* |
| 2 |
* Copyright (C) 2017 Reece H. Dunn |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 3 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, see: <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include "config.h" |
| 19 |
|
| 20 |
#include <errno.h> |
| 21 |
#include <stdint.h> |
| 22 |
#include <string.h> |
| 23 |
|
| 24 |
#include "espeak_ng.h" |
| 25 |
#include "speak_lib.h" |
| 26 |
|
| 27 |
#include "phoneme.h" |
| 28 |
|
| 29 |
phoneme_feature_t phoneme_feature_from_string(const char *feature) |
| 30 |
{ |
| 31 |
if (!feature || strlen(feature) != 3) |
| 32 |
return inv; |
| 33 |
return (feature[0] << 16) | (feature[1] << 8) | feature[2]; |
| 34 |
} |
| 35 |
|
| 36 |
espeak_ng_STATUS |
| 37 |
phoneme_add_feature(PHONEME_TAB *phoneme, |
| 38 |
phoneme_feature_t feature) |
| 39 |
{ |
| 40 |
if (!phoneme) return EINVAL; |
| 41 |
switch (feature) |
| 42 |
{ |
| 43 |
// manner of articulation |
| 44 |
case nas: |
| 45 |
phoneme->type = phNASAL; |
| 46 |
break; |
| 47 |
case stp: |
| 48 |
case afr: // FIXME: eSpeak treats 'afr' as 'stp'. |
| 49 |
phoneme->type = phSTOP; |
| 50 |
break; |
| 51 |
case frc: |
| 52 |
case apr: // FIXME: eSpeak is using this for [h], with 'liquid' used for [l] and [r]. |
| 53 |
phoneme->type = phFRICATIVE; |
| 54 |
break; |
| 55 |
case flp: // FIXME: Why is eSpeak using a vstop (vcd + stp) for this? |
| 56 |
phoneme->type = phVSTOP; |
| 57 |
break; |
| 58 |
case trl: // FIXME: 'trill' should be the type; 'liquid' should be a flag (phoneme files specify both). |
| 59 |
phoneme->phflags |= phTRILL; |
| 60 |
break; |
| 61 |
case clk: |
| 62 |
case ejc: |
| 63 |
case imp: |
| 64 |
case lat: |
| 65 |
// Not supported by eSpeak. |
| 66 |
break; |
| 67 |
case vwl: |
| 68 |
phoneme->type = phVOWEL; |
| 69 |
break; |
| 70 |
case sib: |
| 71 |
phoneme->phflags |= phSIBILANT; |
| 72 |
break; |
| 73 |
// place of articulation |
| 74 |
case blb: |
| 75 |
phoneme->phflags &= ~phARTICULATION; |
| 76 |
phoneme->phflags |= phPLACE_BILABIAL << 16; |
| 77 |
break; |
| 78 |
case lbd: |
| 79 |
phoneme->phflags &= ~phARTICULATION; |
| 80 |
phoneme->phflags |= phPLACE_LABIODENTAL << 16; |
| 81 |
break; |
| 82 |
case dnt: |
| 83 |
phoneme->phflags &= ~phARTICULATION; |
| 84 |
phoneme->phflags |= phPLACE_DENTAL << 16; |
| 85 |
break; |
| 86 |
case alv: |
| 87 |
phoneme->phflags &= ~phARTICULATION; |
| 88 |
phoneme->phflags |= phPLACE_ALVEOLAR << 16; |
| 89 |
break; |
| 90 |
case rfx: |
| 91 |
phoneme->phflags &= ~phARTICULATION; |
| 92 |
phoneme->phflags |= phPLACE_RETROFLEX << 16; |
| 93 |
break; |
| 94 |
case pla: |
| 95 |
phoneme->phflags &= ~phARTICULATION; |
| 96 |
phoneme->phflags |= phPLACE_PALATO_ALVEOLAR << 16; |
| 97 |
break; |
| 98 |
case pal: |
| 99 |
phoneme->phflags &= ~phARTICULATION; |
| 100 |
phoneme->phflags |= phPLACE_PALATAL << 16; |
| 101 |
phoneme->phflags |= phPALATAL; |
| 102 |
break; |
| 103 |
case vel: |
| 104 |
phoneme->phflags &= ~phARTICULATION; |
| 105 |
phoneme->phflags |= phPLACE_VELAR << 16; |
| 106 |
break; |
| 107 |
case lbv: |
| 108 |
phoneme->phflags &= ~phARTICULATION; |
| 109 |
phoneme->phflags |= phPLACE_LABIO_VELAR << 16; |
| 110 |
break; |
| 111 |
case uvl: |
| 112 |
phoneme->phflags &= ~phARTICULATION; |
| 113 |
phoneme->phflags |= phPLACE_UVULAR << 16; |
| 114 |
break; |
| 115 |
case phr: |
| 116 |
phoneme->phflags &= ~phARTICULATION; |
| 117 |
phoneme->phflags |= phPLACE_PHARYNGEAL << 16; |
| 118 |
break; |
| 119 |
case glt: |
| 120 |
phoneme->phflags &= ~phARTICULATION; |
| 121 |
phoneme->phflags |= phPLACE_GLOTTAL << 16; |
| 122 |
break; |
| 123 |
case bld: |
| 124 |
phoneme->phflags &= ~phARTICULATION; |
| 125 |
phoneme->phflags |= phPLACE_BILABIAL << 16; |
| 126 |
break; |
| 127 |
case alp: // pla pzd |
| 128 |
phoneme->phflags &= ~phARTICULATION; |
| 129 |
phoneme->phflags |= phPLACE_PALATO_ALVEOLAR << 16; |
| 130 |
phoneme->phflags |= phPALATAL; |
| 131 |
break; |
| 132 |
// voice |
| 133 |
case vcd: |
| 134 |
phoneme->phflags |= phVOICED; |
| 135 |
break; |
| 136 |
case vls: |
| 137 |
phoneme->phflags |= phVOICELESS; |
| 138 |
break; |
| 139 |
// vowel height |
| 140 |
case hgh: |
| 141 |
case smh: |
| 142 |
case umd: |
| 143 |
case mid: |
| 144 |
case lmd: |
| 145 |
case sml: |
| 146 |
case low: |
| 147 |
// Not supported by eSpeak. |
| 148 |
break; |
| 149 |
// vowel backness |
| 150 |
case fnt: |
| 151 |
case cnt: |
| 152 |
case bck: |
| 153 |
// Not supported by eSpeak. |
| 154 |
break; |
| 155 |
// rounding |
| 156 |
case unr: |
| 157 |
case rnd: |
| 158 |
// Not supported by eSpeak. |
| 159 |
break; |
| 160 |
// articulation |
| 161 |
case lgl: |
| 162 |
case idt: |
| 163 |
case apc: |
| 164 |
case lmn: |
| 165 |
// Not supported by eSpeak. |
| 166 |
break; |
| 167 |
// air flow |
| 168 |
case egs: |
| 169 |
case igs: |
| 170 |
// Not supported by eSpeak. |
| 171 |
break; |
| 172 |
// phonation |
| 173 |
case brv: |
| 174 |
case slv: |
| 175 |
case stv: |
| 176 |
case crv: |
| 177 |
case glc: |
| 178 |
// Not supported by eSpeak. |
| 179 |
break; |
| 180 |
// rounding and labialization |
| 181 |
case ptr: |
| 182 |
case cmp: |
| 183 |
case mrd: |
| 184 |
case lrd: |
| 185 |
// Not supported by eSpeak. |
| 186 |
break; |
| 187 |
// syllabicity |
| 188 |
case syl: |
| 189 |
// Not supported by eSpeak. |
| 190 |
break; |
| 191 |
case nsy: |
| 192 |
phoneme->phflags |= phNONSYLLABIC; |
| 193 |
break; |
| 194 |
// consonant release |
| 195 |
case asp: |
| 196 |
case nrs: |
| 197 |
case lrs: |
| 198 |
case unx: |
| 199 |
// Not supported by eSpeak. |
| 200 |
break; |
| 201 |
// coarticulation |
| 202 |
case pzd: |
| 203 |
phoneme->phflags |= phPALATAL; |
| 204 |
break; |
| 205 |
case vzd: |
| 206 |
case fzd: |
| 207 |
case nzd: |
| 208 |
case rzd: |
| 209 |
// Not supported by eSpeak. |
| 210 |
break; |
| 211 |
// tongue root |
| 212 |
case atr: |
| 213 |
case rtr: |
| 214 |
// Not supported by eSpeak. |
| 215 |
break; |
| 216 |
// fortis and lenis |
| 217 |
case fts: |
| 218 |
case lns: |
| 219 |
// Not supported by eSpeak. |
| 220 |
break; |
| 221 |
// length |
| 222 |
case est: |
| 223 |
case hlg: |
| 224 |
// Not supported by eSpeak. |
| 225 |
break; |
| 226 |
case elg: // FIXME: Should be longer than 'lng'. |
| 227 |
case lng: |
| 228 |
phoneme->phflags |= phLONG; |
| 229 |
break; |
| 230 |
// invalid phoneme feature |
| 231 |
default: |
| 232 |
return ENS_UNKNOWN_PHONEME_FEATURE; |
| 233 |
} |
| 234 |
return ENS_OK; |
| 235 |
} |