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-fd96e6ae7743master
| // letter names, as they are spoken as a single character in text | // letter names, as they are spoken as a single character in text | ||||
| // precede by _ to distinguish from pronunciation as a language word | // precede by _ to distinguish from pronunciation as a language word | ||||
| test h'EloU | |||||
| _a eI | _a eI | ||||
| b bi: | b bi: | ||||
| // combining diacritics | // combining diacritics | ||||
| U+300 grA:v_ | U+300 grA:v_ | ||||
| U+301 a2kju:t_ | |||||
| U+302 s3:kVmflEks_ | |||||
| U+303 tIld@_ | U+303 tIld@_ | ||||
| U+304 makr0n_ | |||||
| U+306 brEv_ | |||||
| U+308 daI@ri:sI2s | |||||
| U+30a rINg_ | U+30a rINg_ | ||||
| U+31e a2pr'0ksIm@nt_ | U+31e a2pr'0ksIm@nt_ | ||||
| U+325 rINg_ | U+325 rINg_ |
| if(match1.points == 0) | if(match1.points == 0) | ||||
| { | { | ||||
| if((wc >= 0x300) && (wc <= 0x36f)) | |||||
| { | |||||
| // combining accent inside a word, ignore | |||||
| } | |||||
| else | |||||
| if(IsAlpha(wc)) | if(IsAlpha(wc)) | ||||
| { | { | ||||
| if((any_alpha > 1) || (p[wc_bytes-1] > ' ')) | if((any_alpha > 1) || (p[wc_bytes-1] > ' ')) |
| "--compile=<voice name>\n" | "--compile=<voice name>\n" | ||||
| "\t Compile the pronunciation rules and dictionary in the current\n" | "\t Compile the pronunciation rules and dictionary in the current\n" | ||||
| "\t directory. =<voice name> is optional and specifies which language\n" | "\t directory. =<voice name> is optional and specifies which language\n" | ||||
| "--path=\"<path>\"\n" | |||||
| "\t Specifies the directory containing the espeak-data directory\n" | |||||
| "--phonout=\"<filename>\"\n" | |||||
| "\t Write output from -x -X commands and mbrola phoneme data to this file\n" | |||||
| "--punct=\"<characters>\"\n" | "--punct=\"<characters>\"\n" | ||||
| "\t Speak the names of punctuation characters during speaking. If\n" | "\t Speak the names of punctuation characters during speaking. If\n" | ||||
| "\t =<characters> is omitted, all punctuation is spoken.\n" | "\t =<characters> is omitted, all punctuation is spoken.\n" | ||||
| {"voices", optional_argument, 0, 0x104}, | {"voices", optional_argument, 0, 0x104}, | ||||
| {"stdout", no_argument, 0, 0x105}, | {"stdout", no_argument, 0, 0x105}, | ||||
| {"split", optional_argument, 0, 0x106}, | {"split", optional_argument, 0, 0x106}, | ||||
| {"path", required_argument, 0, 0x107}, | |||||
| {"phonout", required_argument, 0, 0x108}, | |||||
| {0, 0, 0, 0} | {0, 0, 0, 0} | ||||
| }; | }; | ||||
| FILE *f_text=NULL; | FILE *f_text=NULL; | ||||
| char *p_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 option_index = 0; | ||||
| int c; | int c; | ||||
| samples_split = atoi(optarg); | samples_split = atoi(optarg); | ||||
| break; | 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: | default: | ||||
| exit(0); | exit(0); | ||||
| } | } | ||||
| if(option_waveout || quiet) | if(option_waveout || quiet) | ||||
| { | { | ||||
| // writing to a file (or no output), we can use synchronous mode | // 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; | samples_split = (samplerate * samples_split) * 60; | ||||
| espeak_SetSynthCallback(SynthCallback); | espeak_SetSynthCallback(SynthCallback); | ||||
| else | else | ||||
| { | { | ||||
| // play the sound output | // play the sound output | ||||
| samplerate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK,0,NULL,0); | samplerate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK,0,data_path,0); | ||||
| } | } | ||||
| espeak_SetParameter(espeakLINELENGTH,option_linelength,0); | espeak_SetParameter(espeakLINELENGTH,option_linelength,0); | ||||
| if(option_punctuation == 2) | if(option_punctuation == 2) | ||||
| espeak_SetPunctuationList(option_punctlist); | espeak_SetPunctuationList(option_punctlist); | ||||
| if(option_phonemes >= 0) | espeak_SetPhonemeTrace(option_phonemes,f_phonemes_out); | ||||
| espeak_SetPhonemeTrace(option_phonemes,stderr); | |||||
| if(filename[0]==0) | if(filename[0]==0) | ||||
| { | { |
| "--compile=<voice name>\n" | "--compile=<voice name>\n" | ||||
| "\t Compile the pronunciation rules and dictionary in the current\n" | "\t Compile the pronunciation rules and dictionary in the current\n" | ||||
| "\t directory. =<voice name> is optional and specifies which language\n" | "\t directory. =<voice name> is optional and specifies which language\n" | ||||
| "--path=\"<path>\"\n" | |||||
| "\t Specifies the directory containing the espeak-data directory\n" | |||||
| "--phonout=\"<filename>\"\n" | |||||
| "\t Write output from -x -X commands and mbrola phoneme data to this file\n" | |||||
| "--punct=\"<characters>\"\n" | "--punct=\"<characters>\"\n" | ||||
| "\t Speak the names of punctuation characters during speaking. If\n" | "\t Speak the names of punctuation characters during speaking. If\n" | ||||
| "\t =<characters> is omitted, all punctuation is spoken.\n" | "\t =<characters> is omitted, all punctuation is spoken.\n" | ||||
| 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 | #ifdef PLATFORM_WINDOWS | ||||
| HKEY RegKey; | HKEY RegKey; | ||||
| unsigned long size; | unsigned long size; | ||||
| if((result = LoadPhData()) != 1) | if((result = LoadPhData()) != 1) | ||||
| { | { | ||||
| if(result == -1) | if(result == -1) | ||||
| { | |||||
| fprintf(stderr,"Failed to load espeak-data\n"); | fprintf(stderr,"Failed to load espeak-data\n"); | ||||
| exit(1); | |||||
| } | |||||
| else | 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(); | LoadConfig(); | ||||
| SetVoiceStack(NULL); | SetVoiceStack(NULL); | ||||
| static int optional_argument; | static int optional_argument; | ||||
| static const char *arg_opts = "afklpsvw"; // which options have arguments | static const char *arg_opts = "afklpsvw"; // which options have arguments | ||||
| static char *opt_string=""; | static char *opt_string=""; | ||||
| #define no_argument 0 | #define no_argument 0 | ||||
| #define required_argument 1 | |||||
| #define optional_argument 2 | #define optional_argument 2 | ||||
| #endif | #endif | ||||
| {"voices", optional_argument, 0, 0x104}, | {"voices", optional_argument, 0, 0x104}, | ||||
| {"stdout", no_argument, 0, 0x105}, | {"stdout", no_argument, 0, 0x105}, | ||||
| {"split", optional_argument, 0, 0x106}, | {"split", optional_argument, 0, 0x106}, | ||||
| {"path", required_argument, 0, 0x107}, | |||||
| {"phonout", required_argument, 0, 0x108}, | |||||
| {0, 0, 0, 0} | {0, 0, 0, 0} | ||||
| }; | }; | ||||
| FILE *f_text=NULL; | FILE *f_text=NULL; | ||||
| const char *p_text=NULL; | const char *p_text=NULL; | ||||
| char *data_path = NULL; // use default path for espeak-data | |||||
| int option_index = 0; | int option_index = 0; | ||||
| int c; | int c; | ||||
| option_endpause = 1; | option_endpause = 1; | ||||
| option_phoneme_input = 1; | option_phoneme_input = 1; | ||||
| option_multibyte = espeakCHARS_AUTO; // auto | option_multibyte = espeakCHARS_AUTO; // auto | ||||
| f_trans = stdout; | f_trans = stderr; | ||||
| init_path(argv[0]); | |||||
| #ifdef NEED_GETOPT | #ifdef NEED_GETOPT | ||||
| optind = 1; | optind = 1; | ||||
| DisplayVoices(stdout,optarg2); | DisplayVoices(stdout,optarg2); | ||||
| exit(0); | exit(0); | ||||
| case 0x106: // -- split | case 0x106: // -- split | ||||
| if(optarg2 == NULL) | if(optarg2 == NULL) | ||||
| samples_split = 30; // default 30 minutes | samples_split = 30; // default 30 minutes | ||||
| else | else | ||||
| samples_split = atoi(optarg2); | samples_split = atoi(optarg2); | ||||
| break; | 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: | default: | ||||
| exit(0); | exit(0); | ||||
| } | } | ||||
| } | } | ||||
| init_path(argv[0],data_path); | |||||
| initialise(); | initialise(); | ||||
| if((result = LoadPhData()) != 1) | if((result = LoadPhData()) != 1) | ||||
| { | { | ||||
| if(result == -1) | if(result == -1) | ||||
| { | |||||
| fprintf(stderr,"Failed to load espeak-data\n"); | fprintf(stderr,"Failed to load espeak-data\n"); | ||||
| exit(1); | |||||
| } | |||||
| else | 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)); | memset(&voice_selected,0,sizeof(voice_selected)); | ||||
| option_phonemes = value; | option_phonemes = value; | ||||
| f_trans = stream; | f_trans = stream; | ||||
| if(stream == NULL) | if(stream == NULL) | ||||
| f_trans = stdout; | f_trans = stderr; | ||||
| } // end of espeak_SetPhonemes | } // end of espeak_SetPhonemes | ||||
| #include "translate.h" | #include "translate.h" | ||||
| #include "wave.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; | const int version_phdata = 0x013900; | ||||
| int option_device_number = -1; | int option_device_number = -1; |
| int clause_tone; | int clause_tone; | ||||
| char *voice_change; | char *voice_change; | ||||
| FILE *f_mbrola; | |||||
| static FILE *f_text=NULL; | static FILE *f_text=NULL; | ||||
| static const void *p_text=NULL; | static const void *p_text=NULL; | ||||
| #ifdef USE_MBROLA_LIB | #ifdef USE_MBROLA_LIB | ||||
| MbrolaTranslate(phoneme_list,n_phoneme_list,NULL); | MbrolaTranslate(phoneme_list,n_phoneme_list,NULL); | ||||
| #else | #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 | #endif | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| // increase bass, up to the F1 peak | // increase bass, up to the F1 peak | ||||
| h=1; | h=1; | ||||
| for(f=pitch; f<peaks[1].freq; f+=pitch) | x = peaks[1].height * 24; | ||||
| { | for(f=pitch; f<peaks[1].freq; f+=pitch) | ||||
| htab[h++] += (peaks[1].height * 16); | { | ||||
| } | htab[h++] += x; | ||||
| } | |||||
| // find the nearest harmonic for HF peaks where we don't use shape | // find the nearest harmonic for HF peaks where we don't use shape | ||||
| for(; pk<N_PEAKS; pk++) | for(; pk<N_PEAKS; pk++) |