From a48633dc814de5203c7ad553b0610efea5d64640 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Wed, 25 Jan 2017 21:06:04 +0000 Subject: [PATCH] phoneme_add_feature: support setting the place of articulation. --- src/libespeak-ng/compiledata.c | 23 +---------- src/libespeak-ng/phoneme.c | 70 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 22 deletions(-) diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 71d00574..800878e2 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -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) { diff --git a/src/libespeak-ng/phoneme.c b/src/libespeak-ng/phoneme.c index 15f0b49b..17248b58 100644 --- a/src/libespeak-ng/phoneme.c +++ b/src/libespeak-ng/phoneme.c @@ -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);