[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/7] replace VoiceDescription with SPDVoice
From: |
Andrei Kholodnyi |
Subject: |
[PATCH 5/7] replace VoiceDescription with SPDVoice |
Date: |
Sat, 23 Oct 2010 20:57:08 +0200 |
both structs are identical, replace internal VoiceDescription struct with
public SPDVoice struct
moved SPDVoice declaration from libspeechd.h to speechd_types.h
to make it available for internal modules
replace dialect to variant where applicable
---
include/speechd_types.h | 13 +++++++------
src/api/c/libspeechd.h | 6 ------
src/modules/cicero.c | 2 +-
src/modules/dummy.c | 2 +-
src/modules/espeak.c | 24 ++++++++++++------------
src/modules/festival.c | 24 ++++++++++++------------
src/modules/flite.c | 2 +-
src/modules/generic.c | 2 +-
src/modules/ibmtts.c | 28 ++++++++++++++--------------
src/modules/ivona.c | 6 +++---
src/modules/module_utils.c | 12 ++++++------
src/modules/module_utils.h | 4 ++--
src/modules/pico.c | 10 +++++-----
src/server/module.h | 2 +-
src/server/output.c | 10 +++++-----
src/server/output.h | 2 +-
src/server/parse.c | 4 ++--
17 files changed, 74 insertions(+), 79 deletions(-)
diff --git a/include/speechd_types.h b/include/speechd_types.h
index b87ec6f..3adbdad 100644
--- a/include/speechd_types.h
+++ b/include/speechd_types.h
@@ -51,6 +51,13 @@ typedef enum {
SPD_CHILD_FEMALE = 8
} SPDVoiceType;
+
+typedef struct {
+ char *name; /* Name of the voice (id) */
+ char *language; /* 2-letter ISO language code */
+ char *variant; /* a not-well defined string describing dialect etc. */
+} SPDVoice;
+
typedef enum
{
SORT_BY_TIME = 0,
@@ -77,10 +84,4 @@ typedef enum
NOTIFY_RESUME = 32
}ENotification;
-typedef struct {
- char* name;
- char* language;
- char* dialect;
-}VoiceDescription;
-
#endif /* not ifndef SPEECHD_TYPES */
diff --git a/src/api/c/libspeechd.h b/src/api/c/libspeechd.h
index afc4f43..c7eecf3 100644
--- a/src/api/c/libspeechd.h
+++ b/src/api/c/libspeechd.h
@@ -49,12 +49,6 @@ typedef enum{
SPD_DATA_SSML = 1
}SPDDataMode;
-typedef struct{
- char *name; /* Name of the voice (id) */
- char *language; /* 2-letter ISO language code */
- char *variant; /* a not-well defined string describing dialect etc. */
-}SPDVoice;
-
typedef enum{
SPD_BEGIN = 1,
SPD_END = 2,
diff --git a/src/modules/cicero.c b/src/modules/cicero.c
index 4ded306..cc9823b 100644
--- a/src/modules/cicero.c
+++ b/src/modules/cicero.c
@@ -235,7 +235,7 @@ module_audio_init(char **status_info){
}
-VoiceDescription**
+SPDVoice**
module_list_voices(void)
{
return NULL;
diff --git a/src/modules/dummy.c b/src/modules/dummy.c
index c9948ac..988ad17 100644
--- a/src/modules/dummy.c
+++ b/src/modules/dummy.c
@@ -98,7 +98,7 @@ module_audio_init(char **status_info){
return 0;
}
-VoiceDescription**
+SPDVoice**
module_list_voices(void)
{
return NULL;
diff --git a/src/modules/espeak.c b/src/modules/espeak.c
index ea0736a..3c46cc9 100644
--- a/src/modules/espeak.c
+++ b/src/modules/espeak.c
@@ -104,7 +104,7 @@ static gboolean espeak_stop_requested = FALSE;
/* > */
static int espeak_sample_rate = 0;
-static VoiceDescription **espeak_voice_list = NULL;
+static SPDVoice **espeak_voice_list = NULL;
/* < The playback queue. */
@@ -144,7 +144,7 @@ static int espeak_voice_pitch_baseline = 50;
static void espeak_state_reset();
static TEspeakSuccess espeak_set_punctuation_list_from_utf8(const char *punct);
-static VoiceDescription** espeak_list_synthesis_voices();
+static SPDVoice** espeak_list_synthesis_voices();
static void espeak_free_voice_list();
/* Callbacks */
@@ -324,7 +324,7 @@ module_audio_init(char **status_info){
}
-VoiceDescription**
+SPDVoice**
module_list_voices(void)
{
return espeak_voice_list;
@@ -1198,10 +1198,10 @@ espeak_play_file(char *filename)
return result;
}
-static VoiceDescription**
+static SPDVoice**
espeak_list_synthesis_voices()
{
- VoiceDescription **result = NULL;
+ SPDVoice **result = NULL;
const espeak_VOICE **espeak_voices = espeak_ListVoices(NULL);
int i = 0;
int j = 0;
@@ -1212,24 +1212,24 @@ espeak_list_synthesis_voices()
numvoices++;
}
DBG("Espeak: %d voices total.", numvoices);
- result = g_new0(VoiceDescription*, numvoices + 1);
+ result = g_new0(SPDVoice*, numvoices + 1);
for (i = j = 0; espeak_voices[i] != NULL; i++) {
const espeak_VOICE *v = espeak_voices[i];
if (!g_str_has_prefix(v->identifier, "mb/")) {
/* Not an mbrola voice */
- VoiceDescription *voice = g_new0(VoiceDescription, 1);
+ SPDVoice *voice = g_new0(SPDVoice, 1);
voice->name = g_strdup(v->name);
const gchar *first_lang = v->languages + 1;
gchar *lang = NULL;
- gchar *dialect = NULL;
+ gchar *variant = NULL;
if (g_utf8_validate(first_lang, -1, NULL)) {
gchar *dash = g_utf8_strchr(first_lang, -1,
'-');
if (dash != NULL) {
- /* There is probably a dialect string
(like en-uk) */
+ /* There is probably a variant string
(like en-uk) */
lang = g_strndup(first_lang, dash -
first_lang);
- dialect =
g_strdup(g_utf8_next_char(dash));
+ variant =
g_strdup(g_utf8_next_char(dash));
} else {
lang = g_strdup(first_lang);
}
@@ -1237,7 +1237,7 @@ espeak_list_synthesis_voices()
DBG("Espeak: Not a valid utf8 string: %s",
first_lang);;
}
voice->language = lang;
- voice->dialect = dialect;
+ voice->variant = variant;
result[j++] = voice;
}
@@ -1256,7 +1256,7 @@ espeak_free_voice_list()
for (i = 0; espeak_voice_list[i] != NULL; i++) {
g_free(espeak_voice_list[i]->name);
g_free(espeak_voice_list[i]->language);
- g_free(espeak_voice_list[i]->dialect);
+ g_free(espeak_voice_list[i]->variant);
g_free(espeak_voice_list[i]);
}
g_free(espeak_voice_list);
diff --git a/src/modules/festival.c b/src/modules/festival.c
index 0e4feed..8285860 100644
--- a/src/modules/festival.c
+++ b/src/modules/festival.c
@@ -55,7 +55,7 @@ int festival_process_pid = 0;
FT_Info *festival_info = NULL;
-VoiceDescription** festival_voice_list = NULL;
+SPDVoice** festival_voice_list = NULL;
enum{
FCT_SOCKET = 0,
@@ -131,7 +131,7 @@ FEST_SET_STR(FestivalSetVoice, "speechd-set-voice")
FEST_SET_SYMB(FestivalSetSynthesisVoice, "speechd-set-festival-voice")
/* Internal functions prototypes */
-static VoiceDescription** festivalGetVoices(FT_Info *info);
+static SPDVoice** festivalGetVoices(FT_Info *info);
void* _festival_speak(void*);
void festival_parent_clean();
@@ -315,7 +315,7 @@ module_audio_init(char **status_info){
return module_audio_init_spd(status_info);
}
-VoiceDescription**
+SPDVoice**
module_list_voices(void)
{
return festival_voice_list;
@@ -508,14 +508,14 @@ module_close(int status)
goto sem_wait; \
}
-static VoiceDescription** festivalGetVoices(FT_Info *info)
+static SPDVoice** festivalGetVoices(FT_Info *info)
{
char *reply;
char** voices;
- char* lang; char* dialect;
+ char* lang; char* variant;
int i, j;
int num_voices = 0;
- VoiceDescription** result;
+ SPDVoice** result;
FEST_SEND_CMD("(apply append (voice-list-language-codes))");
festival_read_response(info, &reply);
@@ -536,7 +536,7 @@ static VoiceDescription** festivalGetVoices(FT_Info *info)
for (i=0; ; i++, num_voices++) if (voices[i] == NULL) break;
num_voices /= 3;
- result = (VoiceDescription**) g_malloc((num_voices +
1)*sizeof(VoiceDescription*));
+ result = g_malloc((num_voices + 1)*sizeof(SPDVoice*));
for (i=0, j=0; ;j++){
if (voices[i] == NULL)
@@ -545,18 +545,18 @@ static VoiceDescription** festivalGetVoices(FT_Info *info)
continue;
else
{
- result[j] = (VoiceDescription*) g_malloc(sizeof(VoiceDescription));
+ result[j] = g_malloc(sizeof(SPDVoice));
result[j]->name = voices[i];
lang = voices[i+1];
if ((lang != NULL) && (strcmp(lang, "nil")))
result[j]->language = g_strdup(lang);
else
result[j]->language = NULL;
- dialect = voices[i+2];
- if ((dialect != NULL) && (strcmp(dialect, "nil")))
- result[j]->dialect = g_strdup(dialect);
+ variant = voices[i+2];
+ if ((variant != NULL) && (strcmp(variant, "nil")))
+ result[j]->variant = g_strdup(variant);
else
- result[j]->dialect=NULL;
+ result[j]->variant=NULL;
i+=3;
}
}
diff --git a/src/modules/flite.c b/src/modules/flite.c
index 249b25e..5bf1247 100644
--- a/src/modules/flite.c
+++ b/src/modules/flite.c
@@ -159,7 +159,7 @@ module_audio_init(char **status_info){
}
-VoiceDescription**
+SPDVoice**
module_list_voices(void)
{
return NULL;
diff --git a/src/modules/generic.c b/src/modules/generic.c
index ed5f2bb..79fae51 100644
--- a/src/modules/generic.c
+++ b/src/modules/generic.c
@@ -179,7 +179,7 @@ module_audio_init(char **status_info){
}
-VoiceDescription**
+SPDVoice**
module_list_voices(void)
{
return NULL;
diff --git a/src/modules/ibmtts.c b/src/modules/ibmtts.c
index f3c6515..3984dee 100644
--- a/src/modules/ibmtts.c
+++ b/src/modules/ibmtts.c
@@ -244,7 +244,7 @@ int ibmtts_voice_speed;
static char *ibmtts_input_encoding = "cp1252";
/* list of voices */
-static VoiceDescription **ibmtts_voice_list = NULL;
+static SPDVoice **ibmtts_voice_list = NULL;
static int *ibmtts_voice_index = NULL;
/* Internal function prototypes for main thread. */
@@ -548,7 +548,7 @@ module_audio_init(char **status_info){
}
-VoiceDescription**
+SPDVoice**
module_list_voices(void)
{
DBG("Ibmtts: %s", __FUNCTION__);
@@ -1137,9 +1137,9 @@ ibmtts_voice_enum_to_str(SPDVoiceType voice)
/* Given a language, dialect and SD voice codes sets the IBM voice */
static void
-ibmtts_set_language_and_voice(char *lang, SPDVoiceType voice, char* dialect)
+ibmtts_set_language_and_voice(char *lang, SPDVoiceType voice, char* variant)
{
- char *dialect_name = dialect;
+ char *variant_name = variant;
char *voicename = ibmtts_voice_enum_to_str(voice);
int eciVoice;
int ret = -1;
@@ -1147,15 +1147,15 @@ ibmtts_set_language_and_voice(char *lang, SPDVoiceType
voice, char* dialect)
DBG("Ibmtts: %s, lang=%s, voice=%d, dialect=%s",
__FUNCTION__, lang, (int)voice,
- dialect ? dialect : NULL);
+ variant ? variant : NULL);
- VoiceDescription **v = ibmtts_voice_list;
+ SPDVoice **v = ibmtts_voice_list;
assert(v);
- if (dialect_name) {
+ if (variant_name) {
for (i=0; v[i]; i++) {
- DBG("%d. dialect=%s", i, v[i]->dialect);
- if (!strcmp(v[i]->dialect, dialect_name)) {
+ DBG("%d. variant=%s", i, v[i]->variant);
+ if (!strcmp(v[i]->variant, variant_name)) {
int j = ibmtts_voice_index[i];
ret = eciSetParam(eciHandle, eciLanguageDialect,
eciLocales[j].langID);
DBG("Ibmtts: set langID=0x%x (ret=%d)", eciLocales[j].langID,
ret);
@@ -1169,7 +1169,7 @@ ibmtts_set_language_and_voice(char *lang, SPDVoiceType
voice, char* dialect)
DBG("%d. language=%s", i, v[i]->language);
if (!strcmp(v[i]->language, lang)) {
int j = ibmtts_voice_index[i];
- dialect_name = v[i]->name;
+ variant_name = v[i]->name;
ret = eciSetParam(eciHandle, eciLanguageDialect,
eciLocales[j].langID);
DBG("Ibmtts: set langID=0x%x (ret=%d)", eciLocales[j].langID,
ret);
ibmtts_input_encoding = eciLocales[j].charset;
@@ -1683,8 +1683,8 @@ alloc_voice_list()
if (eciGetAvailableLanguages(aLanguage, &nLanguages))
return;
- ibmtts_voice_list = g_malloc((nLanguages+1)*sizeof(VoiceDescription*));
- ibmtts_voice_index = g_malloc((nLanguages+1)*sizeof(VoiceDescription*));
+ ibmtts_voice_list = g_malloc((nLanguages+1)*sizeof(SPDVoice*));
+ ibmtts_voice_index = g_malloc((nLanguages+1)*sizeof(SPDVoice*));
if (!ibmtts_voice_list)
return;
@@ -1692,7 +1692,7 @@ alloc_voice_list()
for(i=0; i<nLanguages; i++) {
/* look for the language name */
int j;
- ibmtts_voice_list[i] = g_malloc(sizeof(VoiceDescription));
+ ibmtts_voice_list[i] = g_malloc(sizeof(SPDVoice));
DBG("Ibmtts: aLanguage[%d]=0x%08x", i, aLanguage[i]);
for (j=0; j<MAX_NB_OF_LANGUAGES; j++) {
@@ -1700,7 +1700,7 @@ alloc_voice_list()
if (eciLocales[j].langID == aLanguage[i]) {
ibmtts_voice_list[i]->name = eciLocales[j].name;
ibmtts_voice_list[i]->language = eciLocales[j].lang;
- ibmtts_voice_list[i]->dialect = eciLocales[j].dialect;
+ ibmtts_voice_list[i]->variant = eciLocales[j].dialect;
ibmtts_voice_index[i] = j;
DBG("Ibmtts: alloc_voice_list %s", ibmtts_voice_list[i]->name);
break;
diff --git a/src/modules/ivona.c b/src/modules/ivona.c
index 56e34d8..c739d22 100644
--- a/src/modules/ivona.c
+++ b/src/modules/ivona.c
@@ -174,9 +174,9 @@ module_audio_init(char **status_info){
return module_audio_init_spd(status_info);
}
-static VoiceDescription voice_jacek;
-static VoiceDescription *voice_ivona[]={&voice_jacek,NULL};
-VoiceDescription**
+static SPDVoice voice_jacek;
+static SPDVoice *voice_ivona[]={&voice_jacek,NULL};
+SPDVoice**
module_list_voices(void)
{
voice_jacek.name=IvonaSpeakerName;
diff --git a/src/modules/module_utils.c b/src/modules/module_utils.c
index 76b308c..05fb244 100644
--- a/src/modules/module_utils.c
+++ b/src/modules/module_utils.c
@@ -377,9 +377,9 @@ do_debug(char* cmd_buf)
char *
do_list_voices(void)
{
- VoiceDescription **voices;
+ SPDVoice **voices;
int i;
- char *lang, *dialect;
+ char *lang, *variant;
GString *voice_list;
voices = module_list_voices();
@@ -397,11 +397,11 @@ do_list_voices(void)
lang = "none";
else
lang = voices[i]->language;
- if (voices[i]->dialect==NULL)
- dialect= "none";
+ if (voices[i]->variant==NULL)
+ variant= "none";
else
- dialect = voices[i]->dialect;
- g_string_append_printf(voice_list, "200-%s %s %s\n", voices[i]->name,
lang, dialect);
+ variant = voices[i]->variant;
+ g_string_append_printf(voice_list, "200-%s %s %s\n", voices[i]->name,
lang, variant);
}
/* check whether we found at least one voice */
diff --git a/src/modules/module_utils.h b/src/modules/module_utils.h
index 2ec64c9..cea5aa3 100644
--- a/src/modules/module_utils.h
+++ b/src/modules/module_utils.h
@@ -139,10 +139,10 @@ int module_num_dc_options;
int module_load (void);
int module_init (char **status_info);
int module_audio_init_spd (char **status_info);
-VoiceDescription** module_list_voices(void);
+SPDVoice** module_list_voices(void);
int module_speak (char *data, size_t bytes, EMessageType msgtype);
int module_stop (void);
-VoiceDescription** module_get_voices (void);
+SPDVoice** module_get_voices (void);
size_t module_pause (void);
char* module_is_speaking (void);
void module_close (int status);
diff --git a/src/modules/pico.c b/src/modules/pico.c
index 172204b..96df5de 100644
--- a/src/modules/pico.c
+++ b/src/modules/pico.c
@@ -81,7 +81,7 @@ static const char * picoInternalSgLingware[] = {
"fr-FR_nk0_sg.bin",
"it-IT_cm0_sg.bin" };
-static const VoiceDescription pico_voices[] = {
+static const SPDVoice pico_voices[] = {
{"samantha", "en", "en-US"},
{"serena", "en", "en-GB"},
{"sabrina", "de", "de-DE"},
@@ -90,7 +90,7 @@ static const VoiceDescription pico_voices[] = {
{"silvia", "it", "it-IT"}
};
-static const VoiceDescription *pico_voices_list[] = {
+static const SPDVoice *pico_voices_list[] = {
&pico_voices[0],
&pico_voices[1],
&pico_voices[2],
@@ -409,7 +409,7 @@ int module_init(char **status_info)
}
/* load resource for all language, probably need only one */
- for (i = 0; i < sizeof(pico_voices)/sizeof(VoiceDescription); i++) {
+ for (i = 0; i < sizeof(pico_voices)/sizeof(SPDVoice); i++) {
if (0 != pico_init_voice(i)) {
g_free(pmem);
*status_info = g_strdup_printf(MODULE_NAME
@@ -440,7 +440,7 @@ int module_audio_init(char **status_info)
return module_audio_init_spd(status_info);
}
-VoiceDescription **module_list_voices(void)
+SPDVoice **module_list_voices(void)
{
return pico_voices_list;
}
@@ -477,7 +477,7 @@ static void pico_set_language(char *lang)
int i;
/* get voice name based on language */
- for (i = 0; i < sizeof(pico_voices)/sizeof(VoiceDescription); i++) {
+ for (i = 0; i < sizeof(pico_voices)/sizeof(SPDVoice); i++) {
if (!strcmp(pico_voices[i].language,lang)) {
pico_set_synthesis_voice(pico_voices[i].name);
return;
diff --git a/src/server/module.h b/src/server/module.h
index 8c7578c..b7b5813 100644
--- a/src/server/module.h
+++ b/src/server/module.h
@@ -39,7 +39,7 @@ typedef struct{
int stderr_redirect;
pid_t pid;
int working;
- VoiceDescription **voices;
+ SPDVoice **voices;
}OutputModule;
OutputModule* load_output_module(char* mod_name, char* mod_prog,
diff --git a/src/server/output.c b/src/server/output.c
index 24db70c..bf89aa6 100644
--- a/src/server/output.c
+++ b/src/server/output.c
@@ -283,7 +283,7 @@ output_send_data(char* cmd, OutputModule *output, int wfr)
int
_output_get_voices(OutputModule *module)
{
- VoiceDescription** voice_dscr;
+ SPDVoice** voice_dscr;
GString *reply;
gchar **lines;
gchar **atoms;
@@ -309,7 +309,7 @@ _output_get_voices(OutputModule *module)
//TODO: only 256 voices supported here
lines = g_strsplit(reply->str, "\n", 256);
g_string_free(reply, TRUE);
- voice_dscr = g_malloc(256*sizeof(VoiceDescription*));
+ voice_dscr = g_malloc(256*sizeof(SPDVoice*));
for (i = 0; !errors && (lines[i] != NULL); i++) {
MSG(1, "LINE here:|%s|", lines[i]);
if (strlen(lines[i])<=4){
@@ -327,10 +327,10 @@ _output_get_voices(OutputModule *module)
errors = TRUE;
} else {
//Fill in VoiceDescription
- voice_dscr[i] = (VoiceDescription*) g_malloc(sizeof(VoiceDescription));
+ voice_dscr[i] = g_malloc(sizeof(SPDVoice));
voice_dscr[i]->name=g_strdup(atoms[0]);
voice_dscr[i]->language=g_strdup(atoms[1]);
- voice_dscr[i]->dialect=g_strdup(atoms[2]);
+ voice_dscr[i]->variant=g_strdup(atoms[2]);
}
if (atoms != NULL)
g_strfreev(atoms);
@@ -347,7 +347,7 @@ _output_get_voices(OutputModule *module)
return ret;
}
-VoiceDescription**
+SPDVoice**
output_list_voices(char* module_name)
{
OutputModule *module;
diff --git a/src/server/output.h b/src/server/output.h
index 8c574a3..8d5c44f 100644
--- a/src/server/output.h
+++ b/src/server/output.h
@@ -47,5 +47,5 @@ int output_send_loglevel_setting(OutputModule *output);
int output_module_is_speaking(OutputModule *output, char **index_mark);
int waitpid_with_timeout(pid_t pid, int *status_ptr, int options, size_t
timeout);
int output_close(OutputModule *module);
-VoiceDescription** output_list_voices(char* module_name);
+SPDVoice** output_list_voices(char* module_name);
int _output_get_voices(OutputModule *module);
diff --git a/src/server/parse.c b/src/server/parse.c
index 96dc802..3e4d606 100644
--- a/src/server/parse.c
+++ b/src/server/parse.c
@@ -855,7 +855,7 @@ parse_list(const char* buf, const int bytes, const int fd,
const TSpeechDSock *s
char *module_name;
int uid;
TFDSetElement *settings;
- VoiceDescription **voices;
+ SPDVoice **voices;
GString *result;
int i;
char *helper;
@@ -872,7 +872,7 @@ parse_list(const char* buf, const int bytes, const int fd,
const TSpeechDSock *s
for (i=0; ; i++){
if (voices[i] == NULL) break;
g_string_append_printf(result, C_OK_VOICES"-%s %s %s\r\n",
- voices[i]->name, voices[i]->language,
voices[i]->dialect);
+ voices[i]->name, voices[i]->language,
voices[i]->variant);
}
g_string_append(result, OK_VOICE_LIST_SENT);
helper = result->str;
--
1.6.0.4
[PATCH 1/7] replace EPunctMode with SPDPunctuation, William Hubbs, 2010/10/25