LoadConfig() should be refactored to support both voice and language options set in LoadVoice() and LoadLanguageOptions().master
@@ -34,6 +34,8 @@ | |||
#include "langopts.h" | |||
#include "mnemonics.h" // for MNEM_TAB | |||
#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 "voice.h" // for ReadNumbers, Read8Numbers, ... | |||
@@ -178,6 +180,38 @@ if (CheckTranslator(translator, langopts_tab, key) != 0) { | |||
} | |||
} | |||
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) { | |||
int ix; | |||
@@ -29,6 +29,7 @@ extern "C" | |||
#endif | |||
void LoadLanguageOptions(Translator *translator, int key, char *keyValue); | |||
void LoadConfig(void); | |||
#ifdef __cplusplus | |||
} |
@@ -54,9 +54,10 @@ | |||
#include "espeak_command.h" // for delete_espeak_command, SetParameter | |||
#include "event.h" // for event_declare, event_clear_all, eve... | |||
#include "fifo.h" // for fifo_add_command, fifo_add_commands | |||
#include "langopts.h" // for LoadConfig | |||
#include "mbrola.h" // for mbrola_delay | |||
#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 "translate.h" // for p_decoder, InitText, translator | |||
#include "voice.h" // for FreeVoiceList, VoiceReset, current_... |
@@ -393,38 +393,6 @@ int SelectPhonemeTableName(const char *name) | |||
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) | |||
{ | |||
fprintf(stderr, "Invalid instruction %.4x for phoneme '%s'\n", instn, WordToString(ph->mnemonic)); |
@@ -43,7 +43,6 @@ void InterpretPhoneme2(int phcode, | |||
void FreePhData(void); | |||
unsigned char *GetEnvelope(int index); | |||
espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context); | |||
void LoadConfig(void); | |||
int LookupPhonemeString(const char *string); | |||
int LookupPhonemeTable(const char *name); | |||
frameref_t *LookupSpect(PHONEME_TAB *this_ph, |