Browse Source

Fix a numerical overflow in wavegen() which could cause distortion when a voice file increases the height of formant peaks.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@92 d46cf337-b52f-0410-862d-fd96e6ae7743
master
jonsd 17 years ago
parent
commit
e5f2d6f4c6
5 changed files with 14 additions and 23 deletions
  1. 1
    1
      src/Makefile
  2. 10
    19
      src/phonemelist.cpp
  3. 1
    1
      src/synthesize.h
  4. 1
    1
      src/translate.cpp
  5. 1
    1
      src/wavegen.cpp

+ 1
- 1
src/Makefile View File

LIBDIR=/usr/lib LIBDIR=/usr/lib
DATADIR=/usr/share/espeak-data DATADIR=/usr/share/espeak-data


RELEASE = 1.24
RELEASE = 1.29
BIN_NAME = speak BIN_NAME = speak
BIN2_NAME = espeak BIN2_NAME = espeak
LIB_NAME = libespeak.so LIB_NAME = libespeak.so

+ 10
- 19
src/phonemelist.cpp View File

int regression; int regression;
int end_sourceix; int end_sourceix;
int alternative; int alternative;
int first_vowel=0; // first vowel in a word
PHONEME_LIST2 ph_list3[N_PHONEME_LIST]; PHONEME_LIST2 ph_list3[N_PHONEME_LIST];


static PHONEME_LIST2 ph_list2_null = {0,0,0,0,0}; static PHONEME_LIST2 ph_list2_null = {0,0,0,0,0};
// the last word is unstressed, look for a previous word that can be stressed // the last word is unstressed, look for a previous word that can be stressed
while(--j >= 0) while(--j >= 0)
{ {
if(ph_list2[j].stress & 0x80) // dictionary flags indicated that this stress can be promoted
if(ph_list2[j].synthflags & SFLAG_PROMOTE_STRESS) // dictionary flags indicated that this stress can be promoted
{ {
ph_list2[j].stress = 4; // promote to stressed ph_list2[j].stress = 4; // promote to stressed
break; break;
} }
if((ph_list2[j].stress & 0x7f) >= 4)
if(ph_list2[j].stress >= 4)
{ {
// found a stressed syllable, so stop looking // found a stressed syllable, so stop looking
break; break;
// start of a word // start of a word
int k; int k;
word_stress = 0; word_stress = 0;
first_vowel = 1;


// find the highest stress level in this word // find the highest stress level in this word
for(k=j+1; k < n_ph_list2; k++) for(k=j+1; k < n_ph_list2; k++)
break; break;
} }


if((stress_level == 1) && (first_vowel))
stress_level = 0; // ignore 'dimished' stress on first syllable

if(stress_level == 1) if(stress_level == 1)
reduce = 1; // stress = 'reduced' reduce = 1; // stress = 'reduced'


break; break;
} }


if(ph->type == phVOWEL)
first_vowel = 0;

if((plist2+1)->synthflags & SFLAG_LENGTHEN) if((plist2+1)->synthflags & SFLAG_LENGTHEN)
{ {
static char types_double[] = {phFRICATIVE,phVFRICATIVE,phNASAL,phLIQUID,0}; static char types_double[] = {phFRICATIVE,phVFRICATIVE,phNASAL,phLIQUID,0};


next2 = phoneme_tab[(plist2+2)->phcode]; next2 = phoneme_tab[(plist2+2)->phcode];


#ifdef deleted
if((ph->type != phVOWEL) && (ph->type != phPAUSE) //&& ((ph->phflags & phVOICED)==0)
&& (next->type == phLIQUID) && (next->mnemonic != ';') && (next2->type != phVOWEL))
{
// semi-vowel surrounded by consonants. precede by a short schwa
insert_ph = phonSCHWA_SHORT;
insert_synthflags = SFLAG_SYLLABLE;
}

if((ph->type == phLIQUID) && (prev->type != phVOWEL) && (next->type != phVOWEL))
{
// semi-vowel surrounded by consonants. precede by a short schwa
insert_ph = phonSCHWA_SHORT;
insert_synthflags = SFLAG_SYLLABLE;
}
#endif

if((insert_ph == 0) && (ph->link_out != 0) && (((plist2+1)->synthflags & SFLAG_EMBEDDED)==0)) if((insert_ph == 0) && (ph->link_out != 0) && (((plist2+1)->synthflags & SFLAG_EMBEDDED)==0))
{ {
if(ph->phflags & phAPPENDPH) if(ph->phflags & phAPPENDPH)

+ 1
- 1
src/synthesize.h View File

#define SFLAG_LENGTHEN 0x08 // lengthen symbol : included after this phoneme #define SFLAG_LENGTHEN 0x08 // lengthen symbol : included after this phoneme
#define SFLAG_DICTIONARY 0x10 // the pronunciation of this word was listed in the xx_list dictionary #define SFLAG_DICTIONARY 0x10 // the pronunciation of this word was listed in the xx_list dictionary
#define SFLAG_SWITCHED_LANG 0x20 // this word uses phonemes from a different language #define SFLAG_SWITCHED_LANG 0x20 // this word uses phonemes from a different language
#define SFLAG_PROMOTE_STRESS 0x40 // this unstressed word can be promoted to stressed


// embedded command numbers // embedded command numbers
#define EMBED_P 1 // pitch #define EMBED_P 1 // pitch

+ 1
- 1
src/translate.cpp View File

if(flags & FLAG_STRESS_END2) if(flags & FLAG_STRESS_END2)
{ {
// this's word's stress could be increased later // this's word's stress could be increased later
ph_list2[max_stress_ix].stress |= 0x80;
ph_list2[max_stress_ix].synthflags |= SFLAG_PROMOTE_STRESS;
} }


prev_dict_flags = flags; prev_dict_flags = flags;

+ 1
- 1
src/wavegen.cpp View File

z2 = (z2 * mix_wave_amp)/32; z2 = (z2 * mix_wave_amp)/32;
} }


z1 = z2 + (((total>>7) * amplitude2) >> 14);
z1 = z2 + (((total>>8) * amplitude2) >> 13);


echo = (echo_buf[echo_tail++] * echo_amp); echo = (echo_buf[echo_tail++] * echo_amp);
z1 += echo >> 8; z1 += echo >> 8;

Loading…
Cancel
Save