speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 06/09] replace EVoiceType with SPDVoiceType


From: Andrei Kholodnyi
Subject: [PATCH 06/09] replace EVoiceType with SPDVoiceType
Date: Fri, 1 Oct 2010 23:51:01 +0200

both enums are identical, replace internal EVoiceType enum with
public SPDVoiceType enum

moved SPDVoiceType declaration from libspeechd.h to speechd_types.h
to make it available for internal modules
---
 include/spd_utils.h                 |    4 +-
 include/speechd_types.h             |   22 ++++++++----------
 src/api/c/libspeechd.h              |   12 ----------
 src/common/spd_conv.c               |   40 +++++++++++++++++-----------------
 src/modules/espeak.c                |   30 +++++++++++++-------------
 src/modules/festival.c              |    4 +-
 src/modules/generic.c               |    4 +-
 src/modules/ibmtts.c                |   24 ++++++++++----------
 src/modules/module_utils.h          |    8 +++---
 src/modules/module_utils_addvoice.c |   18 +++++++-------
 src/server/configuration.c          |    4 +-
 src/server/parse.c                  |   17 +++++++-------
 src/server/set.c                    |   18 +++++++-------
 src/server/speechd.h                |    2 +-
 14 files changed, 96 insertions(+), 111 deletions(-)

diff --git a/include/spd_utils.h b/include/spd_utils.h
index 360f55f..6245346 100644
--- a/include/spd_utils.h
+++ b/include/spd_utils.h
@@ -30,8 +30,8 @@
 
 ssize_t spd_getline(char **lineptr, size_t * n, FILE * f);
 
-char* spd_voice2str(EVoiceType voice);
-EVoiceType spd_str2voice(char* str);
+char* spd_voice2str(SPDVoiceType voice);
+SPDVoiceType spd_str2voice(char* str);
 char* spd_punct2str(SPDPunctuation punct);
 SPDPunctuation spd_str2punct(char* str);
 char* spd_spell2str(SPDSpelling spell);
diff --git a/include/speechd_types.h b/include/speechd_types.h
index 6e24a75..b87ec6f 100644
--- a/include/speechd_types.h
+++ b/include/speechd_types.h
@@ -40,18 +40,16 @@ typedef enum {
     SPD_SPELL_ON = 1
 } SPDSpelling;
 
