[1.44.02]

Fix: crash with very long numbers.
Very long nubers ( > 14 digits) now spoken as individual digits.
Fix: bracket was interfering with recognizing last-word in a clause.
Lang=el fix: all words were spoken as individual letters.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@252 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2010-08-14 09:07:11 +00:00
parent 4423576af2
commit eb7b132e9a
47 changed files with 1317 additions and 359 deletions
+6 -3
View File
@@ -1925,8 +1925,11 @@ static int LoadEnvelope(FILE *f, const char *fname)
displ = ftell(f_phdata);
fseek(f,12,SEEK_SET);
fread(buf,1,128,f);
fwrite(buf,1,128,f_phdata);
if(fread(buf,128,1,f) == 0)
{
error("Failed to read envelope: %s",fname);
}
fwrite(buf,128,1,f_phdata);
if(n_envelopes < N_ENVELOPES)
{
@@ -3576,7 +3579,7 @@ void CompileMbrola()
wxFileName filename = wxFileName(filepath);
strcpy(mbrola_voice,filename.GetName().mb_str(wxConvLocal));
sprintf(buf,"%s/mbrola_ph/%s_phtrans",path_home,mbrola_voice);
if((f_out = fopen(buf,"w")) == NULL)
if((f_out = fopen(buf,"wb")) == NULL)
{
wxLogError(_T("Can't write to: ")+wxString(buf,wxConvLocal));
return;
+3 -2
View File
@@ -273,7 +273,7 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
}
tr->data_dictlist = Alloc(size);
fread(tr->data_dictlist,size,1,f);
size = fread(tr->data_dictlist,1,size,f);
fclose(f);
@@ -516,7 +516,7 @@ unsigned short ipa1[96] = {
0x252,0x31,0x32,0x25c,0x34,0x35,0x36,0x37,0x275,0x39,0x2d0,0x2b2,0x3c,0x3d,0x3e,0x294,
0x259,0x251,0x3b2,0xe7,0xf0,0x25b,0x46,0x262,0x127,0x26a,0x25f,0x4b,0x4c,0x271,0x14b,0x254,
0x3a6,0x263,0x280,0x283,0x3b8,0x28a,0x28c,0x153,0x3c7,0xf8,0x292,0x32a,0x5c,0x5d,0x5e,0x5f,
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x261,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x303,0x7f
};
@@ -1639,6 +1639,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
*output++ = 0;
return;
} /* end of SetWordStress */
+1 -1
View File
@@ -566,7 +566,7 @@ void DisplayErrorFile(const char *fname)
if(msg != NULL)
{
f = fopen(fname,"r");
fread(msg,len,1,f);
len = fread(msg,1, len, f);
fclose(f);
msg[len] = 0;
msg_string = wxString(msg,wxConvUTF8);
+1 -1
View File
@@ -1883,7 +1883,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control)
{//=============================================================================================================
if(option_sayas == SAYAS_DIGITS1)
if((option_sayas == SAYAS_DIGITS1) || (wtab[0].flags & FLAG_INDIVIDUAL_DIGITS))
return(0); // speak digits individually
if(tr->langopts.numbers != 0)
+1 -2
View File
@@ -774,7 +774,7 @@ static int LoadSoundFile(const char *fname, int index)
fclose(f);
return(4);
}
fread(p,length,1,f);
length = fread(p,1,length,f);
fclose(f);
remove(fname_temp);
@@ -2032,7 +2032,6 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
int stressed_word = 0;
int end_clause_after_tag = 0;
int end_clause_index = 0;
const char *p;
wchar_t xml_buf[N_XML_BUF+1];
#define N_XML_BUF2 20
+2 -1
View File
@@ -388,7 +388,8 @@ espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int rela
parameter:
espeakRATE: speaking speed in word per minute.
espeakVOLUME: volume in range 0-100 0=silence
espeakVOLUME: volume in range 0-200 or more.
0=silence, 100=normal full volume, greater values may produce amplitude compression or distortion
espeakPITCH: base pitch, range 0-100. 50=normal
+2 -2
View File
@@ -147,7 +147,7 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
// read eSpeak's mbrola phoneme translation data, eg. en1_phtrans
sprintf(path,"%s/mbrola_ph/%s",path_home,phtrans);
size = GetFileLength(path);
if((f_in = fopen(path,"r")) == NULL) {
if((f_in = fopen(path,"rb")) == NULL) {
close_MBR();
return(EE_NOT_FOUND);
}
@@ -165,7 +165,7 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
{
*pw++ = Read4Bytes(f_in);
}
fread(mbrola_tab,size,1,f_in);
size = fread(mbrola_tab,1,size,f_in);
fclose(f_in);
setVolumeRatio_MBR((float)(mbrola_control & 0xff) /16.0f);
+2 -2
View File
@@ -35,8 +35,8 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.43.63 02.Aug.10";
const int version_phdata = 0x014361;
const char *version_string = "1.44.02 13.Aug.10";
const int version_phdata = 0x014400;
int option_device_number = -1;
FILE *f_logespeak = NULL;
+6 -1
View File
@@ -1236,10 +1236,15 @@ void DoEmbedded(int *embix, int sourceix)
int command;
do {
word = embedded_list[(*embix)++];
word = embedded_list[*embix];
value = word >> 8;
command = word & 0x7f;
if(command == 0)
return; // error
(*embix)++;
switch(command & 0x1f)
{
case EMBED_S: // speed
+10 -10
View File
@@ -122,7 +122,8 @@ static Translator* NewTranslator(void)
tr->data_dictrules = NULL; // language_1 translation rules file
tr->data_dictlist = NULL; // language_2 dictionary lookup file
tr->transpose_min = 0;
tr->transpose_min = 'a';
tr->transpose_max = 'z';
tr->frequent_pairs = NULL;
// only need lower case
@@ -167,6 +168,7 @@ static Translator* NewTranslator(void)
tr->langopts.replace_chars = NULL;
tr->langopts.ascii_language = ""; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
SetLengthMods(tr,201);
// tr->langopts.length_mods = length_mods_en;
// tr->langopts.length_mods0 = length_mods_en0;
@@ -178,6 +180,7 @@ static Translator* NewTranslator(void)
tr->langopts.thousands_sep = ',';
tr->langopts.decimal_sep = '.';
tr->langopts.break_numbers = BREAK_THOUSANDS; // 1000, 1000,000 1,000,000 etc
tr->langopts.max_digits = 14;
memcpy(tr->punct_to_tone, punctuation_to_tone, sizeof(tr->punct_to_tone));
@@ -278,14 +281,14 @@ static void SetCyrillicLetters(Translator *tr)
tr->letter_bits_offset = OFFSET_CYRILLIC;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBits(tr,0,ru_vowels);
SetLetterBits(tr,LETTERGP_A,ru_vowels);
SetLetterBits(tr,1,ru_soft);
SetLetterBits(tr,2,ru_consonants);
SetLetterBits(tr,3,ru_hard);
SetLetterBits(tr,4,ru_nothard);
SetLetterBits(tr,5,ru_voiced);
SetLetterBits(tr,6,ru_ivowels);
SetLetterBits(tr,7,ru_vowels);
SetLetterBits(tr,LETTERGP_VOWEL2,ru_vowels);
} // end of SetCyrillicLetters
@@ -419,10 +422,8 @@ Translator *SelectTranslator(const char *name)
static const short stress_lengths_da[8] = {160,140, 200,200, 0,0, 220,230};
SetupTranslator(tr,stress_lengths_da,NULL);
tr->transpose_min = 'a';
tr->transpose_max = 'z';
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.param[LOPT_PREFIXES] = 1;
SetLetterVowel(tr,'y');
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
}
@@ -451,9 +452,6 @@ Translator *SelectTranslator(const char *name)
static const short stress_lengths_en[8] = {182,140, 220,220, 0,0, 248,275};
SetupTranslator(tr,stress_lengths_en,NULL);
tr->transpose_min = 'a';
tr->transpose_max = 'z';
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x08;
tr->langopts.numbers = NUM_HUNDRED_AND | NUM_ROMAN | NUM_1900;
@@ -485,6 +483,7 @@ Translator *SelectTranslator(const char *name)
tr->letter_bits_offset = OFFSET_GREEK;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBits(tr,LETTERGP_A,el_vowels);
SetLetterBits(tr,LETTERGP_VOWEL2,el_vowels);
SetLetterBits(tr,LETTERGP_B,el_voiceless);
SetLetterBits(tr,LETTERGP_C,el_consonants);
SetLetterBits(tr,LETTERGP_Y,el_fvowels); // front vowels: ε η ι υ
@@ -733,6 +732,7 @@ SetLengthMods(tr,3); // all equal
tr->letter_bits_offset = OFFSET_ARMENIAN;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBits(tr,LETTERGP_A,hy_vowels);
SetLetterBits(tr,LETTERGP_VOWEL2,hy_vowels);
SetLetterBits(tr,LETTERGP_C,hy_consonants);
tr->langopts.max_initial_consonants = 6;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
@@ -902,7 +902,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.param[LOPT_PREFIXES] = 1;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x10; // devoice at end of word
SetLetterVowel(tr,'y');
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
tr->langopts.ordinal_indicator = "e";
memcpy(tr->stress_lengths,stress_lengths_nl,sizeof(tr->stress_lengths));
+28 -10
View File
@@ -766,12 +766,14 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
int word_length;
int ix;
char *p;
int pfix;
int n_chars;
unsigned int dictionary_flags[2];
unsigned int dictionary_flags2[2];
int end_type=0;
int prefix_type=0;
int prefix_stress;
char *wordx;
char phonemes[N_WORD_PHONEMES];
char *ph_limit;
@@ -1007,7 +1009,6 @@ if((wmark > 0) && (wmark < 8))
while(((length < 3) && (length > 0))|| (word_length > 1 && Unpronouncable(tr,wordx)))
{
char *p;
// This word looks "unpronouncable", so speak letters individually until we
// find a remainder that we can pronounce.
emphasize_allcaps = 0;
@@ -1311,9 +1312,15 @@ if(dictionary_flags2[0] & FLAG_ABBREV)
/* determine stress pattern for this word */
/******************************************/
/* NOTE: this also adds a single PAUSE if the previous word ended
in a primary stress, and this one starts with one */
if(prefix_flags || (strchr(prefix_phonemes,phonSTRESS_P)!=NULL))
prefix_stress = 0;
for(p = prefix_phonemes; *p != 0; p++)
{
if((*p == phonSTRESS_P) || (*p == phonSTRESS_P2))
{
prefix_stress = *p;
}
}
if(prefix_flags || (prefix_stress != 0))
{
if((tr->langopts.param[LOPT_PREFIXES]) || (prefix_type & SUFX_T))
{
@@ -2303,6 +2310,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
char *p;
int j, k;
int n_digits;
int individual_digits;
int charix_top=0;
short charix[N_TR_SOURCE+4];
@@ -2338,7 +2346,9 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
for(p=source; *p != 0; p++)
fputc(*p, f_logespeak);
fprintf(f_logespeak,"ENDCLAUSE\n");
fflush(f_logespeak);
}
p = source;
charix[charix_top+1] = 0;
charix[charix_top+2] = 0x7fff;
@@ -2947,7 +2957,11 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
words[word_count].pre_pause = 8;
if(word_count > 0)
{
words[word_count-1].flags |= FLAG_LAST_WORD;
ix = word_count-1;
while((ix > 0) && (IsBracket(sbuf[words[ix].start])))
ix--; // the last word is a bracket, mark the previous word as last
words[ix].flags |= FLAG_LAST_WORD;
// FLAG_NOSPACE check to avoid recognizing .mr -mr
if((terminator & CLAUSE_DOT) && !(words[word_count-1].flags & FLAG_NOSPACE))
words[word_count-1].flags |= FLAG_HAS_DOT;
@@ -2962,8 +2976,8 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
char *pn;
char *pw;
int nw;
char number_buf[60];
WORD_TAB num_wtab[15]; // copy of 'words', when splitting numbers into parts
char number_buf[150];
WORD_TAB num_wtab[50]; // copy of 'words', when splitting numbers into parts
// start speaking at a specified word position in the text?
count_words++;
@@ -2984,7 +2998,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
{
// Languages with 100000 numbers. Remove thousands separators so that we can insert them again later
pn = number_buf;
while(pn < &number_buf[sizeof(number_buf)-3])
while(pn < &number_buf[sizeof(number_buf)-20])
{
if(iswdigit(*pw))
{
@@ -3010,15 +3024,19 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
for(n_digits=0; iswdigit(word[n_digits]); n_digits++); // count consecutive digits
if((n_digits > 4) && (word[0] != '0'))
if(n_digits > 4)
{
// word is entirely digits, insert commas and break into 3 digit "words"
number_buf[0] = ' ';
pn = &number_buf[1];
nx = n_digits;
nw = 0;
individual_digits = 0;
while(pn < &number_buf[sizeof(number_buf)-3])
if((n_digits > tr->langopts.max_digits) || (word[0] == '0'))
words[ix].flags |= FLAG_INDIVIDUAL_DIGITS;
while(pn < &number_buf[sizeof(number_buf)-20])
{
if(!isdigit(c = *pw++) && (c != tr->langopts.decimal_sep))
break;
+14 -12
View File
@@ -108,6 +108,7 @@
#define FLAG_HAS_DOT 0x10000 // dot after this word
#define FLAG_COMMA_AFTER 0x20000 // comma after this word
#define FLAG_MULTIPLE_SPACES 0x40000 // word is preceded by multiple spaces, newline, or tab
#define FLAG_INDIVIDUAL_DIGITS 0x80000 // speak number as individual digits
#define FLAG_SUFFIX_VOWEL 0x08000000 // remember an initial vowel from the suffix
#define FLAG_NO_TRACE 0x10000000 // passed to TranslateRules() to suppress dictionary lookup printout
@@ -194,18 +195,18 @@
#define PUNCT_SAY_NAME 0x200000
#define CLAUSE_DOT 0x400000
#define CLAUSE_NONE 0 + 0x04000
#define CLAUSE_PARAGRAPH 70 + 0x80000
#define CLAUSE_EOF 40 + 0x90000
#define CLAUSE_VOICE 0 + 0x24000
#define CLAUSE_PERIOD 40 + 0x80000
#define CLAUSE_COMMA 20 + 0x41000
#define CLAUSE_SHORTCOMMA 4 + 0x41000
#define CLAUSE_SHORTFALL 4 + 0x40000
#define CLAUSE_QUESTION 40 + 0x82000
#define CLAUSE_EXCLAMATION 45 + 0x83000
#define CLAUSE_COLON 30 + 0x40000
#define CLAUSE_SEMICOLON 30 + 0x41000
#define CLAUSE_NONE ( 0 + 0x04000)
#define CLAUSE_PARAGRAPH (70 + 0x80000)
#define CLAUSE_EOF (40 + 0x90000)
#define CLAUSE_VOICE ( 0 + 0x24000)
#define CLAUSE_PERIOD (40 + 0x80000)
#define CLAUSE_COMMA (20 + 0x41000)
#define CLAUSE_SHORTCOMMA ( 4 + 0x41000)
#define CLAUSE_SHORTFALL ( 4 + 0x40000)
#define CLAUSE_QUESTION (40 + 0x82000)
#define CLAUSE_EXCLAMATION (45 + 0x83000)
#define CLAUSE_COLON (30 + 0x40000)
#define CLAUSE_SEMICOLON (30 + 0x41000)
#define SAYAS_CHARS 0x12
#define SAYAS_GLYPHS 0x13
@@ -439,6 +440,7 @@ typedef struct {
int min_roman;
int thousands_sep;
int decimal_sep;
int max_digits; // max number of digits which can be spoken as an integer number (rather than individual digits)
const char *ordinal_indicator; // UTF-8 string
// bit 0, accent name before the letter name, bit 1 "capital" after letter name
+1 -1
View File
@@ -611,7 +611,7 @@ void MakeVowelLists(void)
prog_log_table = (PHONEME_PROG_LOG *)malloc(ix);
if(prog_log_table == NULL)
return;
fread(prog_log_table, 1, ix, f_prog_log);
ix = fread(prog_log_table, 1, ix, f_prog_log);
fclose(f_prog_log);
prog_log_end = prog_log_table + ix;
n_prog_log = ix / sizeof(PHONEME_PROG_LOG);