From 4a670d0f57c8a7cb9073c60f8efe3afd3409b2f6 Mon Sep 17 00:00:00 2001 From: jonsd Date: Fri, 26 Apr 2013 22:33:46 +0000 Subject: [PATCH] [1.47.08] Add API function: espeak_TextToPhonemes(). git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@349 d46cf337-b52f-0410-862d-fd96e6ae7743 --- dictsource/dict_phonemes | 4 +- dictsource/en_list | 14 ++--- dictsource/en_rules | 1 + dictsource/pt_list | 4 +- dictsource/pt_rules | 37 +++++------ platforms/windows/make_espeak.iss | 2 +- platforms/windows/make_espeakedit.iss | 2 +- src/compiledict.cpp | 1 + src/dictionary.cpp | 5 ++ src/espeakedit.cpp | 7 +++ src/main.h | 1 + src/menus.cpp | 4 +- src/numbers.cpp | 44 +++++++------ src/readclause.cpp | 6 +- src/speak_lib.cpp | 2 +- src/speak_lib.h | 91 ++++++++++++++++++--------- src/synthdata.cpp | 2 +- src/translate.h | 3 +- 18 files changed, 139 insertions(+), 91 deletions(-) diff --git a/dictsource/dict_phonemes b/dictsource/dict_phonemes index 7a6e4b33..7d37f9c3 100644 --- a/dictsource/dict_phonemes +++ b/dictsource/dict_phonemes @@ -148,7 +148,7 @@ p Q r R s s; t T ts v x z -Dictionary en_dict 2013-04-25 +Dictionary en_dict 2013-04-26 0 0# 3 3: @ @- @2 @5 @L a a# A: A@ aa aI aI3 @@ -574,7 +574,7 @@ S s; S; t t; tS ts tS; ts; v w x z Z Z; -Dictionary pt_dict 2013-04-25 +Dictionary pt_dict 2013-04-26 & &/ &U~ &~ @ @- a A aI aU e E eI EI eU EU diff --git a/dictsource/en_list b/dictsource/en_list index 6380e295..1ff69b6a 100644 --- a/dictsource/en_list +++ b/dictsource/en_list @@ -151,19 +151,14 @@ _} raItbreIs _¡ %Inv,3:tI2dEkskl@m'eIS@n _¦ broUk@nb'A@ _¨ daIa#r'i:sIs -_ª fEmI2nIn'O@dI2n@L _« lEft'gIl@mEt _­ makr0n -² tu: -³ Tri: -_¹ su:p@skrIptw'0n -_² su:p@skrIptt'u: -_³ su:p@skrIptT'ri: +² tu: $native +³ Tri: $native + _´ a#kju:taksEnt _· mId@Ld0t _¸ sEd'Il@ -//_º maskjUlIn'O@dI2n@L -_º dI2gr'i:z _» raIt'gIl@mEt _¿ %Inv,3:tI2dkw'EstS@n @@ -1612,7 +1607,6 @@ fortune fO@tSu:n foyer fOIeI freelance fri:laans freon fri:0n -frequent frI2kwEnt $verb fricassee frIka#seI frigate frIg@t fringer frIndZ3 // infringer @@ -3483,7 +3477,7 @@ Amy eImi Andre 0ndreI Andrea andri@ Andreas A:ndr'eI@s -Angela $1 +Angela ang@l@ Anita $alt3 Anthony ant@ni Anton ant0n diff --git a/dictsource/en_rules b/dictsource/en_rules index 9fcd8241..ec5ad6b7 100644 --- a/dictsource/en_rules +++ b/dictsource/en_rules @@ -2486,6 +2486,7 @@ ery (A 3j _v) ery ErI2 qu) ery i@rI + _x) er (o i@r z) er (o i@r _C) er (o_ i@r er (rA E diff --git a/dictsource/pt_list b/dictsource/pt_list index f63744f7..8e3eb0a0 100755 --- a/dictsource/pt_list +++ b/dictsource/pt_list @@ -835,7 +835,6 @@ dobro $alt $verb doce $alt2 doutora $alt2 doze $alt2 -droga $alt dueto $alt2 elixir eliSir emprego $alt2 $noun @@ -1100,7 +1099,7 @@ rota $alt2 rota $alt $noun rubores $alt2 rumores $alt2 -sabonete $alt2 +sabonete $alt2 sabores $alt2 saibro s'aIbRU saleta $alt2 @@ -1229,7 +1228,6 @@ laptop lEptOp ?1 line l'ain layout l'eI,aUt ?2 login logiN -?2 logo l'OgU ?1 lock l'Ok mail m'eIl mails m'eIls diff --git a/dictsource/pt_rules b/dictsource/pt_rules index 3313e7ed..df452595 100755 --- a/dictsource/pt_rules +++ b/dictsource/pt_rules @@ -214,7 +214,7 @@ i) e (r_ E @s) e (r_ E - qu) e (r_ E + qu) e (r_ E ib) e (rL04_ E d) e (rL04_ E @@ -229,7 +229,7 @@ f) e (rL02_ E e (quL02_ E -e (rbL04_ E + e (rbL04_ E e (rgL04_ E e (rsL04_ E @@ -239,7 +239,7 @@ e (rbL04_ E e (ssL04_ E e (ss_ E // stress and english words ?2 ection (_ 'EkS&~N -?2 ee (n_ i +?2 ee (n_ i e (stL04_ E e (strL04_ E @@ -372,7 +372,6 @@ e (rbL04_ E tiv) e (L05_ E // es- viv) e (L05_ e _com) e (L05_ e - s_colh) e (res_ E _cos) e (L05_ e _pud) e (L05_ E _coub) e (L05_ E @@ -425,18 +424,17 @@ _corro) e (L07_ e _interromp) e (L07_ e _troux) e (L07_ E _ens) e (bL03_ E - _enver) e (dL03_ E _amanc) e (bL03_ E qu) e (brL04_ E _cel) e (brL04_ E _boch) e (chL04_ e - _on) e (rL04_ E - _ex) e (crL04_ E + _ex) e (crL04_ E _enr) e (dL01_ E _v) e (dL03_ E _arr) e (dL03_ E _depr) e (dL03_ E _hosp) e (dL03_ E +_enver) e (dL03_ E _gr) e (gL03_ e _gal) e (gL03_ e _pel) e (gL03_ e @@ -455,6 +453,7 @@ _amanc) e (bL03_ E _g) e (rL04_ E _z) e (rL04_ E qu) e (rL04_ E // re- + _on) e (rL04_ E _op) e (rL04_ E gen) e (rL04_ E // de- re- _alt) e (rL04_ E @@ -475,15 +474,16 @@ _adult) e (rL04_ E _persev) e (rL04_ E _recup) e (rL04_ E _refrig) e (rL04_ E - _ex) e (rcL02_ E + _ex) e (rcL02_ E _alic) e (rcL02_ E _p) e (rdL02_ E _l) e (rdL03_ E _h) e (rdL04_ E _des) e (rdL04_ E +s_colh) e (res_ E _) e (rgL03_ e -_so) e (rgL03_ e _re) e (rgL03_ e + _so) e (rgL03_ e _bez) e (rrL03_ e v) e (rtL03_ e // con- re- in- _f) e (rvL03_ e @@ -855,8 +855,8 @@ _entorp) e (çL03_ e óCC) o (CA_ o úC) o (CA_ o úCC) o (CA_ o -?2 otion (_ 'owS&~N - +?2 otion (_ 'owS&~N + //sort _f) o (L05_ o _pormen) o (L05_ O @@ -866,15 +866,15 @@ _pormen) o (L05_ O _esn) o (bL04_ O _engl) o (bL04_ O _sal) o (brL03_ o - _env) o (ltL03_ o _) o (cL03_ o _m) o (fL01_ O _m) o (fL02_ O _s) o (frL02_ O + l) o (gL04_ O // dialoga, etc. r) o (gL04_ O // inter- + v) o (gL04_ O // advoga, etc. _j) o (gL04_ O af) o (gL04_ O // des- - _adv) o (gL04_ O _ref) o (gL04_ O _ap) oi (L01_ OI _ap) oi (L02_ OI @@ -884,6 +884,7 @@ _pormen) o (L05_ O _emp) o (lgL04_ O _) o (lhL04_ O m) o (lhL04_ O + _env) o (ltL03_ o ent) o (pL02_ O _c) o (pL03_ O _t) o (pL04_ O @@ -1077,8 +1078,8 @@ _remem) o (rL04_ O u (a u g) u (a+ w q) u (a+ w -u (eC u -u (ei u + u (eC u + u (ei u r) u (_A u u (L04_ 'u @@ -1086,8 +1087,8 @@ u (ei u ui (_ 'uI u (iu w u (iCK u -u (éC u -u (íC u + u (éC u + u (íC u uy uI ul (K uw u (lh+ u @@ -1100,7 +1101,7 @@ u (íC u g) u (Y _m) ui (tA_ 'wiN -?2 ution (_ 'uS&~N +?2 ution (_ 'uS&~N .group ú diff --git a/platforms/windows/make_espeak.iss b/platforms/windows/make_espeak.iss index 4a922cf5..c43183f0 100755 --- a/platforms/windows/make_espeak.iss +++ b/platforms/windows/make_espeak.iss @@ -2,7 +2,7 @@ [Setup] AppName=eSpeak -AppVerName=eSpeak version 1.47.06 +AppVerName=eSpeak version 1.47.08 AppCopyright=Licensed under GNU General Public License version 3. (See file License.txt for details). WindowVisible=yes diff --git a/platforms/windows/make_espeakedit.iss b/platforms/windows/make_espeakedit.iss index b62f01fb..9521f0e6 100755 --- a/platforms/windows/make_espeakedit.iss +++ b/platforms/windows/make_espeakedit.iss @@ -1,7 +1,7 @@ [Setup] AppName=eSpeakEdit -AppVerName=eSpeakEdit version 1.47.06 +AppVerName=eSpeakEdit version 1.47.08 DefaultDirName={pf}\eSpeak DefaultGroupName=eSpeak OutputBaseFilename=setup_espeakedit diff --git a/src/compiledict.cpp b/src/compiledict.cpp index c4979533..fe054cc7 100644 --- a/src/compiledict.cpp +++ b/src/compiledict.cpp @@ -133,6 +133,7 @@ MNEM_TAB mnem_flags[] = { {"$stem", 0x30}, // must have a suffix {"$atend", 0x31}, // use this pronunciation if at end of clause {"$atstart", 0x32}, // use this pronunciation at start of clause + {"$native", 0x33}, // not if we've switched translators // doesn't set dictionary_flags {"$?", 100}, // conditional rule, followed by byte giving the condition number diff --git a/src/dictionary.cpp b/src/dictionary.cpp index 41ebfa2b..456a0871 100644 --- a/src/dictionary.cpp +++ b/src/dictionary.cpp @@ -3275,6 +3275,11 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor continue; } } + if(dictionary_flags2 & FLAG_NATIVE) + { + if(tr != translator) + continue; // don't use if we've switched translators + } if(dictionary_flags & FLAG_ALT2_TRANS) { // language specific diff --git a/src/espeakedit.cpp b/src/espeakedit.cpp index 299e947e..156047aa 100644 --- a/src/espeakedit.cpp +++ b/src/espeakedit.cpp @@ -199,6 +199,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(MENU_OPT_SPEED, MyFrame::OnOptions) EVT_MENU(MENU_OPT_PUNCT, MyFrame::OnOptions) EVT_MENU(MENU_OPT_SPELL, MyFrame::OnOptions) + EVT_MENU(MENU_OPT_SPELL2, MyFrame::OnOptions) EVT_MENU(MENU_PATH0, MyFrame::OnOptions) EVT_MENU(MENU_PATH1, MyFrame::OnOptions) EVT_MENU(MENU_PATH2, MyFrame::OnOptions) @@ -625,6 +626,12 @@ void OnOptions2(int event_id) break; case MENU_OPT_SPELL: + transldlg->t_source->SetValue(_T("\n")); + transldlg->t_source->SetInsertionPointEnd(); + notebook->SetSelection(1); + break; + + case MENU_OPT_SPELL2: transldlg->t_source->SetValue(_T("\n")); transldlg->t_source->SetInsertionPointEnd(); notebook->SetSelection(1); diff --git a/src/main.h b/src/main.h index f9a8a12f..72542b73 100755 --- a/src/main.h +++ b/src/main.h @@ -127,6 +127,7 @@ enum { MENU_OPT_SPEED, MENU_OPT_PUNCT, MENU_OPT_SPELL, + MENU_OPT_SPELL2, MENU_PATHS, MENU_PATH0, MENU_PATH1, diff --git a/src/menus.cpp b/src/menus.cpp index 603097d8..0b970607 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -119,8 +119,10 @@ wxMenuBar *MakeMenu(int type, const char *dict_name) option_menu = new wxMenu; option_menu->Append(MENU_PATHS, _("Set &paths"), paths_menu); option_menu->Append(MENU_OPT_SPEED, _("Speed...")); + option_menu->AppendSeparator(); option_menu->Append(MENU_OPT_PUNCT, _("Speak punctuation")); - option_menu->Append(MENU_OPT_SPELL, _("Speak character names")); + option_menu->Append(MENU_OPT_SPELL, _("Speak characters")); + option_menu->Append(MENU_OPT_SPELL2, _("Speak character name")); // TOOLS vowelchart_menu = new wxMenu; diff --git a/src/numbers.cpp b/src/numbers.cpp index 06e73bf9..84842019 100644 --- a/src/numbers.cpp +++ b/src/numbers.cpp @@ -727,37 +727,41 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control) } } letter = towlower2(letter); + LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1); - // is this a subscript or superscript letter ? - for(ix=0; (c = derived_letters[ix]) != 0; ix+=2) + if(ph_buf[0] == 0) { - if(c > letter) - break; - if(c == letter) + // is this a subscript or superscript letter ? + for(ix=0; (c = derived_letters[ix]) != 0; ix+=2) { - c = derived_letters[ix+1]; - letter = c & 0x3fff; - if((modifier = modifiers[c >> 14]) != NULL) + if(c > letter) + break; + if(c == letter) { - Lookup(tr, modifier, capital); - if(capital[0] == 0) + c = derived_letters[ix+1]; + letter = c & 0x3fff; + if((modifier = modifiers[c >> 14]) != NULL) { - capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2 - Lookup(translator2, modifier, &capital[3]); - if(capital[3] != 0) + Lookup(tr, modifier, capital); + if(capital[0] == 0) { - capital[0] = phonPAUSE; - capital[1] = phonSWITCH; - len = strlen(&capital[3]); - capital[len+3] = phonSWITCH; - capital[len+4] = phontab_1; - capital[len+5] = 0; + capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2 + Lookup(translator2, modifier, &capital[3]); + if(capital[3] != 0) + { + capital[0] = phonPAUSE; + capital[1] = phonSWITCH; + len = strlen(&capital[3]); + capital[len+3] = phonSWITCH; + capital[len+4] = phontab_1; + capital[len+5] = 0; + } } } } } + LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1); } - LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1); if(ph_buf[0] == phonSWITCH) { diff --git a/src/readclause.cpp b/src/readclause.cpp index a667cdb0..4b883ef2 100644 --- a/src/readclause.cpp +++ b/src/readclause.cpp @@ -503,13 +503,13 @@ int towupper2(unsigned int c) return(towupper(c)); // check whether a previous character code is the upper-case equivalent of this character - if(towlower2(c-32) == c) + if(towlower2(c-32) == (int)c) return(c-32); // yes, use it - if(towlower2(c-1) == c) + if(towlower2(c-1) == (int)c) return(c-1); for(ix=0; wchar_toupper[ix] != 0; ix+=2) { - if(wchar_toupper[ix] == c) + if(wchar_toupper[ix] == (int)c) return(wchar_toupper[ix+1]); } return(c); // no diff --git a/src/speak_lib.cpp b/src/speak_lib.cpp index 2a4fcbcf..c0d197c5 100644 --- a/src/speak_lib.cpp +++ b/src/speak_lib.cpp @@ -1167,7 +1167,7 @@ ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream) ESPEAK_API void espeak_TextToPhonemes(const void *text, char *buffer, int size, int textmode, int phonememode) {//============================================================================================================== /* phoneme_mode bits 0-3: 0=only phoneme names, 1=ties, 2=ZWJ, 3=underscore separator - bit 4: 0=eSpeak phoneme names, 1=IPA + bits 4-7: 0=eSpeak phoneme names, 1=IPA */ option_multibyte = textmode & 7; TranslateClause(translator, NULL, text, NULL, NULL); diff --git a/src/speak_lib.h b/src/speak_lib.h index 1cc15bc1..d39dba8c 100644 --- a/src/speak_lib.h +++ b/src/speak_lib.h @@ -55,6 +55,9 @@ Revision 7 24.Dec.2011 Changed espeak_EVENT structure to add id.string[] for phoneme mnemonics. Added espeakINITIALIZE_PHONEME_IPA option for espeak_Initialize() to report phonemes as IPA names. +Revision 8 26.Apr.2013 + Added function espeak_TextToPhonemes(). + */ /********************/ /* Initialization */ @@ -94,7 +97,7 @@ typedef struct { char string[8]; // used for phoneme names (UTF8). Terminated by a zero byte unless the name needs the full 8 bytes. } id; } espeak_EVENT; -/* +/* When a message is supplied to espeak_synth, the request is buffered and espeak_synth returns. When the message is really processed, the callback function will be repetedly called. @@ -102,16 +105,16 @@ typedef struct { In PLAYBACK mode, the callback function is called as soon as an event happens. - For example suppose that the following message is supplied to espeak_Synth: + For example suppose that the following message is supplied to espeak_Synth: "hello, hello." * Once processed in RETRIEVAL mode, it could lead to 3 calls of the callback function : ** Block 1: -