From cd17260b31760fd20873f5d03f4c1228b9ff69b9 Mon Sep 17 00:00:00 2001 From: jonsd Date: Thu, 9 Aug 2012 16:29:10 +0000 Subject: [PATCH] [1.46.22] lang=bs,hr,sr: fix for million numbers lang=fa, treat ZLNJ character as hyphen Dictionary changes to lang=pt git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@287 d46cf337-b52f-0410-862d-fd96e6ae7743 --- dictsource/dict_phonemes | 4 +- dictsource/hbs_list | 5 + dictsource/pt_list | 56 +++- dictsource/pt_rules | 16 ++ phsource/compile_report | 54 ++-- platforms/riscos/cpp/speak_riscos | 239 +++++++++++++++--- platforms/riscos/s/cmhgfile | 2 +- platforms/windows/espeakedit/src/speech.h | 1 + .../windows/espeakedit/src_copy/speech.h | 1 + platforms/windows/windows_cmd/src/speech.h | 2 + platforms/windows/windows_dll/src/speech.h | 2 + platforms/windows/windows_sapi/src/speech.h | 2 + src/numbers.cpp | 59 +++-- src/readclause.cpp | 2 +- src/setlengths.cpp | 143 +++++++++++ src/sonic.cpp | 5 + src/speech.h | 1 + src/synthdata.cpp | 4 +- src/synthesize.cpp | 2 + src/tr_languages.cpp | 18 +- src/translate.cpp | 4 +- src/translate.h | 9 +- src/wavegen.cpp | 26 +- 23 files changed, 542 insertions(+), 115 deletions(-) diff --git a/dictsource/dict_phonemes b/dictsource/dict_phonemes index bd66c3c4..57893b2e 100644 --- a/dictsource/dict_phonemes +++ b/dictsource/dict_phonemes @@ -175,7 +175,7 @@ l m n N p R s t T v x z -Dictionary hbs_dict 2008-12-17 +Dictionary hbs_dict 2012-08-08 & @ @2 a A a: aI aU e E e: i I i: l- o @@ -375,7 +375,7 @@ S s; S; t t; tS ts tS; ts; v w x z Z Z; -Dictionary pt_dict 2012-07-25 +Dictionary pt_dict 2012-08-08 & &/ &U~ &~ @ @- a A aI aU e E eI EI eU EU diff --git a/dictsource/hbs_list b/dictsource/hbs_list index b95c9faa..98336074 100644 --- a/dictsource/hbs_list +++ b/dictsource/hbs_list @@ -216,6 +216,7 @@ _tld t'ild& ?2 _3C tR'ist'a_ ?2 _4C tSetR'ist'o_ _6C S'Est'o + _0M1 t'isUtS;& _0MA1 t'isUtS;e _1M1 t'isUtS;U @@ -226,22 +227,26 @@ _tld t'ild& ?3 _0M1 h'il^ad& ?3 _0MA1 h'il^ade ?3 _1M1 h'il^adU + _0M2 m'ilijUna _0MA2 m'ilijUna _1M2 m'ilijUn ?4 _0M2 m'ilijOna ?4 _0MA2 m'ilijOna ?4 _1M2 m'ilijOn + _0M3 m'iliaRdI _0MA3 m'iliaRde _1M3 m'iliaRdU ?2 _0M3 milijArdI ?2 _0MA3 milijArde ?2 _1M3 milijArdU + _0M4 b'ilijUna _1M4 b'ilijUn ?4 _0M4 b'ilijOna ?4 _1M4 b'ilijOn + _dpt _:z'a*Ez_ _roman r*'imsko diff --git a/dictsource/pt_list b/dictsource/pt_list index ebe91cda..a2e2e284 100755 --- a/dictsource/pt_list +++ b/dictsource/pt_list @@ -646,46 +646,79 @@ governo gov'ernU $noun acerto $alt2 $noun adore $alt +albatrozes $alt alferes $alt +algozes $alt +atrozes $alt ameba $alt +belo $alt +besta $alt2 boca $alt2 +bolo $alt2 borboleta $alt2 +bordo $alt +cabeça $alt2 +casebre $alt catorze $alt2 cerca $alt $verb cerco $alt $verb chamego $alt2 +chefe $alt +chinelo $alt +coco $alt2 +começo $alt2 $noun comeres $alt2 conheço $alt2 copa $alt copo $alt +cornos $alt corpos $alt +corto $alt corvos $alt +coto $alt2 couber $alt couberem $alt couberdes $alt couberes $alt der $alt +descova $alt2 +desfecho $alt2 dez $alt doce $alt2 -descova $alt2 +droga $alt enumerem $alt erro $alt2 $noun +esforços $alt +esperma $alt +estrofe $alt estiverdes $alt estiveres $alt farofa $alt fere $alt ferem $alt +fezes $alt fizer $alt fizerem $alt fizerdes $alt fizeres $alt fogos $alt +fores $alt2 fosse $alt2 fossem $alt2 +foste $alt2 +frevo $alt2 +gelo $alt $verb germe $alt +grego $alt2 +groselha $alt grosso $alt2 +grozo $alt $verb hoje $alt2 +joga $alt +jogam $alt jogos $alt +jogue $alt +joguem $alt líderes $alt2 lopes $alt mantiverdes $alt @@ -693,8 +726,12 @@ mantiveres $alt mexa m'eS& mexi meS'i mexo m'eSU +miolo $alt2 modo $alt modos $alt +molho $alt $verb +morcego $alt2 +morda $alt2 mortos $alt ?2 mulher mulj'Er ?4 mulher mul^'Er @@ -702,17 +739,25 @@ mui mwi muito mw'iNtU // -s is included as a suffix muita mw'iNt& mulheres $alt +negro $alt2 novos $alt onu $1 +opereta $alt2 +osso $alt2 ovos $alt paexa paeSa pedra $alt +pelego $alt2 perdem $alt +perede $alt2 pesa $alt pesam $alt +pesque $alt +pesquem $alt peso $alt peso $alt2 $noun portos $alt +pose $alt2 povos $alt preto $alt2 profere $alt @@ -726,13 +771,15 @@ rogas $alt selvagem seUv'aZeIN soco $alt2 sofrem $alt -sofres $alt +sofre $alt +sofreste $alt2 sopre $alt soprem $alt souber $alt souberdes $alt souberes $alt souberem $alt +sugere $alt sugerem $alt suor swOr tapete $alt2 @@ -740,12 +787,17 @@ teta $alt2 tiver $alt tiveres $alt torres $alt2 +tortos $alt +travesso $alt2 +trevo $alt2 +troco $alt2 $noun tropeço $alt2 $noun vanessa $alt2 verbo $alt verme $alt vierem $alt violeta $alt2 +vozes $alt // Close [o] ?1 calculadora $alt2 diff --git a/dictsource/pt_rules b/dictsource/pt_rules index 3210af65..0fe9760c 100755 --- a/dictsource/pt_rules +++ b/dictsource/pt_rules @@ -14,6 +14,10 @@ // G a voiced consonant // K not a vowel +// endings +.L01 a am o +.L02 a am e em o + .group a _) a (_ a _) a (_W 'a // in an acronym @@ -330,6 +334,16 @@ ?1 v) e (l_ ,E // eg: possível, amovível, disponível, etc... ?1 l) e (ta 'E // eg: bicicleta, atleta. + _com) e (tL01_ e + _prom) e (tL01_ e + _esqu) e (çL01_ e + _derr) e (tL01_ e + _atr) e (vL01_ e + _f) e (rvL01_ e + _per) e (çL01_ e + _pad) e (çL01_ e + _dec) e (pL02_ E + _p) e (scL01_ E .group é é ''E @@ -614,6 +628,8 @@ ?1 f) o (rmulá u // eg: formulário, formulários. ?1 v) o (lt O + _m) o (lhL02_ O + .group ô ô ''o diff --git a/phsource/compile_report b/phsource/compile_report index e6a09d57..386e42f8 100644 --- a/phsource/compile_report +++ b/phsource/compile_report @@ -80,7 +80,7 @@ consonants 10 116 bo 10 152 kk 20 117 fa 9 110 - ga 25 125 + ga 21 125 Data file Used by b/b [b] base @@ -118,7 +118,6 @@ d/d [d] base [d] hr [d] sq [d] mt - [d[] ga d/d_ [d] base [d[] base [d] base2 @@ -136,7 +135,6 @@ d/d_ [d] base [d] hr [d] sq [d] mt - [d[] ga d/d_dnt [d] sr d/dr [*] base [d[] base @@ -156,7 +154,6 @@ d/dr [*] base [d] hr [d] sq [d] mt - [d[] ga d/tap [*;] ro d/tap1 [*] base d/tap2 [t#] en @@ -182,7 +179,6 @@ d/xd [d] base [d] mt [dz] bo [dzh] bo - [d[] ga d/xd3 [dh] hi d/xd_pzd [d^] et [d;] lt @@ -418,7 +414,7 @@ l/l_ [l] base [l/] fr l/l_@ [l/3] base [l/] fr -l/l@ [höx] base +l/l@ [hF{] base [l#] base [l] fr [l/2] fr @@ -452,7 +448,7 @@ l/L2_oL [l/2] base l/L2_uL [l/2] base l/l_3 [l/] de l/l_4 [ll] sq -l/la [höx] base +l/la [hF{] base [l#] base [l] fr [l/2] fr @@ -460,7 +456,7 @@ l/la [h [K] tn l/l_a [l/3] base [l/] fr -l/le [höx] base +l/le [hF{] base [l#] base [l] fr [l/2] fr @@ -472,7 +468,7 @@ l/L_eL_af [&] af [&:] af l/l_front [L] sq l/l_front_ [l/4] sq -l/li [höx] base +l/li [hF{] base [l#] base [l] fr [l/2] fr @@ -486,7 +482,7 @@ ll/ll [L] bg ll/_ll [L] bg l/l_long [l] base [l] fr -l/lo [höx] base +l/lo [hF{] base [l#] base [l/2] fr [K] nso @@ -497,7 +493,7 @@ l^/l_rfx [l.] base [l;] lt [l] ru [l^] ru -l/lu [höx] base +l/lu [hF{] base [l#] base [l] fr [l/2] fr @@ -813,14 +809,12 @@ ufric/tlh [K] nso [K] tn ufric/x [x] base [kh] vi - [x] ga ufric/x2 [x2] af [x] ku [X] kk ufric/x_hr [x] base [x] hr [x] ru - [x] ga ufric/x_sr [h#] sr [x#] sr ufric/xx [X] base @@ -951,14 +945,12 @@ ustop/t_dnt [t] base [t] lt [t] pl [t] hr - [t[] ga ustop/t_dnt2 [t] base2 [d] kn ustop/t_hi [t[] base [t] et [t^] et [t`] am - [t[] ga ustop/t_pzd [c] base [t^] et [t;] lt @@ -1046,6 +1038,7 @@ vdiph2/eo [eo] ro vdiph2/e_u [e[u] ro vdiph2/i@ [i@] en-n [i@] hy + [i@] ga vdiph2/i@_2 [i@] en-wm vdiph2/ie [i@] en-wi [ie] fi @@ -1077,6 +1070,7 @@ vdiph2/oa [Oa] ro vdiph2/o_oo [o@] en-wi [O:] is [o] zh +vdiph2/u@ [u@] ga vdiph2/u#@ [U@] en-sc vdiph2/uaa [uo] lt [uo] lv @@ -1231,6 +1225,7 @@ vdiph/eu_2 [eu] fi vdiph/@i [Yi] et [@I] vi [@:I] vi + [@I] ga vdiph/&i [&i] fi [&i] et [aI] hi @@ -1290,6 +1285,7 @@ vdiph/@u [u:] en-wm [@:U] vi vdiph/@u_2 [oU] en-rp vdiph/@u_3 [@U] ro + [@U] ga vdiph/@u_en [oU] en [@U] id vdiph/ui [uI] base2 @@ -1450,6 +1446,11 @@ vowel/@ [@] base [@] wo [@:] wo [@] te + [@] ga + [E#] ga + [I#] ga + [O#] ga + [U#] ga vowel/@- [@-] base [r*] hr vowel/& [a] en-rp @@ -1610,6 +1611,7 @@ vowel/a#_3 [a#] en [a] sq [a/] sq [3] da + [a#] ga vowel/a_4 [a] es [a] el [a] vi @@ -1653,10 +1655,6 @@ vowel/aa_2 [A:] en [A] zh [A@] tn [A:] ga - [A0:] ga - [A1:] ga - [A9:] ga - [0A:] ga vowel/aa_3 [A:] af [A] sq [A] prs @@ -1673,7 +1671,6 @@ vowel/aa_8 [0] en-us [A1] et [A] nl [a:] is - [0] ga vowel/aa_9 [a] fi [a] et [a:] hi @@ -1782,7 +1779,6 @@ vowel/ee_5 [E] en [E] wo [E:] wo [E] tn - [E] ga vowel/ee_6 [&] sk [E3] sv [E] ku @@ -1820,6 +1816,7 @@ vowel/e_mid [E] en-rp [E] prs [E] ht [e] si + [E] ga vowel/e_mid2 [E] af [E] de [E2] de @@ -2001,7 +1998,6 @@ vowel/ii_6 [I] en-wm [i] wo vowel/ii_7 [i] en [i] sq - [i] ga vowel/ii_8 [i] kk vowel/ii_final [i] en-us [i] en-rp @@ -2058,8 +2054,6 @@ vowel/o [o] base2 [o] te [o:] te [o] bo - [o2] ga - [o3] ga [o:] ga vowel/o_2 [o:] cy [o:] hi @@ -2118,7 +2112,6 @@ vowel/oo [o] base [o] prs [O] wo [O:] wo - [O] ga vowel/oo_1 [O:] en-n [O:] en-rp [O@] en-rp @@ -2157,6 +2150,7 @@ vowel/oo_4 [O] base2 [O:] hi [O] it [O] pa + [O] ga vowel/oo_5 [O] pl [O] is [O] sq @@ -2200,8 +2194,6 @@ vowel/u [u] base [u] ak [u:] wo [u] bo - [u1] ga - [u:] ga vowel/u# [u:] en-sc [Y] tr vowel/u_2 [u1] fi @@ -2273,6 +2265,7 @@ vowel/u_bck [u] base2 [u] ne [u] pa [u] mt + [u:] ga vowel/u_bck2 [u] et [u] fr [u:] fr @@ -2280,13 +2273,13 @@ vowel/u_bck2 [u] et [u] es [u] ht [u] fa - [U] ga vowel/u_bck3 [u:] et [u] kk vowel/uu [U] en [U] en-n [U] en-wm [U] tn + [U] ga vowel/uu# [U] ku vowel/uu_2 [U] base2 [U] de @@ -2325,7 +2318,6 @@ vowel/V_3 [V] en-rp [V] pa vowel/V_4 [V] en-sc [V] da - [V] ga vowel/V_6 [V] en-us [a#] lv vowel/y [y] base2 @@ -2381,11 +2373,9 @@ vowel/yy_4 [y] de [yI] is [y] hy vwl_af/@ [@] af - [@] ga vwl_af/I [I] af vwl_af/r@ [@] af [I] af - [@] ga vwl_de/uu_@ [UR] de vwl_en/aI@ [aI@] en [aI@] en-n @@ -2598,7 +2588,6 @@ x/d_ [d] base [d] is [d] sq [d] mt - [d[] ga x/d_dnt [d[] base [d] base2 [d] fi @@ -2608,7 +2597,6 @@ x/d_dnt [d[] base [d] lt [d] pl [d] mt - [d[] ga x/d_pzd [d^] et [d;] lt [d;] pl diff --git a/platforms/riscos/cpp/speak_riscos b/platforms/riscos/cpp/speak_riscos index 80a432f9..5c22b550 100644 --- a/platforms/riscos/cpp/speak_riscos +++ b/platforms/riscos/cpp/speak_riscos @@ -57,12 +57,14 @@ extern void RiscosOpenSound(); extern int WcmdqUsed(); extern void FreePhData(); extern void FreeDictionary(); +extern void Write4Bytes(FILE *f, int value); extern int wcmdq_head; extern int wcmdq_tail; extern int current_source_index; FILE *f_text; +FILE *f_wave = NULL; int (* uri_callback)(int, const char *, const char *) = NULL; int (* phoneme_callback)(const char *) = NULL; @@ -74,6 +76,7 @@ char textbuffile[L_tmpnam]; int sample_rate_index; // current value int current_voice_num=0; int n_voice_files = 0; +int n_voice_variant_files = 0; // output sound buffer, 2 bytes per sample static unsigned short SoundBuf[4096]; @@ -82,7 +85,9 @@ static int callback_inhibit = 0; static int more_text=0; #define N_VOICE_NAMES 60 -static char *voice_names[40]; +#define N_VOICE_VARIANT_NAMES 30 +static char *voice_names[N_VOICE_NAMES]; +static char *voice_variant_names[N_VOICE_VARIANT_NAMES]; #define N_STATIC_BUF 8000 static char static_buf[N_STATIC_BUF]; @@ -108,7 +113,7 @@ static const char *help_text = "-p \n" "\t Pitch adjustment, 0 to 99, default is 50\n" "-s \n" -"\t Speed in words per minute 80 to 370, default is 170\n" +"\t Speed in words per minute 80 to 390, default is 170\n" "-v \n" "\t Use voice file of this name from espeak-data/voices\n" "-w \n" @@ -125,9 +130,9 @@ static const char *help_text = "--punct=\"\"\n" "\t Speak the names of punctuation characters during speaking. If\n" "\t = is omitted, all punctuation is spoken.\n" -//"--voices=\n" -//"\t List the available voices for the specified language.\n" -//"\t If is omitted, then list all voices.\n" +"--voices=\n" +"\t List the available voices for the specified language.\n" +"\t If is omitted, then list all voices.\n" "-k \n" "\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n" "\t higher values = a pitch increase (try -k20).\n"; @@ -163,10 +168,14 @@ int GetFileLength(const char *filename) } /* end of GetFileLength */ +void MarkerEvent(int type, unsigned int char_position, int value, int value2, unsigned char *out_ptr) +{ +} void ReadVoiceNames2(char *directory) {//================================== int len; + int path_len; int *type; char *p; _kernel_swi_regs regs; @@ -182,6 +191,8 @@ void ReadVoiceNames2(char *directory) regs.r[5] = sizeof(buf); regs.r[6] = 0; + path_len = strlen(directory); + while(regs.r[3] > 0) { error = _kernel_swi(0x0c+os_X,®s,®s); /* OS_GBPB 10, read directory entries */ @@ -200,11 +211,21 @@ void ReadVoiceNames2(char *directory) } else { - p = Alloc(len+1); + p = (char *)malloc(len+1); strcpy(p,&buf[20]); - voice_names[n_voice_files++] = p; - if(n_voice_files >= (N_VOICE_NAMES-1)) - break; + + if(strcmp(&directory[path_len-3],".!v")==0) + { + if(n_voice_variant_files >= (N_VOICE_VARIANT_NAMES-1)) + continue; + voice_variant_names[n_voice_variant_files++] = p; + } + else + { + if(n_voice_files >= (N_VOICE_NAMES-1)) + continue; + voice_names[n_voice_files++] = p; + } } } } @@ -214,13 +235,15 @@ void ReadVoiceNames() {//=================== char directory[sizeof(path_home)+10]; - for(n_voice_files=0; n_voice_files= 0) && (voice_num != current_voice_num) && (voice_num < N_VOICE_NAMES)) { @@ -465,7 +567,6 @@ void set_say_options(int reg2, int reg3) option_linelength = 0; option_phonemes = 0; option_waveout = 0; - option_harmonic1 = 8; option_multibyte = 0; // auto option_capitals = 0; option_punctuation = 0; @@ -477,10 +578,13 @@ void set_say_options(int reg2, int reg3) void jsd_swi_functions(int *r) /****************************/ { + espeak_VOICE voice_select; + switch(r[0]) { case 0: /* major version */ - r[0] = 3; + r[0] = 4; + r[1] = 331; break; case 1: /* register user */ @@ -499,6 +603,7 @@ void jsd_swi_functions(int *r) case 5: /* get table of voice names */ r[0] = (int)voice_names; + r[1] = (int)voice_variant_names; break; case 6: /* update voice data, r1 = voice_number */ @@ -514,6 +619,15 @@ void jsd_swi_functions(int *r) // init_voice((char *)r[1]); break; + case 8: + // list voices, r[1] contains optional language name (or "variant") + voice_select.languages = (char *)r[1]; + voice_select.age = 0; + voice_select.gender = 0; + voice_select.name = NULL; + r[0] = (int)espeak_ListVoices(&voice_select); + break; + default: r[0] = 0; r[1] = 0; @@ -529,8 +643,6 @@ _kernel_oserror *swi_handler(int swi_no, int *r, void *pw) { int value; int q_length; - int speed; - int amp; value = r[0]; switch(swi_no) @@ -584,8 +696,7 @@ _kernel_oserror *swi_handler(int swi_no, int *r, void *pw) break; case 8: /* speed */ - speed = (value * 160)/140; - SetParameter(espeakRATE,speed,0); + SetParameter(espeakRATE,value,0); break; case 9: /* word_gap */ @@ -601,8 +712,7 @@ _kernel_oserror *swi_handler(int swi_no, int *r, void *pw) break; case 13: /* volume */ - amp = (value*45)/100; - SetParameter(espeakVOLUME,amp,0); + SetParameter(espeakVOLUME,value,0); WavegenSetVoice(voice); break; } @@ -614,7 +724,7 @@ _kernel_oserror *swi_handler(int swi_no, int *r, void *pw) void PitchAdjust(int pitch_adjustment) {//=================================== int ix, factor; - + extern unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1]; voice->pitch_base = (voice->pitch_base * pitch_adjust_tab[pitch_adjustment])/128; @@ -629,6 +739,72 @@ void PitchAdjust(int pitch_adjustment) +void DisplayVoices(FILE *f_out, char *language) +{//============================================ + int ix; + const char *p; + int len; + int count; + int scores = 0; + const espeak_VOICE *v; + const char *lang_name; + char age_buf[12]; + const espeak_VOICE **voices; + espeak_VOICE voice_select; + + static char genders[4] = {' ','M','F',' '}; + + if(language[0] == '=') + { + // display only voices for the specified language, in order of priority + voice_select.languages = &language[1]; + voice_select.age = 0; + voice_select.gender = 0; + voice_select.name = NULL; + voices = espeak_ListVoices(&voice_select); + scores = 1; + } + else + { + voices = espeak_ListVoices(NULL); + } + + fprintf(f_out,"Pty Language Age/Gender VoiceName File Other Langs\n"); + + for(ix=0; (v = voices[ix]) != NULL; ix++) + { + count = 0; + p = v->languages; + while(*p != 0) + { + len = strlen(p+1); + lang_name = p+1; + + if(v->age == 0) + strcpy(age_buf," "); + else + sprintf(age_buf,"%3d",v->age); + + if(count==0) + { + fprintf(f_out,"%2d %-12s%s%c %-17s %-11s ", + p[0],lang_name,age_buf,genders[v->gender],v->name,v->identifier); + } + else + { + fprintf(f_out,"(%s %d)",lang_name,p[0]); + } + count++; + p += len+2; + } +// if(scores) +// fprintf(f_out,"%3d ",v->score); + fputc('\n',f_out); + } +} // end of DisplayVoices + + + char *param_string(char **argp) {//============================ char *p; @@ -686,7 +862,6 @@ void command_line(char *arg_string, int wait) option_phonemes = 0; option_waveout = 0; option_quiet = 0; - option_harmonic1 = 8; option_multibyte = 0; // auto option_capitals = 0; option_punctuation = 0; @@ -731,7 +906,7 @@ void command_line(char *arg_string, int wait) case 'm': option_ssml = 1; break; - + case 'p': pitch_adjustment = param_number(&p); break; @@ -762,7 +937,7 @@ void command_line(char *arg_string, int wait) wordgap = param_number(&p); SetParameter(espeakWORDGAP,wordgap,0); break; - + case 'v': strncpy0(voicename,param_string(&p),sizeof(voicename)); break; @@ -776,7 +951,13 @@ void command_line(char *arg_string, int wait) strncpy0(command,param_string(&p),sizeof(command)); if(memcmp(command,"compile=",8)==0) { - CompileDictionary(NULL,&command[8],NULL,NULL); + CompileDictionary(NULL,&command[8],NULL,NULL,0); + return; + } + else + if(memcmp(command,"voices",6)==0) + { + DisplayVoices(stdout,&command[6]); return; } else @@ -1075,7 +1256,7 @@ void terminate_module(void) { RiscosCloseSound(); RemoveCallback(); - delete translator; + DeleteTranslator(translator); FreePhData(); } /* end of terminate_module */ @@ -1121,8 +1302,8 @@ _kernel_oserror *user_init(char *cmd_fail, int podule_base, void *pw) for(param=0; param #define PLATFORM_WINDOWS diff --git a/platforms/windows/espeakedit/src_copy/speech.h b/platforms/windows/espeakedit/src_copy/speech.h index 0ac7b3b2..04d0e0bf 100755 --- a/platforms/windows/espeakedit/src_copy/speech.h +++ b/platforms/windows/espeakedit/src_copy/speech.h @@ -28,6 +28,7 @@ //#define SPECT_EDITOR #define INCLUDE_KLATT #define INCLUDE_MBROLA +#define INCLUDE_SONIC #include #define PLATFORM_WINDOWS diff --git a/platforms/windows/windows_cmd/src/speech.h b/platforms/windows/windows_cmd/src/speech.h index 45fe7ace..12532e1d 100755 --- a/platforms/windows/windows_cmd/src/speech.h +++ b/platforms/windows/windows_cmd/src/speech.h @@ -36,6 +36,8 @@ #define NO_VARIADIC_MACROS #define INCLUDE_KLATT #define INCLUDE_MBROLA +#define INCLUDE_SONIC + // will look for espeak_data directory here, and also in user's home directory #define PATH_ESPEAK_DATA "/usr/share/espeak-data" diff --git a/platforms/windows/windows_dll/src/speech.h b/platforms/windows/windows_dll/src/speech.h index 01f1beb5..b7188e54 100755 --- a/platforms/windows/windows_dll/src/speech.h +++ b/platforms/windows/windows_dll/src/speech.h @@ -39,6 +39,8 @@ #define LIBRARY #define INCLUDE_KLATT #define INCLUDE_MBROLA +#define INCLUDE_SONIC + // will look for espeak_data directory here, and also in user's home directory #define PATH_ESPEAK_DATA "/usr/share/espeak-data" diff --git a/platforms/windows/windows_sapi/src/speech.h b/platforms/windows/windows_sapi/src/speech.h index 386b99b9..0df7a00f 100755 --- a/platforms/windows/windows_sapi/src/speech.h +++ b/platforms/windows/windows_sapi/src/speech.h @@ -41,6 +41,8 @@ //#define USE_NANOSLEEP #define INCLUDE_KLATT #define INCLUDE_MBROLA +#define INCLUDE_SONIC + // will look for espeak_data directory here, and also in user's home directory #define PATH_ESPEAK_DATA "/usr/share/espeak-data" diff --git a/src/numbers.cpp b/src/numbers.cpp index 96b64862..5a521d0c 100644 --- a/src/numbers.cpp +++ b/src/numbers.cpp @@ -984,39 +984,46 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab) static const char *M_Variant(int value) {//==================================== - // returns M, or perhaps MA for some cases + // returns M, or perhaps MA or MB for some cases - if(translator->translator_name == L('l','t')) + int teens = 0; + + if(((value % 100) > 10) && ((value % 100) < 20)) + teens = 1; + + switch((translator->langopts.numbers2 >> 6) & 0x7) { - // Lithuanian + case 1: // lang=ru use singular for xx1 except for x11 + if((teens == 0) && ((value % 10) == 1)) + return("1M"); + break; + + case 2: // lang=cs,sk + if((value >= 2) && (value <= 4)) + return("0MA"); + break; + + case 3: // lang=pl + if((teens == 0) && (((value % 10) >= 2) && ((value % 10) <= 4))) + return("0MA"); + break; + + case 4: // lang=lt + if((teens == 1) || ((value % 10) == 0)) + return("0MB"); if((value % 10) == 1) return("0MA"); - if(((value % 10) == 0) || ((value % 100) > 10) && ((value % 100) < 20)) - { - return("0MB"); - } - return("0M"); - } + break; - if((translator->langopts.numbers2 & 0x100) && (value >= 2) && (value <= 4)) - return("0MA"); // Czech, Slovak - else - if(((value % 100) < 10) || ((value % 100) > 20)) // but not teens, 10 to 19 - { - if ((translator->langopts.numbers2 & 0x40) && - ((value % 10)>=2) && - ((value % 10)<=4)) + case 5: // lang=bs,hr,sr + if(teens == 0) { - // for Polish language - two forms of plural! - return("0MA"); + if((value % 10) == 1) + return("1M"); + if(((value % 10) >= 2) && ((value % 10) <= 4)) + return("0MA"); } - - if((translator->langopts.numbers2 & 0x80) && - ((value % 10)==1)) - { - return("1MA"); - } - + break; } return("0M"); } diff --git a/src/readclause.cpp b/src/readclause.cpp index 64afc0db..c1be8a00 100644 --- a/src/readclause.cpp +++ b/src/readclause.cpp @@ -1591,7 +1591,7 @@ static void SetProsodyParameter(int param_type, wchar_t *attr1, PARAM_STACK *sp) static int ReplaceKeyName(char *outbuf, int index, int &outix) {//=========================================================== // Replace some key-names by single characters, so they can be pronounced in different languages - MNEM_TAB keynames[] = { + static MNEM_TAB keynames[] = { {"space ",0xe020}, {"tab ", 0xe009}, {"underscore ", 0xe05f}, diff --git a/src/setlengths.cpp b/src/setlengths.cpp index 76e6983a..fdc7ebc8 100644 --- a/src/setlengths.cpp +++ b/src/setlengths.cpp @@ -136,6 +136,8 @@ static int speed3 = 118; //#define TEST_SPEED +#ifdef INCLUDE_SONIC + void SetSpeed(int control) {//======================= int x; @@ -312,6 +314,147 @@ printf("%3d: speedf %d %d %d pause=%d %d wav=%d lenmod=%d %d\n",wpm,speed1, #endif } // end of SetSpeed +#else // not using sonic speed-up + +void SetSpeed(int control) +{//======================= +// This is the earlier version of SetSpeed() before sonic speed-up was added + int x; + int s1; + int wpm; + int wpm2; + + speed.loud_consonants = 0; + speed.min_sample_len = 450; + speed.lenmod_factor = 110; // controls the effect of FRFLAG_LEN_MOD reduce length change + speed.lenmod2_factor = 100; + + wpm = embedded_value[EMBED_S]; + if(control == 2) + wpm = embedded_value[EMBED_S2]; + +#ifdef TEST_SPEED + if(wpm > 1000) + { + // TESTING + test = wpm / 1000; + wpm = wpm % 1000; + } +#endif + + if(voice->speed_percent > 0) + { + wpm = (wpm * voice->speed_percent)/100; + } + if(wpm > 450) + wpm = 450; + + if(wpm > 360) + { + speed.loud_consonants = (wpm - 360) / 8; + } + + wpm2 = wpm; + if(wpm > 359) wpm2 = 359; + if(wpm < 80) wpm2 = 80; + x = speed_lookup[wpm2-80]; + + if(wpm >= 380) + x = 7; + if(wpm >= 400) + x = 6; + + if(control & 1) + { + // set speed factors for different syllable positions within a word + // these are used in CalcLengths() + speed1 = (x * voice->speedf1)/256; + speed2 = (x * voice->speedf2)/256; + speed3 = (x * voice->speedf3)/256; + + if(x <= 7) + { + speed1 = x; + speed2 = speed3 = x - 1; + } + } + + if(control & 2) + { + // these are used in synthesis file + + if(wpm > 350) + { + speed.lenmod_factor = 85 - (wpm - 350) / 3; + speed.lenmod2_factor = 60 - (wpm - 350) / 8; + } + else + if(wpm > 250) + { + speed.lenmod_factor = 110 - (wpm - 250)/4; + speed.lenmod2_factor = 110 - (wpm - 250)/2; + } + + s1 = (x * voice->speedf1)/256; + + if(wpm >= 170) + speed.wav_factor = 110 + (150*s1)/128; // reduced speed adjustment, used for playing recorded sounds + else + speed.wav_factor = 128 + (128*s1)/130; // = 215 at 170 wpm + + if(wpm >= 350) + { + speed.wav_factor = wav_factor_350[wpm-350]; + } + + if(wpm >= 390) + { + speed.min_sample_len = 450 - (wpm - 400)/2; + if(wpm > 440) + speed.min_sample_len = 420 - (wpm - 440); + } + + speed.pause_factor = (256 * s1)/115; // full speed adjustment, used for pause length + speed.clause_pause_factor = 0; + + if(wpm > 430) + { + speed.pause_factor = 12; +// speed.clause_pause_factor = 15; + } + else + if(wpm > 400) + { + speed.pause_factor = 13; +// speed.clause_pause_factor = 15; + } + else + if(wpm > 374) + { + speed.pause_factor = 14; + } + else + if(wpm > 350) + { + speed.pause_factor = pause_factor_350[wpm - 350]; + } + + if(speed.clause_pause_factor == 0) + { + // restrict the reduction of pauses between clauses + if((speed.clause_pause_factor = speed.pause_factor) < 16) + speed.clause_pause_factor = 16; + } + } + +#ifdef TEST_SPEED +//if(control==3) +printf("%3d: speedf %d %d %d pause=%d %d wav=%d lenmod=%d %d\n",wpm,speed1,speed2,speed3, speed.pause_factor,speed.clause_pause_factor, speed.wav_factor,speed.lenmod_factor,speed.lenmod2_factor); +#endif +} // end of SetSpeed + +#endif // of INCLUDE_SONIC + #ifdef deleted void SetAmplitude(int amp) diff --git a/src/sonic.cpp b/src/sonic.cpp index caea2a57..82febba5 100644 --- a/src/sonic.cpp +++ b/src/sonic.cpp @@ -20,11 +20,15 @@ #include "StdAfx.h" + #include #include #include #include + +#include "speech.h" #include "sonic.h" +#ifdef INCLUDE_SONIC struct sonicStreamStruct { short *inputBuffer; @@ -965,3 +969,4 @@ int sonicChangeShortSpeed( sonicDestroyStream(stream); return numSamples; } +#endif // INCLUDE_SONIC diff --git a/src/speech.h b/src/speech.h index cbc9e5aa..8f37f343 100644 --- a/src/speech.h +++ b/src/speech.h @@ -25,6 +25,7 @@ // conditional compilation options #define INCLUDE_KLATT #define INCLUDE_MBROLA +#define INCLUDE_SONIC #if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN #define ARCH_BIG diff --git a/src/synthdata.cpp b/src/synthdata.cpp index 15231fc8..1db93b41 100644 --- a/src/synthdata.cpp +++ b/src/synthdata.cpp @@ -35,7 +35,7 @@ #include "translate.h" #include "wave.h" -const char *version_string = "1.46.21 25.Jul.12"; +const char *version_string = "1.46.22 09.Aug.12"; const int version_phdata = 0x014600; int option_device_number = -1; @@ -975,7 +975,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_ if(instn2 < 8) { // ChangeIf - if(StressCondition(tr, plist, instn2 & 7, 1)) + if(StressCondition(tr, plist, instn2 & 7, 1) == true) { phdata->pd_param[i_CHANGE_PHONEME] = instn & 0xff; end_flag = 1; // change phoneme, exit diff --git a/src/synthesize.cpp b/src/synthesize.cpp index ca0314ea..26e54707 100644 --- a/src/synthesize.cpp +++ b/src/synthesize.cpp @@ -1237,6 +1237,7 @@ void DoPhonemeMarker(int type, int char_posn, int length, char *name) } // end of DoMarker +#ifdef INCLUDE_SONIC void DoSonicSpeed(int value) {//========================= // value, multiplier * 1024 @@ -1244,6 +1245,7 @@ void DoSonicSpeed(int value) wcmdq[wcmdq_tail][1] = value; WcmdqInc(); } // end of DoSonicSpeed +#endif void DoVoiceChange(voice_t *v) diff --git a/src/tr_languages.cpp b/src/tr_languages.cpp index cfe63b5b..823fcec1 100644 --- a/src/tr_languages.cpp +++ b/src/tr_languages.cpp @@ -118,8 +118,8 @@ static const unsigned short chars_ignore_default[] = { 0, 0 }; // alternatively, ignore characters but allow zero-width-non-joiner (lang-fa) -static const unsigned short chars_ignore_fa[] = { - 0x200c, 0x0605, // zero width non-joiner, replace with not-used Arabic character code +static const unsigned short chars_ignore_zwnj_hyphen[] = { + 0x200c, '-', // zero width non-joiner, replace with hyphen 0x200d, 1, // zero width joiner 0, 0 }; @@ -661,13 +661,11 @@ Translator *SelectTranslator(const char *name) case L('f','a'): // Farsi { - static const char fa_ZWNJ[] = {0x05, 0}; // use letter group G for ZWNJ U+200c tr->letter_bits_offset = OFFSET_ARABIC; tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND; tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words - tr->chars_ignore = chars_ignore_fa; - SetLetterBits(tr,LETTERGP_G,(char *)fa_ZWNJ); + tr->chars_ignore = chars_ignore_zwnj_hyphen; // replace ZWNJ by hyphen } break; @@ -763,7 +761,7 @@ Translator *SelectTranslator(const char *name) tr->langopts.accents = 1; tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_CAPITALS; - tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards + tr->langopts.numbers2 = 0xa + NUM2_THOUSANDS_VAR5; // variant numbers before thousands,milliards tr->langopts.replace_chars = replace_cyrillic_latin; SetLetterVowel(tr,'y'); @@ -999,7 +997,7 @@ SetLengthMods(tr,3); // all equal tr->langopts.unstressed_wd2 = 2; tr->langopts.param[LOPT_DIERESES] = 1; tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT; - tr->langopts.numbers2 = 0x100; + tr->langopts.numbers2 = NUM2_THOUSANDS_VAR4; tr->langopts.max_roman = 5000; } break; @@ -1098,7 +1096,7 @@ SetLengthMods(tr,3); // all equal tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9; tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :) tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2; - tr->langopts.numbers2 = 0x40; + tr->langopts.numbers2 = NUM2_THOUSANDS_VAR3; tr->langopts.param[LOPT_COMBINE_WORDS] = 4 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable (and 2-syllable) words (marked with $alt) SetLetterVowel(tr,'y'); } @@ -1170,7 +1168,7 @@ SetLengthMods(tr,3); // all equal tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ROMAN; - tr->langopts.numbers2 = 0x100; + tr->langopts.numbers2 = NUM2_THOUSANDS_VAR2; tr->langopts.thousands_sep = STRESSPOSN_1L; //no thousands separator tr->langopts.decimal_sep = ','; @@ -1478,7 +1476,7 @@ static void Translator_Russian(Translator *tr) tr->langopts.stress_flags = 0x0020; // waas 0x1010 tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED; - tr->langopts.numbers2 = 0xc2; // variant numbers before thousands + tr->langopts.numbers2 = 0x2 + NUM2_THOUSANDS_VAR1; // variant numbers before thousands tr->langopts.phoneme_change = 1; tr->langopts.testing = 2; diff --git a/src/translate.cpp b/src/translate.cpp index 01e7e16c..aa06eed1 100644 --- a/src/translate.cpp +++ b/src/translate.cpp @@ -372,7 +372,7 @@ int IsAlpha(unsigned int c) {//======================== // Replacement for iswalph() which also checks for some in-word symbols - const unsigned short extra_indic_alphas[] = { + static const unsigned short extra_indic_alphas[] = { 0xa70,0xa71, // Gurmukhi: tippi, addak 0 }; @@ -1013,7 +1013,7 @@ if((wmark > 0) && (wmark < 8)) found = TranslateNumber(tr, word1, phonemes, dictionary_flags, wtab, 0); } - if(!found & ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER)) + if(!found && ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER)) { // either all upper or all lower case diff --git a/src/translate.h b/src/translate.h index 9c8e229e..cbd5b367 100644 --- a/src/translate.h +++ b/src/translate.h @@ -446,10 +446,13 @@ typedef struct { #define NUM2_MULTIPLE_ORDINAL 0x1000 #define NUM2_ENGLISH_NUMERALS 0x2000 +#define NUM2_THOUSANDS_VAR1 0x40 +#define NUM2_THOUSANDS_VAR2 0x80 +#define NUM2_THOUSANDS_VAR3 0xc0 +#define NUM2_THOUSANDS_VAR4 0x100 +#define NUM2_THOUSANDS_VAR5 0x140 // bits 1-4 use variant form of numbers before thousands,millions,etc. - // bit6=(LANG=pl) two forms of plural, M or MA - // bit7=(LANG-ru) use MB for 1 thousand, million, etc - // bit8=(LANG=cs,sk) two forms of plural, M or MA + // bits 6-8 use different forms of thousand, million, etc (M MA MB) // bit9=(LANG=rw) say "thousand" and "million" before its number, not after // bit12=(LANG=el,es) use ordinal form of hundreds and tens as well as units // bit13=(LANG=ne) speak (non-replaced) English numerals in English diff --git a/src/wavegen.cpp b/src/wavegen.cpp index a7535fed..1f34cd22 100644 --- a/src/wavegen.cpp +++ b/src/wavegen.cpp @@ -34,9 +34,10 @@ #include "phoneme.h" #include "synthesize.h" #include "voice.h" -#include "sonic.h" -//#undef INCLUDE_KLATT +#ifdef INCLUDE_SONIC +#include "sonic.h" +#endif #ifdef USE_PORTAUDIO #include "portaudio.h" @@ -150,8 +151,10 @@ static PortAudioStream *pa_stream=NULL; static PaStream *pa_stream=NULL; #endif +#ifdef INCLUDE_SONIC static sonicStream sonicSpeedupStream = NULL; double sonicSpeed = 1.0; +#endif // 1st index=roughness // 2nd index=modulation_type @@ -295,11 +298,15 @@ void WcmdqStop() {//============= wcmdq_head = 0; wcmdq_tail = 0; + +#ifdef INCLUDE_SONIC if(sonicSpeedupStream != NULL) { sonicDestroyStream(sonicSpeedupStream); sonicSpeedupStream = NULL; } +#endif + #ifdef USE_PORTAUDIO Pa_AbortStream(pa_stream); #endif @@ -1912,14 +1919,18 @@ int WavegenFill2(int fill_zeros) } wdata.n_mix_wavefile = 0; wdata.amplitude_fmt = 100; +#ifdef INCLUDE_KLATT KlattReset(1); +#endif result = PlaySilence(length,resume); break; case WCMD_WAVE: echo_complete = echo_length; wdata.n_mix_wavefile = 0; +#ifdef INCLUDE_KLATT KlattReset(1); +#endif result = PlayWave(length,resume,(unsigned char*)q[2], q[3] & 0xff, q[3] >> 8); break; @@ -1989,9 +2000,11 @@ int WavegenFill2(int fill_zeros) wdata.amplitude_fmt = 100; // percentage, but value=0 means 100% break; +#ifdef INCLUDE_SONIC case WCMD_SONIC_SPEED: sonicSpeed = (double)q[1] / 1024; break; +#endif } if(result==0) @@ -2009,6 +2022,7 @@ int WavegenFill2(int fill_zeros) } // end of WavegenFill2 +#ifdef INCLUDE_SONIC /* Speed up the audio samples with libsonic. */ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text) {//============================================================================== @@ -2035,6 +2049,7 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text } return sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out); } // end of SpeedUp +#endif /* Call WavegenFill2, and then speed up the output samples. */ @@ -2042,16 +2057,18 @@ int WavegenFill(int fill_zeros) {//============================ int finished; unsigned char *p_start; - int length; - int max_length; p_start = out_ptr; // fill_zeros is ignored. It is now done in the portaudio callback finished = WavegenFill2(0); +#ifdef INCLUDE_SONIC if(sonicSpeed > 1.0) { + int length; + int max_length; + max_length = (out_end - p_start); length = 2*SpeedUp((short *)p_start, (out_ptr-p_start)/2, max_length/2, finished); out_ptr = p_start + length; @@ -2059,6 +2076,7 @@ int WavegenFill(int fill_zeros) if(length >= max_length) finished = 0; // there may be more data to flush } +#endif return finished; } // end of WavegenFill