From e87bb29b273e7392dccef7575f402e8829c829b0 Mon Sep 17 00:00:00 2001 From: jonsd Date: Tue, 13 Nov 2007 02:28:05 +0000 Subject: [PATCH] [1.29.20] Fix for crash in Chinese text. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@104 d46cf337-b52f-0410-862d-fd96e6ae7743 --- espeak-data/voices/bs | 2 +- espeak-data/voices/hr | 1 + espeak-data/voices/sr | 1 + phsource/compile_report | 2 +- phsource/ph_croatian | 2 +- phsource/vowel/@_hgh | Bin 5207 -> 5205 bytes src/numbers.cpp | 5 +++-- src/synth_mbrola.cpp | 3 ++- src/synthdata.cpp | 2 +- src/translate.cpp | 16 ++++++++++++---- src/wavegen.cpp | 10 ++++------ 11 files changed, 27 insertions(+), 17 deletions(-) diff --git a/espeak-data/voices/bs b/espeak-data/voices/bs index 4307c138..eadd7073 100755 --- a/espeak-data/voices/bs +++ b/espeak-data/voices/bs @@ -13,4 +13,4 @@ formant 4 97 102 100 formant 5 97 102 100 stressAdd 10 10 0 0 0 0 -30 -30 -dictrules 2 +dictrules 3 4 diff --git a/espeak-data/voices/hr b/espeak-data/voices/hr index f6ff1c5e..d6811d3a 100755 --- a/espeak-data/voices/hr +++ b/espeak-data/voices/hr @@ -15,3 +15,4 @@ formant 4 97 102 100 formant 5 97 102 100 stressAdd 10 10 0 0 0 0 -30 -30 +dictrules 1 diff --git a/espeak-data/voices/sr b/espeak-data/voices/sr index 6041a0cd..a7a8223d 100644 --- a/espeak-data/voices/sr +++ b/espeak-data/voices/sr @@ -12,3 +12,4 @@ formant 4 97 102 100 formant 5 97 102 100 stressAdd 10 10 0 0 0 0 -30 -30 +dictrules 2 4 diff --git a/phsource/compile_report b/phsource/compile_report index 5c753326..619c1b93 100644 --- a/phsource/compile_report +++ b/phsource/compile_report @@ -1074,7 +1074,6 @@ vowel/@ [@] base [@] en_rp [V] cy [@4] hi - [@] hr vowel/@- [@-] base [r*] hr vowel/& [a] en_rp @@ -1282,6 +1281,7 @@ vowel/@_fnt [@2] hr vowel/@_hgh [@] en_us [@2] en_us [@5] en_us + [@] hr [@] no vowel/i [i] base2 [i:] en_n diff --git a/phsource/ph_croatian b/phsource/ph_croatian index 9705d0e6..0e3af663 100644 --- a/phsource/ph_croatian +++ b/phsource/ph_croatian @@ -1,6 +1,6 @@ phoneme @ // Schwa vowel starttype (@) endtype (@) - formants vowel/@ + formants vowel/@_hgh length 140 endphoneme diff --git a/phsource/vowel/@_hgh b/phsource/vowel/@_hgh index dd4ad1bb2a23936ab6da329b89848f8bcf4595a5..6da23c8ff3008d45f1e733e4591f48e9ddc47e6b 100644 GIT binary patch delta 315 zcmcbvaaBVwIKb68B-k~Om4Si5AwDBLW20~=i=L1K(*wpWtO*QTSUtr!f$Wc*XBetD zC-6RCe83pNca-G>PXZr^&BAZRuzB+|mV3+)JsVkL;Ch~M8ZyH4)bkyH>yhWT1L|4C z0n@XAH3F{Z7H2M8&qcn;tT1~V`Q3qf*72NYt}h0dCvSw%vX6JY@jxVUOognK^noXkVCLFlp$<48&O+f`!Gia=R#*s Ur(Ani>qhg{<~^JL2t+dj09uw;K>z>% delta 317 zcmcbraa}_=IKb68B-k~Ooq>VDAwD@Lzc_WHU?_{8umsZs#x1M~3|m+yiE#qiA34u3 zgmWtJK45&n7{PaxJG gY(#B^?ZX@yoC}>jopSA6tsBi(oA+$~B@oRF0Aq?))c^nh diff --git a/src/numbers.cpp b/src/numbers.cpp index 9c9ade9e..1dfee97b 100644 --- a/src/numbers.cpp +++ b/src/numbers.cpp @@ -203,6 +203,7 @@ int Translator::TranslateRoman(char *word, char *ph_out) {//===================================================== int c; char *p; + const char *p2; int acc; int prev; int value; @@ -219,10 +220,10 @@ int Translator::TranslateRoman(char *word, char *ph_out) while((c = *word++) != ' ') { - if((p = strchr(roman_numbers,c)) == NULL) + if((p2 = strchr(roman_numbers,c)) == NULL) return(0); - value = roman_values[p - roman_numbers]; + value = roman_values[p2 - roman_numbers]; if((prev==5) || (prev==50) || (prev==500)) { diff --git a/src/synth_mbrola.cpp b/src/synth_mbrola.cpp index c8fd80cb..da8dccc9 100755 --- a/src/synth_mbrola.cpp +++ b/src/synth_mbrola.cpp @@ -521,6 +521,7 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola) #else // fprintf(f_mbrola,";; v=%.2f\n",(float)(mbrola_control & 0xff)/16.0); // ;; v= has no effect on mbrola #endif + for(phix=1; phix < n_phonemes; phix++) { mbr_buf[0] = 0; @@ -674,7 +675,7 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola) #ifdef USE_MBROLA_LIB MbrolaSynth(NULL); #endif -} // end of SynthMbrola +} // end of MbrolaTranslate #ifdef TEST_MBROLA diff --git a/src/synthdata.cpp b/src/synthdata.cpp index 090928fe..5b079730 100755 --- a/src/synthdata.cpp +++ b/src/synthdata.cpp @@ -35,7 +35,7 @@ #include "translate.h" #include "wave.h" -const char *version_string = "1.29.18 10.Nov.07"; +const char *version_string = "1.29.20 13.Nov.07"; const int version_phdata = 0x012901; int option_device_number = -1; diff --git a/src/translate.cpp b/src/translate.cpp index 24e35fd9..6b1af7c4 100755 --- a/src/translate.cpp +++ b/src/translate.cpp @@ -371,6 +371,13 @@ int IsAlpha(unsigned int c) return(0); } +int IsDigit09(unsigned int c) +{//========================= + if((c >= 0) && (c <= 9)) + return(1); + return(0); +} + int IsDigit(unsigned int c) {//======================== if(iswdigit(c)) @@ -1770,7 +1777,7 @@ void *Translator::TranslateClause(FILE *f_text, const void *vp_input, int *tone_ prev_out2 = prev_out; utf8_in(&prev_out,&sbuf[ix-1],1); // prev_out = sbuf[ix-1]; - if(langopts.tone_numbers && isdigit(prev_out) && IsAlpha(prev_out2)) + if(langopts.tone_numbers && IsDigit09(prev_out) && IsAlpha(prev_out2)) { // tone numbers can be part of a word, consider them as alphabetic prev_out = 'a'; @@ -1864,7 +1871,7 @@ void *Translator::TranslateClause(FILE *f_text, const void *vp_input, int *tone_ // speak as words #ifdef deleted -if((c == '/') && (langopts.testing & 2) && isdigit(next_in) && IsAlpha(prev_out)) +if((c == '/') && (langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(prev_out)) { // TESTING, explicit indication of stressed syllable by /2 after the word word_mark = next_in-'0'; @@ -1892,7 +1899,7 @@ if((c == '/') && (langopts.testing & 2) && isdigit(next_in) && IsAlpha(prev_out) { if(IsAlpha(prev_out)) { - if(langopts.tone_numbers && isdigit(c) && !isdigit(next_in)) + if(langopts.tone_numbers && IsDigit09(c) && !IsDigit09(next_in)) { // allow a tone number as part of the word } @@ -2091,7 +2098,7 @@ if((c == '/') && (langopts.testing & 2) && isdigit(next_in) && IsAlpha(prev_out) else if(iswdigit(c)) { - if(langopts.tone_numbers && IsAlpha(prev_out) && !isdigit(next_in)) + if(langopts.tone_numbers && IsAlpha(prev_out) && !IsDigit(next_in)) { } else @@ -2211,6 +2218,7 @@ if((c == '/') && (langopts.testing & 2) && isdigit(next_in) && IsAlpha(prev_out) continue; + // digits should have been converted to Latin alphabet ('0' to '9') word = pw = &sbuf[words[ix].start]; for(n_digits=0; iswdigit(word[n_digits]); n_digits++); // count consecutive digits if((n_digits > 4) && (word[0] != '0')) diff --git a/src/wavegen.cpp b/src/wavegen.cpp index 3c7a6ac8..d8df444e 100755 --- a/src/wavegen.cpp +++ b/src/wavegen.cpp @@ -1762,11 +1762,12 @@ void Write4Bytes(FILE *f, int value) int OpenWaveFile(const char *path, int rate) /******************************************/ { + // Set the length of 0x7fffffff for --stdout + // This will be changed to the correct length for -w (write to file) static unsigned char wave_hdr[44] = { 'R','I','F','F',0,0,0,0,'W','A','V','E','f','m','t',' ', 0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0, - 2,0,0x10,0,'d','a','t','a', 0,0,0,0 }; - + 2,0,0x10,0,'d','a','t','a', 0xff,0xff,0xff,0x7f}; if(path == NULL) return(2); @@ -1783,7 +1784,7 @@ int OpenWaveFile(const char *path, int rate) fwrite(wave_hdr,1,24,f_wave); Write4Bytes(f_wave,rate); Write4Bytes(f_wave,rate * 2); - fwrite(&wave_hdr[32],1,8,f_wave); + fwrite(&wave_hdr[32],1,12,f_wave); return(0); } return(1); @@ -1862,8 +1863,6 @@ int WavegenFill(int fill_zeros) { if(WcmdqUsed() <= 0) { -#define echo2 -#ifdef echo2 if(echo_complete > 0) { // continue to play silence until echo is completed @@ -1871,7 +1870,6 @@ int WavegenFill(int fill_zeros) if(resume == 1) return(0); // not yet finished } -#endif if(fill_zeros) {