From 5019e658424579816aecacd5cc9d7d55a6be718e Mon Sep 17 00:00:00 2001 From: jonsd Date: Fri, 17 Aug 2007 12:58:34 +0000 Subject: [PATCH] [1.28.05] Changed names of voice variant files (espeak-data/voices/!v). Moves "wisper" and "croak" into voices/!v. Voice variants can now be specified as en+wisper, en+f2 (for female 2), etc. espeak --voices=variant lists the voice variants. Moves some lines from speech.h into other header files. Possible fix for data version check on big-endian. Fixed crash error iin LoadConfig(). Fixed crash in espeakedit: press Tab in enpty Prosody window. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@74 d46cf337-b52f-0410-862d-fd96e6ae7743 --- dictsource/de_list | 3 + espeak-data/voices/!v/!varnt1 | 18 ---- espeak-data/voices/!v/!varnt11 | 16 ---- espeak-data/voices/!v/!varnt12 | 14 --- espeak-data/voices/!v/!varnt13 | 15 --- espeak-data/voices/!v/!varnt14 | 16 ---- espeak-data/voices/!v/!varnt2 | 13 --- espeak-data/voices/!v/!varnt3 | 14 --- espeak-data/voices/!v/!varnt4 | 15 --- espeak-data/voices/!v/!varnt5 | 13 --- espeak-data/voices/!v/!varnt6 | 11 --- espeak-data/voices/en/en-croak | 16 ---- espeak-data/voices/en/en-wisper | 15 --- phsource/ph_hindi | 3 +- src/compiledata.cpp | 4 +- src/espeakedit.cpp | 2 +- src/extras.cpp | 4 +- src/formantdlg.cpp | 3 + src/intonation.cpp | 2 +- src/options.cpp | 1 + src/prosodydisplay.cpp | 9 +- src/readclause.cpp | 2 +- src/setlengths.cpp | 2 +- src/speak.cpp | 2 +- src/speak_lib.cpp | 4 +- src/spect.cpp | 2 +- src/spectdisplay.cpp | 5 +- src/spectseq.cpp | 3 + src/speech.h | 29 +----- src/synthdata.cpp | 14 ++- src/synthesize.cpp | 2 +- src/synthesize.h | 24 +++++ src/translate.cpp | 2 +- src/transldlg.cpp | 2 +- src/voicedlg.cpp | 3 + src/voices.cpp | 134 ++++++++++++++++----------- src/vowelchart.cpp | 4 +- src/wavegen.cpp | 2 +- windows/espeakedit/espeakedit.dsp | 3 +- windows/espeakedit/src/speech.h | 32 ++----- windows/espeakedit/src_copy/speech.h | 32 ++----- windows/windows_cmd/src/speech.h | 30 +----- windows/windows_dll/src/speech.h | 30 +----- windows/windows_sapi/src/speech.h | 30 +----- 44 files changed, 186 insertions(+), 414 deletions(-) delete mode 100755 espeak-data/voices/!v/!varnt1 delete mode 100755 espeak-data/voices/!v/!varnt11 delete mode 100755 espeak-data/voices/!v/!varnt12 delete mode 100644 espeak-data/voices/!v/!varnt13 delete mode 100644 espeak-data/voices/!v/!varnt14 delete mode 100644 espeak-data/voices/!v/!varnt2 delete mode 100644 espeak-data/voices/!v/!varnt3 delete mode 100644 espeak-data/voices/!v/!varnt4 delete mode 100755 espeak-data/voices/!v/!varnt5 delete mode 100755 espeak-data/voices/!v/!varnt6 delete mode 100755 espeak-data/voices/en/en-croak delete mode 100755 espeak-data/voices/en/en-wisper diff --git a/dictsource/de_list b/dictsource/de_list index bb687550..73ac1ca0 100644 --- a/dictsource/de_list +++ b/dictsource/de_list @@ -43,6 +43,9 @@ _— g@d'ank@nSt@-*,IC _#9 t,abu:l'Ato:* _#32 l'e:*ts'aIC@n +// Not Roman numbers +v faU +x Iks // Numbers //======== diff --git a/espeak-data/voices/!v/!varnt1 b/espeak-data/voices/!v/!varnt1 deleted file mode 100755 index e9c0af18..00000000 --- a/espeak-data/voices/!v/!varnt1 +++ /dev/null @@ -1,18 +0,0 @@ -name male1 -gender male 70 - -pitch 74 109 -flutter 4 -roughness 4 - -formant 0 98 95 100 -formant 1 98 95 100 -formant 2 97 95 100 -formant 3 97 100 100 -formant 4 97 100 100 -formant 5 105 100 100 -formant 6 95 100 100 -formant 7 100 100 100 -formant 8 100 100 100 - -stressAdd -10 -10 -20 -20 0 0 40 70 diff --git a/espeak-data/voices/!v/!varnt11 b/espeak-data/voices/!v/!varnt11 deleted file mode 100755 index c42fe6dc..00000000 --- a/espeak-data/voices/!v/!varnt11 +++ /dev/null @@ -1,16 +0,0 @@ -gender female - -pitch 140 200 -flutter 7 -roughness 4 -formant 0 115 80 150 -formant 1 120 70 187 -formant 2 110 70 150 -formant 3 115 70 150 -formant 4 110 70 150 -formant 5 110 90 150 -formant 6 105 80 150 -formant 7 110 70 150 -formant 8 110 70 150 - -stressAdd -10 -10 -20 -20 0 0 40 70 diff --git a/espeak-data/voices/!v/!varnt12 b/espeak-data/voices/!v/!varnt12 deleted file mode 100755 index e9b5d222..00000000 --- a/espeak-data/voices/!v/!varnt12 +++ /dev/null @@ -1,14 +0,0 @@ -gender female - -pitch 140 220 -formant 0 105 80 150 -formant 1 110 80 160 -formant 2 110 70 150 -formant 3 110 70 150 -formant 4 115 70 150 -formant 5 115 70 150 -formant 6 110 70 150 -formant 7 110 70 150 -formant 8 110 70 150 - -stressAdd 0 0 -10 -10 0 0 10 40 diff --git a/espeak-data/voices/!v/!varnt13 b/espeak-data/voices/!v/!varnt13 deleted file mode 100644 index 41f2394d..00000000 --- a/espeak-data/voices/!v/!varnt13 +++ /dev/null @@ -1,15 +0,0 @@ -gender female - -pitch 150 230 -formant 0 105 80 150 -formant 1 110 80 150 -formant 2 120 70 150 -formant 3 125 70 150 -formant 4 125 70 150 -formant 5 125 80 150 -formant 6 120 70 150 -formant 7 110 70 150 -formant 8 110 70 150 - -stressAmp 18 18 20 20 20 20 20 20 -breath 0 5 7 7 7 6 6 5 diff --git a/espeak-data/voices/!v/!varnt14 b/espeak-data/voices/!v/!varnt14 deleted file mode 100644 index 1df9cb44..00000000 --- a/espeak-data/voices/!v/!varnt14 +++ /dev/null @@ -1,16 +0,0 @@ -gender female - -echo 130 15 -pitch 145 200 -formant 0 120 80 150 -formant 1 115 70 160 -formant 2 125 80 150 -formant 3 125 80 150 -formant 4 125 80 150 -formant 5 125 80 150 -formant 6 110 80 150 -formant 7 110 75 150 -formant 8 110 75 150 - -stressAdd -20 -20 -20 -20 0 0 60 90 -stressAmp 18 16 20 20 20 20 20 20 diff --git a/espeak-data/voices/!v/!varnt2 b/espeak-data/voices/!v/!varnt2 deleted file mode 100644 index 6b557033..00000000 --- a/espeak-data/voices/!v/!varnt2 +++ /dev/null @@ -1,13 +0,0 @@ -gender male - -pitch 88 115 -echo 130 15 -formant 0 100 80 120 -formant 1 90 85 120 -formant 2 110 85 120 -formant 3 105 90 120 -formant 4 100 90 120 -formant 5 100 90 120 -formant 6 100 90 120 -formant 7 100 90 120 -formant 8 100 90 120 diff --git a/espeak-data/voices/!v/!varnt3 b/espeak-data/voices/!v/!varnt3 deleted file mode 100644 index aff454ac..00000000 --- a/espeak-data/voices/!v/!varnt3 +++ /dev/null @@ -1,14 +0,0 @@ -gender male - -pitch 80 122 -formant 0 100 100 100 -formant 1 96 97 100 -formant 2 96 97 100 -formant 3 96 103 100 -formant 4 95 103 100 -formant 5 95 103 100 -formant 6 100 100 100 -formant 7 100 100 100 -formant 8 100 100 100 - -stressAdd 10 10 0 0 0 0 -30 -30 diff --git a/espeak-data/voices/!v/!varnt4 b/espeak-data/voices/!v/!varnt4 deleted file mode 100644 index 9c03acac..00000000 --- a/espeak-data/voices/!v/!varnt4 +++ /dev/null @@ -1,15 +0,0 @@ -gender male - -pitch 70 110 - -formant 0 103 100 100 -formant 1 103 100 100 -formant 2 103 100 100 -formant 3 103 100 100 -formant 4 106 100 100 -formant 5 106 100 100 -formant 6 106 100 100 -formant 7 103 100 100 -formant 8 103 100 100 - -stressAdd -10 -10 -30 -30 0 0 60 90 diff --git a/espeak-data/voices/!v/!varnt5 b/espeak-data/voices/!v/!varnt5 deleted file mode 100755 index 20353e1c..00000000 --- a/espeak-data/voices/!v/!varnt5 +++ /dev/null @@ -1,13 +0,0 @@ -gender male - -pitch 90 130 - -formant 0 100 85 130 -formant 1 105 85 130 -formant 2 105 85 130 -formant 3 105 85 130 -formant 4 105 85 130 -formant 5 105 85 130 -formant 6 105 85 150 -formant 7 105 85 150 -formant 8 105 85 150 diff --git a/espeak-data/voices/!v/!varnt6 b/espeak-data/voices/!v/!varnt6 deleted file mode 100755 index d2fcacaa..00000000 --- a/espeak-data/voices/!v/!varnt6 +++ /dev/null @@ -1,11 +0,0 @@ -gender male - -pitch 82 117 - -formant 0 100 90 120 -formant 1 100 90 140 -formant 2 100 70 140 -formant 3 100 75 140 -formant 4 100 80 140 -formant 5 100 80 140 - diff --git a/espeak-data/voices/en/en-croak b/espeak-data/voices/en/en-croak deleted file mode 100755 index b9ef6f7d..00000000 --- a/espeak-data/voices/en/en-croak +++ /dev/null @@ -1,16 +0,0 @@ -pitch 85 117 - -flutter 20 - -formant 0 100 80 110 -formant 1 100 100 100 -formant 2 100 100 100 -formant 3 100 100 100 -formant 4 110 100 100 -formant 5 110 100 100 -formant 6 100 100 100 -formant 7 100 100 100 -formant 8 100 100 100 - - - diff --git a/espeak-data/voices/en/en-wisper b/espeak-data/voices/en/en-wisper deleted file mode 100755 index c07c83c0..00000000 --- a/espeak-data/voices/en/en-wisper +++ /dev/null @@ -1,15 +0,0 @@ -name english-wisper -language en-uk 10 -language en 10 -gender male - -pitch 82 117 - -formant 0 100 0 100 -formant 1 100 80 100 - -flutter 20 - -voicing 17 -breath 75 75 50 40 15 10 -breathw 150 150 200 200 400 400 diff --git a/phsource/ph_hindi b/phsource/ph_hindi index bc796e11..5aaaf9b9 100644 --- a/phsource/ph_hindi +++ b/phsource/ph_hindi @@ -330,12 +330,11 @@ endphoneme phoneme t // dental variant of /t/ vls dnt stop - vowelin f1=1 f2=1500 -300 300 f3=-100 80 amp=18 + vowelin f1=1 f2=1500 -250 250 f3=-100 80 amp=16 vowelout f1=0 f2=1500 -300 250 f3=-100 80 rms=20 lengthmod 2 wave ustop/t_hi%60 before _ ustop/t_dnt%35 -// before _ ustop/t_hi%35 switchvoicing d endphoneme diff --git a/src/compiledata.cpp b/src/compiledata.cpp index f0d2b969..ef90cb14 100755 --- a/src/compiledata.cpp +++ b/src/compiledata.cpp @@ -30,11 +30,11 @@ #include "speak_lib.h" #include "main.h" #include "speech.h" -#include "voice.h" -#include "spect.h" #include "options.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" +#include "spect.h" #define tNUMBER 1 diff --git a/src/espeakedit.cpp b/src/espeakedit.cpp index d41e8841..9de7a2a9 100755 --- a/src/espeakedit.cpp +++ b/src/espeakedit.cpp @@ -33,10 +33,10 @@ #include "speak_lib.h" #include "main.h" #include "speech.h" -#include "voice.h" #include "options.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "spect.h" #include "translate.h" #include "prosodydisplay.h" diff --git a/src/extras.cpp b/src/extras.cpp index 98f694ea..19732a52 100644 --- a/src/extras.cpp +++ b/src/extras.cpp @@ -28,10 +28,10 @@ #include "speak_lib.h" #include "main.h" #include "speech.h" -#include "voice.h" -#include "spect.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" +#include "spect.h" #include "translate.h" #include "options.h" diff --git a/src/formantdlg.cpp b/src/formantdlg.cpp index f71879fd..c0afea4f 100755 --- a/src/formantdlg.cpp +++ b/src/formantdlg.cpp @@ -24,8 +24,11 @@ #include "wx/mdi.h" +#include "speak_lib.h" #include "main.h" #include "speech.h" +#include "phoneme.h" +#include "synthesize.h" #include "voice.h" #include "spect.h" diff --git a/src/intonation.cpp b/src/intonation.cpp index 468c09c2..b71a9bce 100755 --- a/src/intonation.cpp +++ b/src/intonation.cpp @@ -25,9 +25,9 @@ #include "speak_lib.h" #include "speech.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" diff --git a/src/options.cpp b/src/options.cpp index 462b1e57..0d0fab7b 100755 --- a/src/options.cpp +++ b/src/options.cpp @@ -20,6 +20,7 @@ #include "wx/wx.h" #include "wx/fileconf.h" +#include "wx/filename.h" #include #include "speech.h" diff --git a/src/prosodydisplay.cpp b/src/prosodydisplay.cpp index 9ea1a489..3175ae6d 100755 --- a/src/prosodydisplay.cpp +++ b/src/prosodydisplay.cpp @@ -125,7 +125,7 @@ void ProsodyDisplay::SelectPh(int index) if(index < 0) return; p = &phlist[index]; - if(p == NULL) return; + if((p == NULL) || (p->ph == NULL)) return; sprintf(buf,"Stress %d Amp %2d LenMod %2d Pitch %3d %3d [env=%d] Flags %.2x ", p->tone,p->amp,p->length,p->pitch1,p->pitch2,p->env,p->ph->phflags); @@ -293,7 +293,14 @@ void ProsodyDisplay::OnKey(wxKeyEvent& event) p->length++; break; + case WXK_TAB: + display = 0; + event.Skip(); + transldlg->SetFocus(); + break; + default: + display = 0; event.Skip(); break; } diff --git a/src/readclause.cpp b/src/readclause.cpp index db687bdc..5f0acdef 100644 --- a/src/readclause.cpp +++ b/src/readclause.cpp @@ -29,9 +29,9 @@ #include "speak_lib.h" #include "speech.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" #include diff --git a/src/setlengths.cpp b/src/setlengths.cpp index 11520fb8..9ae577d5 100755 --- a/src/setlengths.cpp +++ b/src/setlengths.cpp @@ -25,9 +25,9 @@ #include "speak_lib.h" #include "speech.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" extern int GetAmplitude(void); diff --git a/src/speak.cpp b/src/speak.cpp index f09399db..88d61bb4 100755 --- a/src/speak.cpp +++ b/src/speak.cpp @@ -43,9 +43,9 @@ #include #include "speak_lib.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" diff --git a/src/speak_lib.cpp b/src/speak_lib.cpp index 76794509..f153c4ec 100644 --- a/src/speak_lib.cpp +++ b/src/speak_lib.cpp @@ -36,9 +36,9 @@ #endif #include "speak_lib.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" #include "debug.h" @@ -265,7 +265,7 @@ int GetFileLength(const char *filename) char *Alloc(int size) {//================== char *p; - if((p = (char *)malloc(size+1)) == NULL) + if((p = (char *)malloc(size)) == NULL) fprintf(stderr,"Can't allocate memory\n"); // I was told that size+1 fixes a crash on 64-bit systems return(p); } diff --git a/src/spect.cpp b/src/spect.cpp index 31eec9c4..00cd9faa 100755 --- a/src/spect.cpp +++ b/src/spect.cpp @@ -23,9 +23,9 @@ #include "speak_lib.h" #include "speech.h" #include "main.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "spect.h" #include "options.h" #include "wx/txtstrm.h" diff --git a/src/spectdisplay.cpp b/src/spectdisplay.cpp index 7db051d3..89262e1c 100755 --- a/src/spectdisplay.cpp +++ b/src/spectdisplay.cpp @@ -29,8 +29,11 @@ #include -#include "main.h" +#include "speak_lib.h" #include "speech.h" +#include "main.h" +#include "phoneme.h" +#include "synthesize.h" #include "voice.h" #include "spect.h" #include "options.h" diff --git a/src/spectseq.cpp b/src/spectseq.cpp index e3a0c366..3ca2cceb 100755 --- a/src/spectseq.cpp +++ b/src/spectseq.cpp @@ -21,7 +21,10 @@ #include "wx/wx.h" #include +#include "speak_lib.h" #include "speech.h" +#include "phoneme.h" +#include "synthesize.h" #include "voice.h" #include "spect.h" #include "main.h" diff --git a/src/speech.h b/src/speech.h index 73444c37..14c8f14d 100755 --- a/src/speech.h +++ b/src/speech.h @@ -54,9 +54,6 @@ typedef double DOUBLEX; -#define N_PEAKS 9 -#define N_MARKERS 8 - typedef struct { const char *mnem; @@ -65,32 +62,12 @@ typedef struct { int LookupMnem(MNEM_TAB *table, char *string); -typedef struct { - short pkfreq; - short pkheight; - short pkwidth; - short pkright; -} peak_t; - -typedef struct { - short frflags; - unsigned char length; - unsigned char rms; - short ffreq[9]; - unsigned char fheight[9]; - unsigned char fwidth[6]; // width/4 - unsigned char fright[6]; // width/4 -} frame_t; - - -int GetFileLength(const char *filename); -char *Alloc(int size); -void Free(void *ptr); #define N_PATH_HOME 120 extern char path_home[N_PATH_HOME]; // this is the espeak-data directory -extern const char *version_string; -extern const int version_phdata; extern void strncpy0(char *to,const char *from, int size); +int GetFileLength(const char *filename); +char *Alloc(int size); +void Free(void *ptr); diff --git a/src/synthdata.cpp b/src/synthdata.cpp index b33190cd..0f7ca186 100755 --- a/src/synthdata.cpp +++ b/src/synthdata.cpp @@ -29,13 +29,13 @@ #include "speak_lib.h" #include "speech.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" #include "wave.h" -const char *version_string = "1.28.04 15.Aug.07"; +const char *version_string = "1.28.05 17.Aug.07"; const int version_phdata = 0x012801; int option_device_number = -1; @@ -125,7 +125,13 @@ int LoadPhData() return(-1); wavefile_data = (unsigned char *)spects_data; - version = *((unsigned int *)spects_data); + // read the version number from the first 4 bytes of phondata + version = 0; + for(ix=0; ix<4; ix++) + { + version += (wavefile_data[ix] << (ix*8)); + } + if(version != version_phdata) { result = version; @@ -635,7 +641,7 @@ void LoadConfig(void) if(ix==2) { soundicon_tab[n_soundicon_tab].name = c1; - p = Alloc(strlen(string+1)); + p = Alloc(strlen(string)+1); strcpy(p,string); soundicon_tab[n_soundicon_tab].filename = p; soundicon_tab[n_soundicon_tab++].length = 0; diff --git a/src/synthesize.cpp b/src/synthesize.cpp index efaf669e..eea9c5ac 100755 --- a/src/synthesize.cpp +++ b/src/synthesize.cpp @@ -28,9 +28,9 @@ #include "speak_lib.h" #include "speech.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" #define PITCHfall 0 diff --git a/src/synthesize.h b/src/synthesize.h index 80ebef7f..4e605b53 100755 --- a/src/synthesize.h +++ b/src/synthesize.h @@ -65,6 +65,28 @@ extern int embedded_value[N_EMBEDDED_VALUES]; extern int embedded_default[N_EMBEDDED_VALUES]; +#define N_PEAKS 9 +#define N_MARKERS 8 + +typedef struct { + short pkfreq; + short pkheight; + short pkwidth; + short pkright; +} peak_t; + +typedef struct { + short frflags; + unsigned char length; + unsigned char rms; + short ffreq[9]; + unsigned char fheight[9]; + unsigned char fwidth[6]; // width/4 + unsigned char fright[6]; // width/4 +} frame_t; + + + // formant data used by wavegen typedef struct { int freq; // Hz<<16 @@ -237,6 +259,8 @@ extern int event_list_ix; extern espeak_EVENT *event_list; extern t_espeak_callback* synth_callback; extern int option_log_frames; +extern const char *version_string; +extern const int version_phdata; #define N_SOUNDICON_TAB 100 extern int n_soundicon_tab; diff --git a/src/translate.cpp b/src/translate.cpp index 98bd81b5..0b38270f 100755 --- a/src/translate.cpp +++ b/src/translate.cpp @@ -29,9 +29,9 @@ #include "speak_lib.h" #include "speech.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" #define WORD_STRESS_CHAR '*' diff --git a/src/transldlg.cpp b/src/transldlg.cpp index 7af1ce4e..0173d4db 100755 --- a/src/transldlg.cpp +++ b/src/transldlg.cpp @@ -25,9 +25,9 @@ #include "speak_lib.h" #include "speech.h" #include "phoneme.h" -#include "voice.h" #include "main.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" #include "prosodydisplay.h" diff --git a/src/voicedlg.cpp b/src/voicedlg.cpp index db861428..0d041b86 100755 --- a/src/voicedlg.cpp +++ b/src/voicedlg.cpp @@ -21,8 +21,11 @@ #include "wx/wx.h" +#include "speak_lib.h" #include "main.h" #include "speech.h" +#include "phoneme.h" +#include "synthesize.h" #include "voice.h" #include "spect.h" #include "options.h" diff --git a/src/voices.cpp b/src/voices.cpp index 5c3c9df7..1d5fb35c 100755 --- a/src/voices.cpp +++ b/src/voices.cpp @@ -35,9 +35,9 @@ #endif #include "speak_lib.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #include "translate.h" @@ -306,26 +306,6 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*lea if(n_languages == 0) { -#ifdef deleted -// Read voice variant files -// Don't use this, instead preset the variants_* arrays - - // no language is specified, this voice file only affects the voice characteristics - if(memcmp(leafname,"!variant",8)==0) - { - if(((variant = atoi(&leafname[8])) > 0) && (strlen(variants_either) < N_VOICE_VARIANTS)) - { - char string[2]; - string[0] = variant; - string[1] = 0; - strcat(variants_either,string); - if(gender == 1) - strcat(variants_male,string); - if(gender == 2) - strcat(variants_female,string); - } - } -#endif return(NULL); // no language lines in the voice file } @@ -442,11 +422,17 @@ static void VoiceFormant(char *p) static voice_t *VoiceLookup(char *voicename) {//========================================= +// Keep a cache of previously used voices. int ix; voice_t *v; for(ix=0; ix < N_VOICES; ix++) { + if((ix < n_voices_tab) && (strcmp(voices_tab[ix]->name,voicename)==0)) + { + return(voices_tab[ix]); // found the entry for the specified voice name + } + if(ix == n_voices_tab) { // found a free slot @@ -457,13 +443,8 @@ static voice_t *VoiceLookup(char *voicename) strncpy0(v->name,voicename,sizeof(v->name)); return(v); } - else - if(strcmp(voices_tab[ix]->name,voicename)==0) - { - return(voices_tab[ix]); // found the entry for the specified voice name - } } - return(NULL); // table is full + return(voices_tab[0]); // table is full, reuse the first entry } // end of VoiceLookup @@ -640,6 +621,9 @@ voice_t *LoadVoice(const char *vname, int control) break; sscanf(p,"%s",language_name); + if(strcmp(language_name,"variant")==0) + break; + language_type = strtok(language_name,"-"); language_set = 1; strcpy(translator_name,language_type); @@ -908,24 +892,63 @@ voice_t *LoadVoice(const char *vname, int control) } // end of LoadVoice -voice_t *LoadVoiceVariant(const char *vname, int variant) -{//====================================================== - voice_t *v; - char *p; - char buf[40]; +char *ExtractVoiceVariantName(char *vname, int variant_num) +{//======================================================== +// Remove any voice variant suffix (name or number) from a voice name +// Returns the voice variant name - strcpy(buf,vname); - if((p = strchr(buf,'+')) != NULL) + char *p; + static char variant_name[20]; + + variant_name[0] = 0; + + if((p = strchr(vname,'+')) != NULL) { // The voice name has a +variant suffix - *p = 0; - variant = atoi(p+1); + *p++ = 0; // delete the suffix from the voice name + if(isdigit(*p)) + { + variant_num = atoi(p); // variant number + } + else + { + // voice variant name, not number + strcpy(variant_name,"!v/"); + strncpy0(&variant_name[3],p,sizeof(variant_name)-3); + } } - v = LoadVoice(buf,0); - if((v != NULL) && (variant > 0)) + + if(variant_num > 0) { - sprintf(buf,"!varnt%d",variant); // changed from !variant1 to !varnt1 to avoid 8 char filenames on DOS - v = LoadVoice(buf,2); + if(variant_num < 10) + sprintf(variant_name,"!v/m%d",variant_num); // male + else + sprintf(variant_name,"!v/f%d",variant_num-10); // female + } + + return(variant_name); +} // end of ExtractVoiceVariantName + + + +voice_t *LoadVoiceVariant(const char *vname, int variant_num) +{//========================================================== +// Load a voice file. +// Also apply a voice variant if specified by "variant", or by "+number" or "+name" in the "vname" + + voice_t *v; + char *variant_name; + char buf[60]; + + strncpy0(buf,vname,sizeof(buf)); + variant_name = ExtractVoiceVariantName(buf,variant_num); + + if((v = LoadVoice(buf,0)) == NULL) + return(NULL); + + if(variant_name[0] != 0) + { + v = LoadVoice(variant_name,2); } return(v); } @@ -982,6 +1005,12 @@ static int ScoreVoice(espeak_VOICE *voice_spec, int spec_n_parts, int spec_lang_ } else { + if((*p == 0) && (strcmp(voice_spec->languages,"variants")==0)) + { + // match on a voice with no languages if the required language is "variants" + score = 100; + } + // compare the required language with each of the languages of this voice while(*p != 0) { @@ -1337,6 +1366,7 @@ void GetVoices(const char *path) HANDLE hFind = INVALID_HANDLE_VALUE; DWORD dwError; +#undef UNICODE // we need FindFirstFileA() which takes an 8-bit c-string sprintf(fname,"%s\\*",path); hFind = FindFirstFile(fname, &FindFileData); if(hFind == INVALID_HANDLE_VALUE) @@ -1420,21 +1450,14 @@ espeak_ERROR SetVoiceByName(const char *name) {//========================================= espeak_VOICE *v; espeak_VOICE voice_selector; - int variant=0; - char *p; - char variant_name[20]; + char *variant_name; static char buf[60]; strncpy0(buf,name,sizeof(buf)); - if((p = strchr(buf,'+')) != NULL) - { - // remove the voice variant suffix, from eg. en+3 - *p = 0; - variant = atoi(p+1); - } + variant_name = ExtractVoiceVariantName(buf,0); memset(&voice_selector,0,sizeof(voice_selector)); - voice_selector.name = (char *)name; + voice_selector.name = buf; // first check for a voice with this filename // This may avoid the need to call espeak_ListVoices(). @@ -1443,10 +1466,8 @@ espeak_ERROR SetVoiceByName(const char *name) { voice_selected = first_voice; - if(variant > 0) + if(variant_name[0] != 0) { - // apply a voice variant - sprintf(variant_name,"!varnt%d",variant); LoadVoice(variant_name,2); } @@ -1460,9 +1481,14 @@ espeak_ERROR SetVoiceByName(const char *name) if((v = SelectVoiceByName(voices_list,buf)) != NULL) { - if(LoadVoiceVariant(v->identifier,variant) != NULL) + if(LoadVoice(v->identifier,0) != NULL) { voice_selected = v; + + if(variant_name[0] != 0) + { + LoadVoice(variant_name,2); + } WavegenSetVoice(voice); SetVoiceStack(&voice_selector); return(EE_OK); diff --git a/src/vowelchart.cpp b/src/vowelchart.cpp index 8a22e177..39ee1e0b 100644 --- a/src/vowelchart.cpp +++ b/src/vowelchart.cpp @@ -30,10 +30,10 @@ #include "speak_lib.h" #include "main.h" #include "speech.h" -#include "voice.h" -#include "spect.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" +#include "spect.h" #include "translate.h" #include "options.h" diff --git a/src/wavegen.cpp b/src/wavegen.cpp index 11d11f6b..b1cc5361 100755 --- a/src/wavegen.cpp +++ b/src/wavegen.cpp @@ -30,9 +30,9 @@ #include "speak_lib.h" #include "speech.h" -#include "voice.h" #include "phoneme.h" #include "synthesize.h" +#include "voice.h" #ifdef USE_PORTAUDIO #include "portaudio.h" diff --git a/windows/espeakedit/espeakedit.dsp b/windows/espeakedit/espeakedit.dsp index 0ecd3fa4..e0bcfe67 100755 --- a/windows/espeakedit/espeakedit.dsp +++ b/windows/espeakedit/espeakedit.dsp @@ -380,6 +380,7 @@ LINK32=link.exe # PROP Use_Debug_Libraries 1 # PROP Output_Dir "vc_mswud" # PROP Intermediate_Dir "vc_mswud\minimal" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W4 /Gm /GR /Zi /Od /I ".\..\..\lib\vc_lib\mswud" /I ".\..\..\include" /I "." /I ".\..\..\samples" /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "_WINDOWS" /D "NOPCH" /Fd"vc_mswud\minimal.pdb" /FD /GZ /EHsc /c # ADD CPP /nologo /MDd /W4 /Gm /GR /Zi /Od /I ".\..\..\lib\vc_lib\mswud" /I ".\..\..\include" /I "." /I ".\..\..\samples" /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "_WINDOWS" /D "NOPCH" /Fd"vc_mswud\minimal.pdb" /FD /GZ /EHsc /c @@ -392,7 +393,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 wxmsw28ud_core.lib wxbase28ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib /nologo /subsystem:windows /debug /machine:I386 /libpath:".\..\..\lib\vc_lib" -# ADD LINK32 wxmsw28ud_core.lib wxbase28ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib /nologo /subsystem:windows /debug /machine:I386 /libpath:".\..\..\lib\vc_lib" +# ADD LINK32 wxmsw28ud_core.lib wxbase28ud.lib wxmsw28ud_adv.lib winmm.lib PAStaticWMME.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib PAStaticWMME.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib /nologo /subsystem:windows /debug /machine:I386 /libpath:".\..\..\lib\vc_lib" !ELSEIF "$(CFG)" == "minimal - Win32 Release" diff --git a/windows/espeakedit/src/speech.h b/windows/espeakedit/src/speech.h index 667b3f79..8b81cfe0 100755 --- a/windows/espeakedit/src/speech.h +++ b/windows/espeakedit/src/speech.h @@ -21,8 +21,6 @@ #define LOG_FRAMES // write keyframe info to src/log -#define N_PEAKS 9 -#define N_MARKERS 8 // comment this out when compiling the "speak" process //#define SPECT_EDITOR @@ -43,6 +41,9 @@ typedef unsigned short USHORT; typedef unsigned char UCHAR; typedef double DOUBLEX; + + + typedef struct { const char *mnem; int value; @@ -50,31 +51,12 @@ typedef struct { int LookupMnem(MNEM_TAB *table, char *string); -typedef struct { - short pkfreq; - short pkheight; - short pkwidth; - short pkright; -} peak_t; - -typedef struct { - short frflags; - unsigned char length; - unsigned char rms; - short ffreq[9]; - unsigned char fheight[9]; - unsigned char fwidth[6]; // width/4 - unsigned char fright[6]; // width/4 -} frame_t; - - -int GetFileLength(const char *filename); -char *Alloc(int size); -void Free(void *ptr); #define N_PATH_HOME 120 extern char path_home[N_PATH_HOME]; // this is the espeak-data directory -extern const char *version_string; -extern const int version_phdata; extern void strncpy0(char *to,const char *from, int size); +int GetFileLength(const char *filename); +char *Alloc(int size); +void Free(void *ptr); + diff --git a/windows/espeakedit/src_copy/speech.h b/windows/espeakedit/src_copy/speech.h index 667b3f79..8b81cfe0 100755 --- a/windows/espeakedit/src_copy/speech.h +++ b/windows/espeakedit/src_copy/speech.h @@ -21,8 +21,6 @@ #define LOG_FRAMES // write keyframe info to src/log -#define N_PEAKS 9 -#define N_MARKERS 8 // comment this out when compiling the "speak" process //#define SPECT_EDITOR @@ -43,6 +41,9 @@ typedef unsigned short USHORT; typedef unsigned char UCHAR; typedef double DOUBLEX; + + + typedef struct { const char *mnem; int value; @@ -50,31 +51,12 @@ typedef struct { int LookupMnem(MNEM_TAB *table, char *string); -typedef struct { - short pkfreq; - short pkheight; - short pkwidth; - short pkright; -} peak_t; - -typedef struct { - short frflags; - unsigned char length; - unsigned char rms; - short ffreq[9]; - unsigned char fheight[9]; - unsigned char fwidth[6]; // width/4 - unsigned char fright[6]; // width/4 -} frame_t; - - -int GetFileLength(const char *filename); -char *Alloc(int size); -void Free(void *ptr); #define N_PATH_HOME 120 extern char path_home[N_PATH_HOME]; // this is the espeak-data directory -extern const char *version_string; -extern const int version_phdata; extern void strncpy0(char *to,const char *from, int size); +int GetFileLength(const char *filename); +char *Alloc(int size); +void Free(void *ptr); + diff --git a/windows/windows_cmd/src/speech.h b/windows/windows_cmd/src/speech.h index 2373977a..f0cc4624 100755 --- a/windows/windows_cmd/src/speech.h +++ b/windows/windows_cmd/src/speech.h @@ -41,9 +41,6 @@ typedef double DOUBLEX; -#define N_PEAKS 9 -#define N_MARKERS 7 - typedef struct { const char *mnem; @@ -52,33 +49,12 @@ typedef struct { int LookupMnem(MNEM_TAB *table, char *string); -typedef struct { - short pkfreq; - short pkheight; - short pkwidth; - short pkright; -} peak_t; - -typedef struct { - short frflags; - unsigned char length; - unsigned char rms; - short ffreq[9]; - unsigned char fheight[9]; - unsigned char fwidth[6]; // width/4 - unsigned char fright[6]; // width/4 -} frame_t; - - -int GetFileLength(const char *filename); -char *Alloc(int size); -void Free(void *ptr); - #define N_PATH_HOME 120 extern char path_home[N_PATH_HOME]; // this is the espeak-data directory -extern const char *version_string; -extern const int version_phdata; extern void strncpy0(char *to,const char *from, int size); +int GetFileLength(const char *filename); +char *Alloc(int size); +void Free(void *ptr); diff --git a/windows/windows_dll/src/speech.h b/windows/windows_dll/src/speech.h index f0a03978..d70dace4 100755 --- a/windows/windows_dll/src/speech.h +++ b/windows/windows_dll/src/speech.h @@ -42,9 +42,6 @@ typedef double DOUBLEX; -#define N_PEAKS 9 -#define N_MARKERS 7 - typedef struct { const char *mnem; @@ -53,33 +50,12 @@ typedef struct { int LookupMnem(MNEM_TAB *table, char *string); -typedef struct { - short pkfreq; - short pkheight; - short pkwidth; - short pkright; -} peak_t; - -typedef struct { - short frflags; - unsigned char length; - unsigned char rms; - short ffreq[9]; - unsigned char fheight[9]; - unsigned char fwidth[6]; // width/4 - unsigned char fright[6]; // width/4 -} frame_t; - - -int GetFileLength(const char *filename); -char *Alloc(int size); -void Free(void *ptr); - #define N_PATH_HOME 120 extern char path_home[N_PATH_HOME]; // this is the espeak-data directory -extern const char *version_string; -extern const int version_phdata; extern void strncpy0(char *to,const char *from, int size); +int GetFileLength(const char *filename); +char *Alloc(int size); +void Free(void *ptr); diff --git a/windows/windows_sapi/src/speech.h b/windows/windows_sapi/src/speech.h index 217c0936..6d9e344b 100755 --- a/windows/windows_sapi/src/speech.h +++ b/windows/windows_sapi/src/speech.h @@ -46,9 +46,6 @@ typedef double DOUBLEX; -#define N_PEAKS 9 -#define N_MARKERS 7 - typedef struct { const char *mnem; @@ -57,33 +54,12 @@ typedef struct { int LookupMnem(MNEM_TAB *table, char *string); -typedef struct { - short pkfreq; - short pkheight; - short pkwidth; - short pkright; -} peak_t; - -typedef struct { - short frflags; - unsigned char length; - unsigned char rms; - short ffreq[9]; - unsigned char fheight[9]; - unsigned char fwidth[6]; // width/4 - unsigned char fright[6]; // width/4 -} frame_t; - - -int GetFileLength(const char *filename); -char *Alloc(int size); -void Free(void *ptr); - #define N_PATH_HOME 120 extern char path_home[N_PATH_HOME]; // this is the espeak-data directory -extern const char *version_string; -extern const int version_phdata; extern void strncpy0(char *to,const char *from, int size); +int GetFileLength(const char *filename); +char *Alloc(int size); +void Free(void *ptr);