From 0e3e90126e2a91f430c2b9045b156a8d833c323d Mon Sep 17 00:00:00 2001 From: jonsd Date: Fri, 5 Oct 2007 11:04:43 +0000 Subject: [PATCH] Ensure echo completes one echo period at the end of speech. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@90 d46cf337-b52f-0410-862d-fd96e6ae7743 --- dictsource/fr_list | 8 +++++++- src/wavegen.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/dictsource/fr_list b/dictsource/fr_list index 5203e3b3..a66959df 100755 --- a/dictsource/fr_list +++ b/dictsource/fr_list @@ -1,4 +1,4 @@ - + // This file in UTF8 encoded // 2006-11-18 Gilles Casse @@ -351,6 +351,11 @@ résident Rezidt2 $verb couvent k'uvt2 $verb concurrent kO~kyR'A~ récurrent RekyR'A~ +ferment fErm'A~ +ferment f'Ermt2 $verb +sergent sErZ'A~ +serment sErm'A~ +serpent sErp'A~ // MAIN WORD DICTIONARY @@ -591,3 +596,4 @@ vincent vE~sA~ + diff --git a/src/wavegen.cpp b/src/wavegen.cpp index 13221957..1f01fa1a 100755 --- a/src/wavegen.cpp +++ b/src/wavegen.cpp @@ -80,6 +80,7 @@ static int peak_height[N_PEAKS]; #define N_ECHO_BUF 5500 // max of 250mS at 22050 Hz static int echo_head; static int echo_tail; +static int echo_length = 0; // period (in sample\) to ensure completion of echo at the end of speech, set in WavegenSetEcho() static int echo_amp = 0; static short echo_buf[N_ECHO_BUF]; @@ -821,11 +822,13 @@ static void WavegenSetEcho(void) if(delay == 0) amp = 0; echo_head = (delay * samplerate)/1000; + echo_length = echo_head; // ensure completion of echo at the end of speech +// echo_length = echo_head * 2; // perhaps allow 2 echo periods at the end of speech ? echo_amp = amp; // compensate (partially) for increase in amplitude due to echo general_amplitude = GetAmplitude(); general_amplitude = ((general_amplitude * (512-amp))/512); -} +} // end of WavegenSetEcho @@ -1362,6 +1365,9 @@ static int PlaySilence(int length, int resume) static int n_samples; int value=0; + if(length == 0) + return(0); + nsamples = 0; samplecount = 0; @@ -1826,6 +1832,7 @@ int WavegenFill(int fill_zeros) int length; int result; static int resume=0; + static int echo_complete=0; #ifdef TEST_MBROLA if(mbrola_name[0] != 0) @@ -1836,6 +1843,17 @@ int WavegenFill(int fill_zeros) { if(WcmdqUsed() <= 0) { +#define echo2 +#ifdef echo2 + if(echo_complete > 0) + { + // continue to play silence until echo is completed + resume = PlaySilence(echo_complete,resume); + if(resume == 1) + return(0); // not yet finished + } +#endif + if(fill_zeros) { while(out_ptr < out_end) @@ -1855,12 +1873,16 @@ int WavegenFill(int fill_zeros) break; case WCMD_PAUSE: + if(resume==0) + { + echo_complete -= length; + } n_mix_wavefile = 0; - if(length==0) break; result = PlaySilence(length,resume); break; case WCMD_WAVE: + echo_complete = echo_length; n_mix_wavefile = 0; result = PlayWave(length,resume,(unsigned char*)q[2], q[3] & 0xff, q[3] >> 8); break; @@ -1880,6 +1902,7 @@ int WavegenFill(int fill_zeros) case WCMD_SPECT2: // as WCMD_SPECT but stop any concurrent wave file n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case case WCMD_SPECT: + echo_complete = echo_length; result = Wavegen2(length & 0xffff,q[1] >> 16,resume,(frame_t *)q[2],(frame_t *)q[3]); break;