Browse Source

phoneme_add_feature: support setting the place of articulation.

master
Reece H. Dunn 8 years ago
parent
commit
a48633dc81
2 changed files with 71 additions and 22 deletions
  1. 1
    22
      src/libespeak-ng/compiledata.c
  2. 70
    0
      src/libespeak-ng/phoneme.c

+ 1
- 22
src/libespeak-ng/compiledata.c View File

@@ -71,7 +71,6 @@ enum {
tPHONEME_TYPE = 1,
tPHONEME_FLAG,
tTRANSITION,
tPLACE,
tSTATEMENT,
tINSTRN1,
tWHICH_PHONEME,
@@ -320,20 +319,6 @@ static keywtab_t keywords[] = {
{ "vcd", tPHONEME_FLAG, phVOICED },
{ "vls", tPHONEME_FLAG, phFORTIS },

// place of articulation, set bits 16-19 of phflags
{ "blb", tPLACE, 1 },
{ "lbd", tPLACE, 2 },
{ "dnt", tPLACE, 3 },
{ "alv", tPLACE, 4 },
{ "rfx", tPLACE, 5 },
{ "pla", tPLACE, 6 },
{ "pal", tPLACE, 7 },
{ "vel", tPLACE, 8 },
{ "lbv", tPLACE, 9 },
{ "uvl", tPLACE, 10 },
{ "phr", tPLACE, 11 },
{ "glt", tPLACE, 12 },

// vowel transition attributes
{ "len=", tTRANSITION, 1 },
{ "rms=", tTRANSITION, 2 },
@@ -2013,7 +1998,6 @@ int CompilePhoneme(int compile_phoneme)
if_stack[0].returned = 0;
after_if = 0;
int phoneme_flags = 0;
int place_articulation = 0;

NextItem(tSTRING);
if (compile_phoneme) {
@@ -2039,6 +2023,7 @@ int CompilePhoneme(int compile_phoneme)
phoneme_out->start_type = 0;
phoneme_out->end_type = 0;
phoneme_out->length_mod = 0;
phoneme_out->phflags = 0;

while (!endphoneme && !feof(f_in)) {
if ((keyword = NextItem(tKEYWORD)) < 0) {
@@ -2059,11 +2044,6 @@ int CompilePhoneme(int compile_phoneme)
error("More than one phoneme type: %s", item_string);
phoneme_out->type = keyword;
break;
case tPLACE:
if (place_articulation > 0)
error("Place of articulation has already been given: %s", item_string);
place_articulation = keyword;
break;
case tPHONEME_FLAG:
phoneme_flags |= keyword;
break;
@@ -2292,7 +2272,6 @@ int CompilePhoneme(int compile_phoneme)
error("Phoneme type is missing");
phoneme_out->type = 0;
}
phoneme_out->phflags = place_articulation << 16;
phoneme_out->phflags |= phoneme_flags;

if (phoneme_out->phflags & phVOICED) {

+ 70
- 0
src/libespeak-ng/phoneme.c View File

@@ -47,6 +47,21 @@ enum feature_t {
vwl = FEATURE('v', 'w', 'l'),
lat = FEATURE('l', 'a', 't'),
sib = FEATURE('s', 'i', 'b'),
// place of articulation
blb = FEATURE('b', 'l', 'b'),
lbd = FEATURE('l', 'b', 'd'),
bld = FEATURE('b', 'l', 'd'),
dnt = FEATURE('d', 'n', 't'),
alv = FEATURE('a', 'l', 'v'),
pla = FEATURE('p', 'l', 'a'),
rfx = FEATURE('r', 'f', 'x'),
alp = FEATURE('a', 'l', 'p'),
pal = FEATURE('p', 'a', 'l'),
vel = FEATURE('v', 'e', 'l'),
lbv = FEATURE('l', 'b', 'v'),
uvl = FEATURE('u', 'v', 'l'),
phr = FEATURE('p', 'h', 'r'),
glt = FEATURE('g', 'l', 't'),
};

uint32_t lookup_feature(const char *feature) {
@@ -94,6 +109,61 @@ phoneme_add_feature(PHONEME_TAB *phoneme,
case sib:
phoneme->phflags |= phSIBILANT;
break;
// place of articulation
case blb:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 1 << 16;
break;
case lbd:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 2 << 16;
break;
case dnt:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 3 << 16;
break;
case alv:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 4 << 16;
break;
case rfx:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 5 << 16;
break;
case pla:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 6 << 16;
break;
case pal:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 7 << 16;
break;
case vel:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 8 << 16;
break;
case lbv:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 9 << 16;
break;
case uvl:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 10 << 16;
break;
case phr:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 11 << 16;
break;
case glt:
phoneme->phflags &= ~phARTICULATION;
phoneme->phflags |= 12 << 16;
break;
case bld:
// FIXME: Not supported by eSpeak. Used in German p͡f.
break;
case alp:
// FIXME: Not supported by eSpeak. Used in Chinese/Japanese ɕ and ʑ.
break;
// invalid phoneme feature
default:
return create_name_error_context(context, ENS_UNKNOWN_PHONEME_FEATURE, feature);

Loading…
Cancel
Save