-typedef enum
-    {                  /* Type of voice */
-       NO_VOICE = 0,
-       MALE1 = 1,
-       MALE2 = 2,
-       MALE3 = 3,
-       FEMALE1 = 4,
-       FEMALE2 = 5,
-       FEMALE3 = 6,
-       CHILD_MALE = 7,
-       CHILD_FEMALE = 8
-    }EVoiceType;
+typedef enum {
+    SPD_MALE1 = 1,
+    SPD_MALE2 = 2,
+    SPD_MALE3 = 3,
+    SPD_FEMALE1 = 4,
+    SPD_FEMALE2 = 5,
+    SPD_FEMALE3 = 6,
+    SPD_CHILD_MALE = 7,
+    SPD_CHILD_FEMALE = 8
+} SPDVoiceType;
 
 typedef enum
     {
diff --git a/src/api/c/libspeechd.h b/src/api/c/libspeechd.h
index d58003c..a8fdba7 100644
--- a/src/api/c/libspeechd.h
+++ b/src/api/c/libspeechd.h
@@ -48,18 +48,6 @@ typedef enum{
     SPD_DATA_TEXT = 0,
     SPD_DATA_SSML = 1
 }SPDDataMode;
-    
-typedef enum{
-    SPD_MALE1 = 1,
-    SPD_MALE2 = 2,
-    SPD_MALE3 = 3,
-    SPD_FEMALE1 = 4,
-    SPD_FEMALE2 = 5,
-    SPD_FEMALE3 = 6,
-    SPD_CHILD_MALE = 7,
-    SPD_CHILD_FEMALE = 8
-}SPDVoiceType;
-
 
 typedef struct{
   char *name;   /* Name of the voice (id) */
diff --git a/src/common/spd_conv.c b/src/common/spd_conv.c
index 221e505..dc7ee58 100644
--- a/src/common/spd_conv.c
+++ b/src/common/spd_conv.c
@@ -31,40 +31,40 @@
 #include "spd_utils.h"
 
 char*
-spd_voice2str(EVoiceType voice)
+spd_voice2str(SPDVoiceType voice)
 {
     char *str;
 
     switch (voice)
         {
-        case MALE1: str = strdup("male1"); break;
-        case MALE2: str = strdup("male2"); break;
-        case MALE3: str = strdup("male3"); break;
-        case FEMALE1: str = strdup("female1"); break;
-        case FEMALE2: str = strdup("female2"); break;
-        case FEMALE3: str = strdup("female3"); break;
-        case CHILD_MALE: str = strdup("child_male"); break;
-        case CHILD_FEMALE: str = strdup("child_female"); break;
+        case SPD_MALE1: str = strdup("male1"); break;
+        case SPD_MALE2: str = strdup("male2"); break;
+        case SPD_MALE3: str = strdup("male3"); break;
+        case SPD_FEMALE1: str = strdup("female1"); break;
+        case SPD_FEMALE2: str = strdup("female2"); break;
+        case SPD_FEMALE3: str = strdup("female3"); break;
+        case SPD_CHILD_MALE: str = strdup("child_male"); break;
+        case SPD_CHILD_FEMALE: str = strdup("child_female"); break;
         default: str = NULL;
         }
 
     return str;
 }
 
-EVoiceType
+SPDVoiceType
 spd_str2voice(char* str)
 {
-    EVoiceType voice;
-
-    if (!strcmp(str, "male1")) voice = MALE1;
-    else if (!strcmp(str, "male2")) voice = MALE2;
-    else if (!strcmp(str, "male3")) voice = MALE3;
-    else if (!strcmp(str, "female1")) voice = FEMALE1;
-    else if (!strcmp(str, "female2")) voice = FEMALE2;
-    else if (!strcmp(str, "female3")) voice = FEMALE3;
-    else if (!strcmp(str, "child_male")) voice = CHILD_MALE;
-    else if (!strcmp(str, "child_female")) voice = CHILD_FEMALE;
-    else voice = NO_VOICE;
+    SPDVoiceType voice;
+
+    if (!strcmp(str, "male1")) voice = SPD_MALE1;
+    else if (!strcmp(str, "male2")) voice = SPD_MALE2;
+    else if (!strcmp(str, "male3")) voice = SPD_MALE3;
+    else if (!strcmp(str, "female1")) voice = SPD_FEMALE1;
+    else if (!strcmp(str, "female2")) voice = SPD_FEMALE2;
+    else if (!strcmp(str, "female3")) voice = SPD_FEMALE3;
+    else if (!strcmp(str, "child_male")) voice = SPD_CHILD_MALE;
+    else if (!strcmp(str, "child_female")) voice = SPD_CHILD_FEMALE;
+    else voice = -1;
 
     return voice;
 }
diff --git a/src/modules/espeak.c b/src/modules/espeak.c
index 11ff47f..ea0736a 100644
--- a/src/modules/espeak.c
+++ b/src/modules/espeak.c
@@ -166,8 +166,8 @@ static void espeak_set_pitch_range(signed int pitch_range);
 
 /* Voices and languages */
 static void espeak_set_language(char *lang);
-static void espeak_set_voice(EVoiceType voice);
-static void espeak_set_language_and_voice(char *lang, EVoiceType voice);
+static void espeak_set_voice(SPDVoiceType voice);
+static void espeak_set_language_and_voice(char *lang, SPDVoiceType voice);
 static void espeak_set_synthesis_voice(char *);
 
 /* Internal function prototypes for playback thread. */
@@ -711,40 +711,40 @@ espeak_set_cap_let_recogn(SPDCapitalLetters cap_mode)
 
 /* Given a language code and SD voice code, sets the espeak voice. */
 static void
-espeak_set_language_and_voice(char *lang, EVoiceType voice_code)
+espeak_set_language_and_voice(char *lang, SPDVoiceType voice_code)
 {
        DBG("Espeak: set_language_and_voice %s %d", lang, voice_code);
        espeak_ERROR ret;
     
        unsigned char overlay = 0;
        switch (voice_code) {
-       case NO_VOICE:
+       case SPD_MALE1:
                overlay = 0;
                break;
-       case MALE1:
-               overlay = 0;
-               break;
-       case MALE2:
+       case SPD_MALE2:
                overlay = 1;
                break;
-       case MALE3:
+       case SPD_MALE3:
                overlay = 2;
                break;
-       case FEMALE1:
+       case SPD_FEMALE1:
                overlay = 11;
                break;
-       case FEMALE2:
+       case SPD_FEMALE2:
                overlay = 12;
                break;
-       case FEMALE3:
+       case SPD_FEMALE3:
                overlay = 13;
                break;
-       case CHILD_MALE:
+       case SPD_CHILD_MALE:
                overlay = 4;
                break;
-       case CHILD_FEMALE:
+       case SPD_CHILD_FEMALE:
                overlay = 14;
                break;
+       default:
+               overlay = 0;
+               break;
        }
 
        char *name = g_strdup_printf("%s+%d", lang, overlay);
@@ -760,7 +760,7 @@ espeak_set_language_and_voice(char *lang, EVoiceType 
voice_code)
 }
 
 static void
-espeak_set_voice(EVoiceType voice)
+espeak_set_voice(SPDVoiceType voice)
 {
        assert(msg_settings.language);
        espeak_set_language_and_voice(msg_settings.language, voice);
diff --git a/src/modules/festival.c b/src/modules/festival.c
index a87d857..0a50f35 100644
--- a/src/modules/festival.c
+++ b/src/modules/festival.c
@@ -138,7 +138,7 @@ void festival_parent_clean();
 
 void festival_set_rate(signed int rate);
 void festival_set_pitch(signed int pitch);
-void festival_set_voice(EVoiceType voice);
+void festival_set_voice(SPDVoiceType voice);
 void festival_set_synthesis_voice(char* synthesis_voice);
 void festival_set_language(char* language);
 void festival_set_punctuation_mode(SPDPunctuation punct);
@@ -800,7 +800,7 @@ festival_set_language(char* language)
 }
 
 void
-festival_set_voice(EVoiceType voice)
+festival_set_voice(SPDVoiceType voice)
 {
     char* voice_name;
 
diff --git a/src/modules/generic.c b/src/modules/generic.c
index 12017b6..ed5f2bb 100644
--- a/src/modules/generic.c
+++ b/src/modules/generic.c
@@ -60,7 +60,7 @@ static void generic_child_close(TModuleDoublePipe dpipe);
 
 void generic_set_rate(signed int rate);
 void generic_set_pitch(signed int pitch);
-void generic_set_voice(EVoiceType voice);
+void generic_set_voice(SPDVoiceType voice);
 void generic_set_language(char* language);
 void generic_set_volume(signed int volume);
 void generic_set_punct(SPDPunctuation punct);
@@ -607,7 +607,7 @@ generic_set_language(char *lang)
 }
 
 void
-generic_set_voice(EVoiceType voice)
+generic_set_voice(SPDVoiceType voice)
 {
     assert(generic_msg_language);
     generic_msg_voice_str = module_getvoice(generic_msg_language->code, voice);
diff --git a/src/modules/ibmtts.c b/src/modules/ibmtts.c
index a374143..b68fcf5 100644
--- a/src/modules/ibmtts.c
+++ b/src/modules/ibmtts.c
@@ -250,8 +250,8 @@ static int *ibmtts_voice_index = NULL;
 
 /* Internal function prototypes for main thread. */
 static void ibmtts_set_language(char *lang);
-static void ibmtts_set_voice(EVoiceType voice);
-static void ibmtts_set_language_and_voice(char *lang, EVoiceType voice, char* 
dialect);
+static void ibmtts_set_voice(SPDVoiceType voice);
+static void ibmtts_set_language_and_voice(char *lang, SPDVoiceType voice, 
char* dialect);
 static void ibmtts_set_synthesis_voice(char *);
 static void ibmtts_set_rate(signed int rate);
 static void ibmtts_set_pitch(signed int pitch);
@@ -1118,7 +1118,7 @@ ibmtts_set_punctuation_mode(SPDPunctuation punct_mode)
 
 /* Given a language, dialect and SD voice codes sets the IBM voice */
 static void
-ibmtts_set_language_and_voice(char *lang, EVoiceType voice, char* dialect)
+ibmtts_set_language_and_voice(char *lang, SPDVoiceType voice, char* dialect)
 {
     char *dialect_name = dialect;
     char *voicename = spd_voice2str(voice);
@@ -1169,14 +1169,14 @@ ibmtts_set_language_and_voice(char *lang, EVoiceType 
voice, char* dialect)
     if (NULL == params) {
         DBG("Ibmtts: Setting default VoiceParameters for voice %s", voicename);
         switch (voice) {
-            case MALE1:         eciVoice = 1;   break;  /* Adult Male 1 */
-            case MALE2:         eciVoice = 4;   break;  /* Adult Male 2 */
-            case MALE3:         eciVoice = 5;   break;  /* Adult Male 3 */
-            case FEMALE1:       eciVoice = 2;   break;  /* Adult Female 1 */
-            case FEMALE2:       eciVoice = 6;   break;  /* Adult Female 2 */
-            case FEMALE3:       eciVoice = 7;   break;  /* Elderly Female 1 */
-            case CHILD_MALE:    eciVoice = 3;   break;  /* Child */
-            case CHILD_FEMALE:  eciVoice = 3;   break;  /* Child */
+            case SPD_MALE1:         eciVoice = 1;   break;  /* Adult Male 1 */
+            case SPD_MALE2:         eciVoice = 4;   break;  /* Adult Male 2 */
+            case SPD_MALE3:         eciVoice = 5;   break;  /* Adult Male 3 */
+            case SPD_FEMALE1:       eciVoice = 2;   break;  /* Adult Female 1 
*/
+            case SPD_FEMALE2:       eciVoice = 6;   break;  /* Adult Female 2 
*/
+            case SPD_FEMALE3:       eciVoice = 7;   break;  /* Elderly Female 
1 */
+            case SPD_CHILD_MALE:    eciVoice = 3;   break;  /* Child */
+            case SPD_CHILD_FEMALE:  eciVoice = 3;   break;  /* Child */
             default:            eciVoice = 1;   break;  /* Adult Male 1 */
         }
         ret = eciCopyVoice(eciHandle, eciVoice, 0);
@@ -1208,7 +1208,7 @@ ibmtts_set_language_and_voice(char *lang, EVoiceType 
voice, char* dialect)
 }
 
 static void
-ibmtts_set_voice(EVoiceType voice)
+ibmtts_set_voice(SPDVoiceType voice)
 {
     if (msg_settings.language) {
        ibmtts_set_language_and_voice(msg_settings.language, voice, NULL);
diff --git a/src/modules/module_utils.h b/src/modules/module_utils.h
index efba38a..2ec64c9 100644
--- a/src/modules/module_utils.h
+++ b/src/modules/module_utils.h
@@ -58,7 +58,7 @@ typedef struct{
 
     char* language;
 
-    EVoiceType voice;
+    SPDVoiceType voice;
     char *synthesis_voice;
 }SPDMsgSettings;
 
@@ -87,7 +87,7 @@ int module_num_dc_options;
  msg_settings_old.spelling_mode = -1;\
  msg_settings_old.cap_let_recogn = -1;\
  msg_settings_old.language = NULL;     \
- msg_settings_old.voice = NO_VOICE;\
+ msg_settings_old.voice = -1;\
  msg_settings_old.synthesis_voice = NULL;
 
 #define INIT_SETTINGS_TABLES()\
@@ -99,7 +99,7 @@ int module_num_dc_options;
  msg_settings.spelling_mode = SPD_SPELL_OFF;\
  msg_settings.cap_let_recogn = SPD_CAP_NONE;\
  msg_settings.language = NULL;\
- msg_settings.voice = MALE1;\
+ msg_settings.voice = SPD_MALE1;\
  msg_settings.synthesis_voice = NULL;\
  CLEAN_OLD_SETTINGS_TABLE()
 
@@ -427,6 +427,6 @@ int module_audio_init(char **status_info);
 
 /* Prototypes from module_utils_addvoice.c */
 void module_register_settings_voices(void);
-char* module_getvoice(char* language, EVoiceType voice);
+char* module_getvoice(char* language, SPDVoiceType voice);
 
 #endif /* #ifndef __MODULE_UTILS_H */
diff --git a/src/modules/module_utils_addvoice.c 
b/src/modules/module_utils_addvoice.c
index f828712..42caa40 100644
--- a/src/modules/module_utils_addvoice.c
+++ b/src/modules/module_utils_addvoice.c
@@ -116,7 +116,7 @@ module_register_settings_voices(void)
 }
 
 char*
-module_getvoice(char* language, EVoiceType voice)
+module_getvoice(char* language, SPDVoiceType voice)
 {
     SPDVoiceDef *voices;
     char *ret;
@@ -133,21 +133,21 @@ module_getvoice(char* language, EVoiceType voice)
     }
 
     switch(voice){
-    case MALE1: 
+    case SPD_MALE1:
         ret = voices->male1; break;
-    case MALE2: 
+    case SPD_MALE2:
         ret = voices->male2; break;
-    case MALE3: 
+    case SPD_MALE3:
         ret = voices->male3; break;
-    case FEMALE1: 
+    case SPD_FEMALE1:
         ret = voices->female1; break;
-    case FEMALE2: 
+    case SPD_FEMALE2:
         ret = voices->female2; break;
-    case FEMALE3: 
+    case SPD_FEMALE3:
         ret = voices->female3; break;
-    case CHILD_MALE: 
+    case SPD_CHILD_MALE:
         ret = voices->child_male; break;
-    case CHILD_FEMALE: 
+    case SPD_CHILD_FEMALE:
         ret = voices->child_female; break;
     default:
         printf("Unknown voice");
diff --git a/src/server/configuration.c b/src/server/configuration.c
index a9ade25..0a08beb 100644
--- a/src/server/configuration.c
+++ b/src/server/configuration.c
@@ -188,7 +188,7 @@ GLOBAL_FDSET_OPTION_CB_INT(DefaultSpelling, spelling_mode, 
1, "Invalid spelling
 GLOBAL_FDSET_OPTION_CB_INT(DefaultPauseContext, pause_context, 1, "")
 
 GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultPriority, priority, int, spd_str2prio)
-GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultVoiceType, voice, EVoiceType, 
spd_str2voice)
+GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultVoiceType, voice, SPDVoiceType, 
spd_str2voice)
 GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultPunctuationMode, punctuation_mode, 
SPDPunctuation, spd_str2punct)
 GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultCapLetRecognition, cap_let_recogn, 
SPDCapitalLetters, spd_str2cap)
 
@@ -447,7 +447,7 @@ load_default_global_set_options()
     GlobalFDSet.client_name = g_strdup("unknown:unknown:unknown");
     GlobalFDSet.language = g_strdup("en");
     GlobalFDSet.output_module = NULL;
-    GlobalFDSet.voice = MALE1;
+    GlobalFDSet.voice = SPD_MALE1;
     GlobalFDSet.cap_let_recogn = SPD_CAP_NONE;
     GlobalFDSet.min_delay_progress = 2000;
     GlobalFDSet.pause_context = 0;
diff --git a/src/server/parse.c b/src/server/parse.c
index 24c6594..96dc802 100644
--- a/src/server/parse.c
+++ b/src/server/parse.c
@@ -903,31 +903,30 @@ parse_get(const char *buf, const int bytes, const int fd, 
const TSpeechDSock *sp
 
         switch (settings->voice)
         {
-            case MALE1:
+            case SPD_MALE1:
                 g_string_append_printf(result, C_OK_GET"-MALE1\r\n");
                 break;
-            case MALE2:
+            case SPD_MALE2:
                 g_string_append_printf(result, C_OK_GET"-MALE2\r\n");
                 break;
-            case MALE3:
+            case SPD_MALE3:
                 g_string_append_printf(result, C_OK_GET"-MALE3\r\n");
                 break;
-            case FEMALE1:
+            case SPD_FEMALE1:
                 g_string_append_printf(result, C_OK_GET"-FEMALE1\r\n");
                 break;
-            case FEMALE2:
+            case SPD_FEMALE2:
                 g_string_append_printf(result, C_OK_GET"-FEMALE2\r\n");
                 break;
-            case FEMALE3:
+            case SPD_FEMALE3:
                 g_string_append_printf(result, C_OK_GET"-FEMALE3\r\n");
                 break;
-            case CHILD_MALE:
+            case SPD_CHILD_MALE:
                 g_string_append_printf(result, C_OK_GET"-CHILD_MALE\r\n");
                 break;
-            case CHILD_FEMALE:
+            case SPD_CHILD_FEMALE:
                 g_string_append_printf(result, C_OK_GET"-CHILD_FEMALE\r\n");
                 break;
-            case NO_VOICE:
             default:
                 g_string_append_printf(result, C_OK_GET"-NO_VOICE\r\n");
                 break;
diff --git a/src/server/set.c b/src/server/set.c
index 185b53c..3d2df6f 100644
--- a/src/server/set.c
+++ b/src/server/set.c
@@ -147,14 +147,14 @@ set_voice_uid(int uid, char *voice)
     settings = get_client_settings_by_uid(uid);
     if (settings == NULL) return 1;
 
-    if (!strcmp(voice, "male1")) settings->voice = MALE1;
-    else if (!strcmp(voice, "male2")) settings->voice = MALE2;
-    else if (!strcmp(voice, "male3")) settings->voice = MALE3;
-    else if (!strcmp(voice, "female1")) settings->voice = FEMALE1;
-    else if (!strcmp(voice, "female2")) settings->voice = FEMALE2;
-    else if (!strcmp(voice, "female3")) settings->voice = FEMALE3;
-    else if (!strcmp(voice, "child_male")) settings->voice = CHILD_MALE;
-    else if (!strcmp(voice, "child_female")) settings->voice = CHILD_FEMALE;
+    if (!strcmp(voice, "male1")) settings->voice = SPD_MALE1;
+    else if (!strcmp(voice, "male2")) settings->voice = SPD_MALE2;
+    else if (!strcmp(voice, "male3")) settings->voice = SPD_MALE3;
+    else if (!strcmp(voice, "female1")) settings->voice = SPD_FEMALE1;
+    else if (!strcmp(voice, "female2")) settings->voice = SPD_FEMALE2;
+    else if (!strcmp(voice, "female3")) settings->voice = SPD_FEMALE3;
+    else if (!strcmp(voice, "child_male")) settings->voice = SPD_CHILD_MALE;
+    else if (!strcmp(voice, "child_female")) settings->voice = 
SPD_CHILD_FEMALE;
     else return 1;
 
     if (settings->synthesis_voice != NULL){
@@ -247,7 +247,7 @@ set_synthesis_voice_uid(int uid, char *synthesis_voice)
     SET_PARAM_STR(synthesis_voice);        
 
     /* Delete ordinary voice settings so that we don't mix */
-    settings->voice = NO_VOICE;
+    settings->voice = -1;
 
     return 0;
 }
diff --git a/src/server/speechd.h b/src/server/speechd.h
index 6bf3ca8..d15a7f7 100644
--- a/src/server/speechd.h
+++ b/src/server/speechd.h
@@ -92,7 +92,7 @@ typedef struct{
     char *client_name;         /* Name of the client. */
     char *language;             /* Selected language name. (e.g. "en", "cz", 
"fr", ...) */
     char *output_module;        /* Output module name. (e.g. "festival", 
"flite", "apollo", ...) */
-    EVoiceType voice;           /* see EVoiceType definition above */
+    SPDVoiceType voice;           /* see SPDVoiceType definition above */
     char *synthesis_voice;
     SPDCapitalLetters cap_let_recogn;         /* Capital letters recognition: 
(0 - off, 1 - on) */
 
-- 
1.6.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]