LoadConfig() should be refactored to support both voice and language options set in LoadVoice() and LoadLanguageOptions().master
| #include "langopts.h" | #include "langopts.h" | ||||
| #include "mnemonics.h" // for MNEM_TAB | #include "mnemonics.h" // for MNEM_TAB | ||||
| #include "translate.h" // for Translator | #include "translate.h" // for Translator | ||||
| #include "soundicon.h" // for soundicon_tab, n_soundicon_tab | |||||
| #include "speech.h" // for path_home, PATHSEP | |||||
| #include "synthdata.h" // for n_tunes, tunes | #include "synthdata.h" // for n_tunes, tunes | ||||
| #include "voice.h" // for ReadNumbers, Read8Numbers, ... | #include "voice.h" // for ReadNumbers, Read8Numbers, ... | ||||
| } | } | ||||
| } | } | ||||
| void LoadConfig(void) { | |||||
| // Load configuration file, if one exists | |||||
| char buf[sizeof(path_home)+10]; | |||||
| FILE *f; | |||||
| int ix; | |||||
| char c1; | |||||
| char string[200]; | |||||
| sprintf(buf, "%s%c%s", path_home, PATHSEP, "config"); | |||||
| if ((f = fopen(buf, "r")) == NULL) | |||||
| return; | |||||
| while (fgets(buf, sizeof(buf), f) != NULL) { | |||||
| if (buf[0] == '/') continue; | |||||
| if (memcmp(buf, "tone", 4) == 0) | |||||
| ReadTonePoints(&buf[5], tone_points); | |||||
| else if (memcmp(buf, "soundicon", 9) == 0) { | |||||
| ix = sscanf(&buf[10], "_%c %s", &c1, string); | |||||
| if (ix == 2) { | |||||
| // add sound file information to soundicon array | |||||
| // the file will be loaded to memory by LoadSoundFile2() | |||||
| soundicon_tab[n_soundicon_tab].name = c1; | |||||
| soundicon_tab[n_soundicon_tab].filename = strdup(string); | |||||
| soundicon_tab[n_soundicon_tab++].length = 0; | |||||
| } | |||||
| } | |||||
| } | |||||
| fclose(f); | |||||
| } | |||||
| static int LookupTune(const char *name) { | static int LookupTune(const char *name) { | ||||
| int ix; | int ix; | ||||
| #endif | #endif | ||||
| void LoadLanguageOptions(Translator *translator, int key, char *keyValue); | void LoadLanguageOptions(Translator *translator, int key, char *keyValue); | ||||
| void LoadConfig(void); | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } |
| #include "espeak_command.h" // for delete_espeak_command, SetParameter | #include "espeak_command.h" // for delete_espeak_command, SetParameter | ||||
| #include "event.h" // for event_declare, event_clear_all, eve... | #include "event.h" // for event_declare, event_clear_all, eve... | ||||
| #include "fifo.h" // for fifo_add_command, fifo_add_commands | #include "fifo.h" // for fifo_add_command, fifo_add_commands | ||||
| #include "langopts.h" // for LoadConfig | |||||
| #include "mbrola.h" // for mbrola_delay | #include "mbrola.h" // for mbrola_delay | ||||
| #include "readclause.h" // for PARAM_STACK, param_stack | #include "readclause.h" // for PARAM_STACK, param_stack | ||||
| #include "synthdata.h" // for FreePhData, LoadConfig, LoadPhData | |||||
| #include "synthdata.h" // for FreePhData, LoadPhData | |||||
| #include "synthesize.h" // for SpeakNextClause, Generate, Synthesi... | #include "synthesize.h" // for SpeakNextClause, Generate, Synthesi... | ||||
| #include "translate.h" // for p_decoder, InitText, translator | #include "translate.h" // for p_decoder, InitText, translator | ||||
| #include "voice.h" // for FreeVoiceList, VoiceReset, current_... | #include "voice.h" // for FreeVoiceList, VoiceReset, current_... |
| return ix; | return ix; | ||||
| } | } | ||||
| void LoadConfig(void) | |||||
| { | |||||
| // Load configuration file, if one exists | |||||
| char buf[sizeof(path_home)+10]; | |||||
| FILE *f; | |||||
| int ix; | |||||
| char c1; | |||||
| char string[200]; | |||||
| sprintf(buf, "%s%c%s", path_home, PATHSEP, "config"); | |||||
| if ((f = fopen(buf, "r")) == NULL) | |||||
| return; | |||||
| while (fgets(buf, sizeof(buf), f) != NULL) { | |||||
| if (buf[0] == '/') continue; | |||||
| if (memcmp(buf, "tone", 4) == 0) | |||||
| ReadTonePoints(&buf[5], tone_points); | |||||
| else if (memcmp(buf, "soundicon", 9) == 0) { | |||||
| ix = sscanf(&buf[10], "_%c %s", &c1, string); | |||||
| if (ix == 2) { | |||||
| // add sound file information to soundicon array | |||||
| // the file will be loaded to memory by LoadSoundFile2() | |||||
| soundicon_tab[n_soundicon_tab].name = c1; | |||||
| soundicon_tab[n_soundicon_tab].filename = strdup(string); | |||||
| soundicon_tab[n_soundicon_tab++].length = 0; | |||||
| } | |||||
| } | |||||
| } | |||||
| fclose(f); | |||||
| } | |||||
| static void InvalidInstn(PHONEME_TAB *ph, int instn) | static void InvalidInstn(PHONEME_TAB *ph, int instn) | ||||
| { | { | ||||
| fprintf(stderr, "Invalid instruction %.4x for phoneme '%s'\n", instn, WordToString(ph->mnemonic)); | fprintf(stderr, "Invalid instruction %.4x for phoneme '%s'\n", instn, WordToString(ph->mnemonic)); |
| void FreePhData(void); | void FreePhData(void); | ||||
| unsigned char *GetEnvelope(int index); | unsigned char *GetEnvelope(int index); | ||||
| espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context); | espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context); | ||||
| void LoadConfig(void); | |||||
| int LookupPhonemeString(const char *string); | int LookupPhonemeString(const char *string); | ||||
| int LookupPhonemeTable(const char *name); | int LookupPhonemeTable(const char *name); | ||||
| frameref_t *LookupSpect(PHONEME_TAB *this_ph, | frameref_t *LookupSpect(PHONEME_TAB *this_ph, |