Skip to content

Commit 78ac6c4

Browse files
committed
code cleanup: do not compile mbrola if not enabled
1 parent 92beee2 commit 78ac6c4

7 files changed

Lines changed: 35 additions & 5 deletions

File tree

Makefile.am

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ EXTRA_DIST += ChangeLog
5050

5151
all-local: \
5252
espeak-ng-data/phontab \
53-
dictionaries \
54-
mbrola
53+
dictionaries
5554

5655
uninstall-hook:
5756
rm -rf $(DESTDIR)$(DATADIR)
@@ -158,7 +157,6 @@ src_libespeak_ng_la_SOURCES = \
158157
src/libespeak-ng/common.c \
159158
src/libespeak-ng/compiledata.c \
160159
src/libespeak-ng/compiledict.c \
161-
src/libespeak-ng/compilembrola.c \
162160
src/libespeak-ng/dictionary.c \
163161
src/libespeak-ng/encoding.c \
164162
src/libespeak-ng/error.c \
@@ -178,7 +176,6 @@ src_libespeak_ng_la_SOURCES = \
178176
src/libespeak-ng/ssml.c \
179177
src/libespeak-ng/synthdata.c \
180178
src/libespeak-ng/synthesize.c \
181-
src/libespeak-ng/synth_mbrola.c \
182179
src/libespeak-ng/translate.c \
183180
src/libespeak-ng/translateword.c \
184181
src/libespeak-ng/tr_languages.c \
@@ -244,7 +241,10 @@ endif
244241

245242
if OPT_MBROLA
246243
AM_CFLAGS += -DUSE_MBROLA=1
247-
src_libespeak_ng_la_SOURCES += src/libespeak-ng/mbrowrap.c
244+
src_libespeak_ng_la_SOURCES += \
245+
src/libespeak-ng/mbrowrap.c \
246+
src/libespeak-ng/synth_mbrola.c \
247+
src/libespeak-ng/compilembrola.c
248248
endif
249249

250250
if OPT_ASYNC
@@ -956,6 +956,8 @@ dictsource/yue_emoji:
956956

957957
##### mbrola:
958958

959+
if OPT_MBROLA
960+
959961
PHSOURCE_MBROLA = \
960962
$(wildcard phsource/mbrola/*)
961963

@@ -967,3 +969,7 @@ espeak-ng-data/mbrola_ph/%_phtrans: phsource/mbrola/% src/espeak-ng
967969
ESPEAK_DATA_PATH=$(CURDIR) src/espeak-ng --compile-mbrola=phsource/mbrola/$*
968970

969971
EXTRA_DIST += $(PHSOURCE_MBROLA)
972+
973+
all-local: mbrola
974+
975+
endif

src/espeak-ng.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ static const char *help_text =
8989
"\t Compile pronunciation rules and dictionary from the current\n"
9090
"\t directory, including line numbers for use with -X.\n"
9191
"\t <voice name> specifies the language\n"
92+
#if USE_MBROLA
9293
"--compile-mbrola=<voice name>\n"
9394
"\t Compile an MBROLA voice\n"
95+
#endif
9496
"--compile-intonations\n"
9597
"\t Compile the intonation data\n"
9698
"--compile-phonemes=<phsource-dir>\n"
@@ -323,7 +325,9 @@ int main(int argc, char **argv)
323325
{ "version", no_argument, 0, 0x10b },
324326
{ "sep", optional_argument, 0, 0x10c },
325327
{ "tie", optional_argument, 0, 0x10d },
328+
#if USE_MBROLA
326329
{ "compile-mbrola", optional_argument, 0, 0x10e },
330+
#endif
327331
{ "compile-intonations", no_argument, 0, 0x10f },
328332
{ "compile-phonemes", optional_argument, 0, 0x110 },
329333
{ "load", no_argument, 0, 0x111 },
@@ -536,6 +540,7 @@ int main(int argc, char **argv)
536540
if (phonemes_separator == 'z')
537541
phonemes_separator = 0x200d; // ZWJ
538542
break;
543+
#if USE_MBROLA
539544
case 0x10e: // --compile-mbrola
540545
{
541546
espeak_ng_InitializePath(data_path);
@@ -548,6 +553,7 @@ int main(int argc, char **argv)
548553
}
549554
return EXIT_SUCCESS;
550555
}
556+
#endif
551557
case 0x10f: // --compile-intonations
552558
{
553559
espeak_ng_InitializePath(data_path);

src/libespeak-ng/speech.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un
523523
ep->text_position = char_position & 0xffffff;
524524
ep->length = char_position >> 24;
525525

526+
#if !USE_MBROLA
527+
static const int mbrola_delay = 0;
528+
#endif
529+
526530
time = ((double)(count_samples + mbrola_delay + (out_ptr - out_start)/2)*1000.0)/samplerate;
527531
ep->audio_position = (int)time;
528532
ep->sample = (count_samples + mbrola_delay + (out_ptr - out_start)/2);

src/libespeak-ng/synthdata.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,14 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
639639
{
640640
case 1: // PreVoicing
641641
return control & 1;
642+
#if USE_KLATT
642643
case 2: // KlattSynth
643644
return voice->klattv[0] != 0;
645+
#endif
646+
#if USE_MBROLA
644647
case 3: // MbrolaSynth
645648
return mbrola_name[0] != 0;
649+
#endif
646650
}
647651
}
648652
return false;

src/libespeak-ng/synthesize.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,8 +1148,10 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume)
11481148
if (option_phoneme_events & espeakINITIALIZE_PHONEME_IPA)
11491149
use_ipa = 1;
11501150

1151+
#if USE_MBROLA
11511152
if (mbrola_name[0] != 0)
11521153
return MbrolaGenerate(phoneme_list, n_ph, resume);
1154+
#endif
11531155

11541156
if (resume == false) {
11551157
ix = 1;

src/libespeak-ng/voices.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ void VoiceReset(int tone_only)
305305

306306
if (tone_only == 0) {
307307
n_replace_phonemes = 0;
308+
#if USE_MBROLA
308309
LoadMbrolaTable(NULL, NULL, 0);
310+
#endif
309311
}
310312

311313
// probably unnecessary, but removing this would break tests
@@ -649,6 +651,7 @@ voice_t *LoadVoice(const char *vname, int control)
649651
sscanf(p, "%d", &voice->speed_percent);
650652
SetSpeed(3);
651653
break;
654+
#if USE_MBROLA
652655
case V_MBROLA:
653656
{
654657
int srate = 16000;
@@ -665,11 +668,14 @@ voice_t *LoadVoice(const char *vname, int control)
665668
voice->samplerate = srate;
666669
}
667670
break;
671+
#endif
672+
#if USE_KLATT
668673
case V_KLATT:
669674
voice->klattv[0] = 1; // default source: IMPULSIVE
670675
Read8Numbers(p, voice->klattv);
671676
voice->klattv[KLATT_Kopen] -= 40;
672677
break;
678+
#endif
673679
case V_FAST:
674680
sscanf(p, "%d", &speed.fast_settings);
675681
SetSpeed(3);

src/libespeak-ng/wavegen.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,10 @@ void WcmdqStop()
246246
}
247247
#endif
248248

249+
#if USE_MBROLA
249250
if (mbrola_name[0] != 0)
250251
MbrolaReset();
252+
#endif
251253
}
252254

253255
int WcmdqFree()

0 commit comments

Comments
 (0)