diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c index fff78941..c666e9f1 100644 --- a/src/libespeak-ng/speech.c +++ b/src/libespeak-ng/speech.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -382,7 +383,8 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t SpeakNextClause(NULL, text, 0); if (my_mode == (ENOUTPUT_MODE_SYNCHRONOUS | ENOUTPUT_MODE_SPEAK_AUDIO)) { - for (;;) { + bool continue_speaking = true; + while (continue_speaking) { #ifdef PLATFORM_WINDOWS Sleep(300); // 0.3s #else @@ -396,8 +398,15 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t sleep(1); #endif #endif - if (SynthOnTimer() != 0) - break; + do { + if (WcmdqUsed() > 0) + WavegenOpenSound(); + + if (Generate(phoneme_list, &n_phoneme_list, 1) == 0) { + if (SpeakNextClause(NULL, NULL, 1) == 0) + continue_speaking = WavegenCloseSound() == 0; + } + } while (skipping_text); } return ENS_OK; } diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index 4723dd3f..5a5e3433 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -1530,21 +1530,6 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) return 0; // finished the phoneme list } -int SynthOnTimer() -{ - do { - if (WcmdqUsed() > 0) - WavegenOpenSound(); - - if (Generate(phoneme_list, &n_phoneme_list, 1) == 0) { - if (SpeakNextClause(NULL, NULL, 1) == 0) - return WavegenCloseSound(); - } - } while (skipping_text); - - return 0; -} - int SpeakNextClause(FILE *f_in, const void *text_in, int control) { // Speak text from file (f_in) or memory (text_in) diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index feb47162..d0d1a4b0 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -502,7 +502,6 @@ espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context); void SynthesizeInit(void); int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume); void MakeWave2(PHONEME_LIST *p, int n_ph); -int SynthOnTimer(void); int SpeakNextClause(FILE *f_text, const void *text_in, int control); void SetSpeed(int control); void SetEmbedded(int control, int value);