From 26e453dd2f2a1d32e628566e1915f49277167310 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Wed, 11 Jan 2017 07:30:19 +0000 Subject: [PATCH] Don't reset the parameters unless they have been set. This is based on a patch by Samuel Thibault. This is needed when espeak_Cancel is called before espeak_Synth, like can be done in brltty. --- CHANGELOG.md | 1 + src/libespeak-ng/speech.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13bd3dca..188a3369 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ bug fixes: * Fixes for running the spect code on big-endian architectures. * Fix determining the voice directory when installing the 32-bit Windows binaries on a 64-bit Windows system. +* Don't reset the speech parameters unless they have already been set. updated languages: diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c index ab76526a..158b7edf 100644 --- a/src/libespeak-ng/speech.c +++ b/src/libespeak-ng/speech.c @@ -73,6 +73,7 @@ static espeak_ng_OUTPUT_MODE my_mode = ENOUTPUT_MODE_SYNCHRONOUS; static int out_samplerate = 0; static int voice_samplerate = 22050; static espeak_ng_STATUS err = ENS_OK; +static int did_save_parameters = 0; t_espeak_callback *synth_callback = NULL; int (*uri_callback)(int, const char *, const char *) = NULL; @@ -488,6 +489,7 @@ espeak_ng_STATUS sync_espeak_Synth(unsigned int unique_identifier, const void *t my_unique_identifier = unique_identifier; my_user_data = user_data; + did_save_parameters = 1; for (int i = 0; i < N_SPEECH_PARAM; i++) saved_parameters[i] = param_stack[0].parameter[i]; @@ -827,8 +829,11 @@ ESPEAK_NG_API espeak_ng_STATUS espeak_ng_Cancel(void) #endif embedded_value[EMBED_T] = 0; // reset echo for pronunciation announcements - for (int i = 0; i < N_SPEECH_PARAM; i++) - SetParameter(i, saved_parameters[i], 0); + if (did_save_parameters) { + for (int i = 0; i < N_SPEECH_PARAM; i++) + SetParameter(i, saved_parameters[i], 0); + did_save_parameters = 0; + } return ENS_OK; }