From 04fa12b60cf0a2033b770e1088fbb5c15136495c Mon Sep 17 00:00:00 2001 From: jonsd Date: Sun, 23 Nov 2008 13:46:27 +0000 Subject: [PATCH] [1.39.29] Allow combining accent characters inside a word (don't cause the word to be spelled). Add command line options: --path --phonout git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@204 d46cf337-b52f-0410-862d-fd96e6ae7743 --- dictsource/en_list | 6 ++++++ src/dictionary.cpp | 5 +++++ src/espeak.cpp | 26 ++++++++++++++++++++++---- src/speak.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- src/speak_lib.cpp | 7 +++++-- src/synthdata.cpp | 2 +- src/synthesize.cpp | 5 ++++- src/wavegen.cpp | 13 +++++++------ 8 files changed, 87 insertions(+), 22 deletions(-) diff --git a/dictsource/en_list b/dictsource/en_list index 57780f54..2d2eece8 100644 --- a/dictsource/en_list +++ b/dictsource/en_list @@ -19,6 +19,7 @@ // letter names, as they are spoken as a single character in text // precede by _ to distinguish from pronunciation as a language word +test h'EloU _a eI b bi: @@ -236,7 +237,12 @@ U+2cc s'Ek@ndrIstr,Es // combining diacritics U+300 grA:v_ +U+301 a2kju:t_ +U+302 s3:kVmflEks_ U+303 tIld@_ +U+304 makr0n_ +U+306 brEv_ +U+308 daI@ri:sI2s U+30a rINg_ U+31e a2pr'0ksIm@nt_ U+325 rINg_ diff --git a/src/dictionary.cpp b/src/dictionary.cpp index 793e83b5..e701bb0e 100755 --- a/src/dictionary.cpp +++ b/src/dictionary.cpp @@ -2520,6 +2520,11 @@ int Translator::TranslateRules(char *p_start, char *phonemes, int ph_size, char if(match1.points == 0) { + if((wc >= 0x300) && (wc <= 0x36f)) + { + // combining accent inside a word, ignore + } + else if(IsAlpha(wc)) { if((any_alpha > 1) || (p[wc_bytes-1] > ' ')) diff --git a/src/espeak.cpp b/src/espeak.cpp index c8ccbe71..0f9ced97 100644 --- a/src/espeak.cpp +++ b/src/espeak.cpp @@ -62,6 +62,10 @@ static const char *help_text = "--compile=\n" "\t Compile the pronunciation rules and dictionary in the current\n" "\t directory. = is optional and specifies which language\n" +"--path=\"\"\n" +"\t Specifies the directory containing the espeak-data directory\n" +"--phonout=\"\"\n" +"\t Write output from -x -X commands and mbrola phoneme data to this file\n" "--punct=\"\"\n" "\t Speak the names of punctuation characters during speaking. If\n" "\t = is omitted, all punctuation is spoken.\n" @@ -310,6 +314,8 @@ int main (int argc, char **argv) {"voices", optional_argument, 0, 0x104}, {"stdout", no_argument, 0, 0x105}, {"split", optional_argument, 0, 0x106}, + {"path", required_argument, 0, 0x107}, + {"phonout", required_argument, 0, 0x108}, {0, 0, 0, 0} }; @@ -318,6 +324,8 @@ int main (int argc, char **argv) FILE *f_text=NULL; char *p_text=NULL; + FILE *f_phonemes_out = stderr; + char *data_path = NULL; // use default path for espeak-data int option_index = 0; int c; @@ -468,6 +476,17 @@ int main (int argc, char **argv) samples_split = atoi(optarg); break; + case 0x107: // --path + data_path = optarg; + break; + + case 0x108: // --phonout + if((f_phonemes_out = fopen(optarg,"w")) == NULL) + { + fprintf(stderr,"Can't write to: %s\n",optarg); + } + break; + default: exit(0); } @@ -477,7 +496,7 @@ int main (int argc, char **argv) if(option_waveout || quiet) { // writing to a file (or no output), we can use synchronous mode - samplerate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,NULL,0); + samplerate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,data_path,0); samples_split = (samplerate * samples_split) * 60; espeak_SetSynthCallback(SynthCallback); @@ -501,7 +520,7 @@ int main (int argc, char **argv) else { // play the sound output - samplerate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK,0,NULL,0); + samplerate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK,0,data_path,0); } @@ -538,8 +557,7 @@ int main (int argc, char **argv) espeak_SetParameter(espeakLINELENGTH,option_linelength,0); if(option_punctuation == 2) espeak_SetPunctuationList(option_punctlist); - if(option_phonemes >= 0) - espeak_SetPhonemeTrace(option_phonemes,stderr); + espeak_SetPhonemeTrace(option_phonemes,f_phonemes_out); if(filename[0]==0) { diff --git a/src/speak.cpp b/src/speak.cpp index 1b536cd1..df107121 100755 --- a/src/speak.cpp +++ b/src/speak.cpp @@ -96,6 +96,10 @@ static const char *help_text = "--compile=\n" "\t Compile the pronunciation rules and dictionary in the current\n" "\t directory. = is optional and specifies which language\n" +"--path=\"\"\n" +"\t Specifies the directory containing the espeak-data directory\n" +"--phonout=\"\"\n" +"\t Write output from -x -X commands and mbrola phoneme data to this file\n" "--punct=\"\"\n" "\t Speak the names of punctuation characters during speaking. If\n" "\t = is omitted, all punctuation is spoken.\n" @@ -319,8 +323,15 @@ static int WavegenFile(void) -static void init_path(char *argv0) -{//=============================== +static void init_path(char *argv0, char *path_specified) +{//===================================================== + + if(path_specified) + { + sprintf(path_home,"%s/espeak-data",path_specified); + return; + } + #ifdef PLATFORM_WINDOWS HKEY RegKey; unsigned long size; @@ -397,9 +408,12 @@ static int initialise(void) if((result = LoadPhData()) != 1) { if(result == -1) + { fprintf(stderr,"Failed to load espeak-data\n"); + exit(1); + } else - fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x)\n",result,version_phdata); + fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home); } LoadConfig(); SetVoiceStack(NULL); @@ -433,7 +447,8 @@ static void StopSpeak(int unused) static int optional_argument; static const char *arg_opts = "afklpsvw"; // which options have arguments static char *opt_string=""; -#define no_argument 0 +#define no_argument 0 +#define required_argument 1 #define optional_argument 2 #endif @@ -456,6 +471,8 @@ int main (int argc, char **argv) {"voices", optional_argument, 0, 0x104}, {"stdout", no_argument, 0, 0x105}, {"split", optional_argument, 0, 0x106}, + {"path", required_argument, 0, 0x107}, + {"phonout", required_argument, 0, 0x108}, {0, 0, 0, 0} }; @@ -463,6 +480,7 @@ int main (int argc, char **argv) FILE *f_text=NULL; const char *p_text=NULL; + char *data_path = NULL; // use default path for espeak-data int option_index = 0; int c; @@ -492,9 +510,7 @@ int main (int argc, char **argv) option_endpause = 1; option_phoneme_input = 1; option_multibyte = espeakCHARS_AUTO; // auto - f_trans = stdout; - - init_path(argv[0]); + f_trans = stderr; #ifdef NEED_GETOPT optind = 1; @@ -661,18 +677,31 @@ int main (int argc, char **argv) DisplayVoices(stdout,optarg2); exit(0); - case 0x106: // -- split if(optarg2 == NULL) samples_split = 30; // default 30 minutes else samples_split = atoi(optarg2); break; + + case 0x107: // --path + data_path = optarg2; + break; + + case 0x108: // --phonout + if((f_trans = fopen(optarg2,"w")) == NULL) + { + fprintf(stderr,"Can't write to: %s\n",optarg2); + f_trans = stderr; + } + break; + default: exit(0); } } + init_path(argv[0],data_path); initialise(); diff --git a/src/speak_lib.cpp b/src/speak_lib.cpp index 4d3fd53a..a27cef86 100644 --- a/src/speak_lib.cpp +++ b/src/speak_lib.cpp @@ -342,9 +342,12 @@ static int initialise(void) if((result = LoadPhData()) != 1) { if(result == -1) + { fprintf(stderr,"Failed to load espeak-data\n"); + exit(1); + } else - fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x)\n",result,version_phdata); + fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home); } memset(&voice_selected,0,sizeof(voice_selected)); @@ -1040,7 +1043,7 @@ ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream) option_phonemes = value; f_trans = stream; if(stream == NULL) - f_trans = stdout; + f_trans = stderr; } // end of espeak_SetPhonemes diff --git a/src/synthdata.cpp b/src/synthdata.cpp index 55e2efdd..02e90399 100755 --- a/src/synthdata.cpp +++ b/src/synthdata.cpp @@ -35,7 +35,7 @@ #include "translate.h" #include "wave.h" -const char *version_string = "1.39.28 22.Nov.08"; +const char *version_string = "1.39.29 23.Nov.08"; const int version_phdata = 0x013900; int option_device_number = -1; diff --git a/src/synthesize.cpp b/src/synthesize.cpp index e8e225bc..6840bb9d 100755 --- a/src/synthesize.cpp +++ b/src/synthesize.cpp @@ -1514,6 +1514,7 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control) int clause_tone; char *voice_change; + FILE *f_mbrola; static FILE *f_text=NULL; static const void *p_text=NULL; @@ -1631,7 +1632,9 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control) #ifdef USE_MBROLA_LIB MbrolaTranslate(phoneme_list,n_phoneme_list,NULL); #else - MbrolaTranslate(phoneme_list,n_phoneme_list,stdout); + if((f_mbrola = f_trans) == stderr) + f_mbrola = stdout; + MbrolaTranslate(phoneme_list,n_phoneme_list,f_mbrola); #endif } diff --git a/src/wavegen.cpp b/src/wavegen.cpp index 1e9a41e4..9fd7e9e6 100755 --- a/src/wavegen.cpp +++ b/src/wavegen.cpp @@ -901,12 +901,13 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control) } } -// increase bass, up to the F1 peak -h=1; -for(f=pitch; f