From 78ac6c4a882517d611ec0b23bda2e48e661e89f1 Mon Sep 17 00:00:00 2001 From: Yury Popov Date: Sun, 27 Nov 2022 13:57:15 +0300 Subject: [PATCH] code cleanup: do not compile mbrola if not enabled --- Makefile.am | 16 +++++++++++----- src/espeak-ng.c | 6 ++++++ src/libespeak-ng/speech.c | 4 ++++ src/libespeak-ng/synthdata.c | 4 ++++ src/libespeak-ng/synthesize.c | 2 ++ src/libespeak-ng/voices.c | 6 ++++++ src/libespeak-ng/wavegen.c | 2 ++ 7 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 79470157..b7d070eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,8 +50,7 @@ EXTRA_DIST += ChangeLog all-local: \ espeak-ng-data/phontab \ - dictionaries \ - mbrola + dictionaries uninstall-hook: rm -rf $(DESTDIR)$(DATADIR) @@ -158,7 +157,6 @@ src_libespeak_ng_la_SOURCES = \ src/libespeak-ng/common.c \ src/libespeak-ng/compiledata.c \ src/libespeak-ng/compiledict.c \ - src/libespeak-ng/compilembrola.c \ src/libespeak-ng/dictionary.c \ src/libespeak-ng/encoding.c \ src/libespeak-ng/error.c \ @@ -178,7 +176,6 @@ src_libespeak_ng_la_SOURCES = \ src/libespeak-ng/ssml.c \ src/libespeak-ng/synthdata.c \ src/libespeak-ng/synthesize.c \ - src/libespeak-ng/synth_mbrola.c \ src/libespeak-ng/translate.c \ src/libespeak-ng/translateword.c \ src/libespeak-ng/tr_languages.c \ @@ -244,7 +241,10 @@ endif if OPT_MBROLA AM_CFLAGS += -DUSE_MBROLA=1 -src_libespeak_ng_la_SOURCES += src/libespeak-ng/mbrowrap.c +src_libespeak_ng_la_SOURCES += \ + src/libespeak-ng/mbrowrap.c \ + src/libespeak-ng/synth_mbrola.c \ + src/libespeak-ng/compilembrola.c endif if OPT_ASYNC @@ -956,6 +956,8 @@ dictsource/yue_emoji: ##### mbrola: +if OPT_MBROLA + PHSOURCE_MBROLA = \ $(wildcard phsource/mbrola/*) @@ -967,3 +969,7 @@ espeak-ng-data/mbrola_ph/%_phtrans: phsource/mbrola/% src/espeak-ng ESPEAK_DATA_PATH=$(CURDIR) src/espeak-ng --compile-mbrola=phsource/mbrola/$* EXTRA_DIST += $(PHSOURCE_MBROLA) + +all-local: mbrola + +endif diff --git a/src/espeak-ng.c b/src/espeak-ng.c index 8af9f89b..a57653f9 100644 --- a/src/espeak-ng.c +++ b/src/espeak-ng.c @@ -89,8 +89,10 @@ static const char *help_text = "\t Compile pronunciation rules and dictionary from the current\n" "\t directory, including line numbers for use with -X.\n" "\t specifies the language\n" +#if USE_MBROLA "--compile-mbrola=\n" "\t Compile an MBROLA voice\n" +#endif "--compile-intonations\n" "\t Compile the intonation data\n" "--compile-phonemes=\n" @@ -323,7 +325,9 @@ int main(int argc, char **argv) { "version", no_argument, 0, 0x10b }, { "sep", optional_argument, 0, 0x10c }, { "tie", optional_argument, 0, 0x10d }, +#if USE_MBROLA { "compile-mbrola", optional_argument, 0, 0x10e }, +#endif { "compile-intonations", no_argument, 0, 0x10f }, { "compile-phonemes", optional_argument, 0, 0x110 }, { "load", no_argument, 0, 0x111 }, @@ -536,6 +540,7 @@ int main(int argc, char **argv) if (phonemes_separator == 'z') phonemes_separator = 0x200d; // ZWJ break; +#if USE_MBROLA case 0x10e: // --compile-mbrola { espeak_ng_InitializePath(data_path); @@ -548,6 +553,7 @@ int main(int argc, char **argv) } return EXIT_SUCCESS; } +#endif case 0x10f: // --compile-intonations { espeak_ng_InitializePath(data_path); diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c index 71065bf7..eb427e97 100644 --- a/src/libespeak-ng/speech.c +++ b/src/libespeak-ng/speech.c @@ -523,6 +523,10 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un ep->text_position = char_position & 0xffffff; ep->length = char_position >> 24; +#if !USE_MBROLA + static const int mbrola_delay = 0; +#endif + time = ((double)(count_samples + mbrola_delay + (out_ptr - out_start)/2)*1000.0)/samplerate; ep->audio_position = (int)time; ep->sample = (count_samples + mbrola_delay + (out_ptr - out_start)/2); diff --git a/src/libespeak-ng/synthdata.c b/src/libespeak-ng/synthdata.c index c4d4a188..c366c201 100644 --- a/src/libespeak-ng/synthdata.c +++ b/src/libespeak-ng/synthdata.c @@ -639,10 +639,14 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, { case 1: // PreVoicing return control & 1; +#if USE_KLATT case 2: // KlattSynth return voice->klattv[0] != 0; +#endif +#if USE_MBROLA case 3: // MbrolaSynth return mbrola_name[0] != 0; +#endif } } return false; diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index 645bd3bf..eb50ba9e 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -1148,8 +1148,10 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume) if (option_phoneme_events & espeakINITIALIZE_PHONEME_IPA) use_ipa = 1; +#if USE_MBROLA if (mbrola_name[0] != 0) return MbrolaGenerate(phoneme_list, n_ph, resume); +#endif if (resume == false) { ix = 1; diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index 6bf6b541..98f0cb82 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -305,7 +305,9 @@ void VoiceReset(int tone_only) if (tone_only == 0) { n_replace_phonemes = 0; +#if USE_MBROLA LoadMbrolaTable(NULL, NULL, 0); +#endif } // probably unnecessary, but removing this would break tests @@ -649,6 +651,7 @@ voice_t *LoadVoice(const char *vname, int control) sscanf(p, "%d", &voice->speed_percent); SetSpeed(3); break; +#if USE_MBROLA case V_MBROLA: { int srate = 16000; @@ -665,11 +668,14 @@ voice_t *LoadVoice(const char *vname, int control) voice->samplerate = srate; } break; +#endif +#if USE_KLATT case V_KLATT: voice->klattv[0] = 1; // default source: IMPULSIVE Read8Numbers(p, voice->klattv); voice->klattv[KLATT_Kopen] -= 40; break; +#endif case V_FAST: sscanf(p, "%d", &speed.fast_settings); SetSpeed(3); diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c index fe8dfc02..5813b3ad 100644 --- a/src/libespeak-ng/wavegen.c +++ b/src/libespeak-ng/wavegen.c @@ -246,8 +246,10 @@ void WcmdqStop() } #endif +#if USE_MBROLA if (mbrola_name[0] != 0) MbrolaReset(); +#endif } int WcmdqFree()