diff --git a/Makefile.am b/Makefile.am index 82202bd0..61b77d7c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -141,6 +141,7 @@ src_libespeak_ng_la_SOURCES = \ src/libespeak-ng/intonation.c \ src/libespeak-ng/numbers.c \ src/libespeak-ng/readclause.c \ + src/libespeak-ng/phoneme.c \ src/libespeak-ng/phonemelist.c \ src/libespeak-ng/setlengths.c \ src/libespeak-ng/spect.c \ diff --git a/src/include/espeak-ng/espeak_ng.h b/src/include/espeak-ng/espeak_ng.h index afa8e547..13d33504 100644 --- a/src/include/espeak-ng/espeak_ng.h +++ b/src/include/espeak-ng/espeak_ng.h @@ -41,6 +41,7 @@ typedef enum { ENS_GROUP_ERRNO = 0x00000000, /* Values 0-255 map to errno error codes. */ ENS_GROUP_ESPEAK_NG = 0x10000000, /* eSpeak NG error codes. */ + /* eSpeak NG 1.49.0 */ ENS_OK = 0, ENS_COMPILE_ERROR = 0x100001FF, ENS_VERSION_MISMATCH = 0x100002FF, @@ -56,6 +57,9 @@ typedef enum { ENS_NO_SPECT_FRAMES = 0x10000CFF, ENS_EMPTY_PHONEME_MANIFEST = 0x10000DFF, ENS_SPEECH_STOPPED = 0x10000EFF, + + /* eSpeak NG 1.49.2 */ + ENS_UNKNOWN_PHONEME_FEATURE = 0x10000FFF, } espeak_ng_STATUS; typedef enum { diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index c5ea72b9..97259a23 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -2054,6 +2054,9 @@ int CompilePhoneme(int compile_phoneme) continue; } + if (phoneme_add_feature(phoneme_out, item_string, NULL) == ENS_OK) + continue; + switch (item_type) { case tPHONEME_TYPE: diff --git a/src/libespeak-ng/error.c b/src/libespeak-ng/error.c index fe427b7d..50537761 100644 --- a/src/libespeak-ng/error.c +++ b/src/libespeak-ng/error.c @@ -121,6 +121,9 @@ ESPEAK_NG_API void espeak_ng_GetStatusCodeMessage(espeak_ng_STATUS status, char case ENS_EMPTY_PHONEME_MANIFEST: strncpy0(buffer, "The phoneme manifest file does not contain any phonemes", length); break; + case ENS_UNKNOWN_PHONEME_FEATURE: + strncpy0(buffer, "The phoneme feature is not recognised", length); + break; default: if ((status & ENS_GROUP_MASK) == ENS_GROUP_ERRNO) strerror_r(status, buffer, length); diff --git a/src/libespeak-ng/phoneme.c b/src/libespeak-ng/phoneme.c new file mode 100644 index 00000000..a5f07bea --- /dev/null +++ b/src/libespeak-ng/phoneme.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2016 Reece H. Dunn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see: . + */ + +#include "config.h" + +#include + +#include +#include + +#include "phoneme.h" +#include "speech.h" +#include "error.h" + +enum feature_t { + inv, // invalid phoneme feature name +}; + +static MNEM_TAB features[] = { + { NULL, inv }, +}; + +espeak_ng_STATUS +phoneme_add_feature(PHONEME_TAB *phoneme, + const char *feature, + espeak_ng_ERROR_CONTEXT *context) +{ + if (!phoneme || !feature) return -EINVAL; + + switch (LookupMnem(features, feature)) + { + default: + return ENS_UNKNOWN_PHONEME_FEATURE; + } + return ENS_OK; +} diff --git a/src/libespeak-ng/phoneme.h b/src/libespeak-ng/phoneme.h index a83ad186..7ae486a2 100644 --- a/src/libespeak-ng/phoneme.h +++ b/src/libespeak-ng/phoneme.h @@ -113,6 +113,11 @@ typedef struct { unsigned char length_mod; // a length_mod group number, used to access length_mod_tab } PHONEME_TAB; +espeak_ng_STATUS +phoneme_add_feature(PHONEME_TAB *phoneme, + const char *feature, + espeak_ng_ERROR_CONTEXT *context); + // Several phoneme tables may be loaded into memory. phoneme_tab points to // one for the current voice extern int n_phoneme_tab;