speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH 2/3] add list modules option (-O) to say.c


From: Andrei Kholodnyi
Subject: [PATCH 2/3] add list modules option (-O) to say.c
Date: Wed, 13 Oct 2010 19:41:05 +0200

spd_say can now retrieve a list of modules
by calling spd_list_modules
---
 src/clients/say/options.c |    4 ++++
 src/clients/say/options.h |    4 +++-
 src/clients/say/say.c     |   20 +++++++++++++++++++-
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/clients/say/options.c b/src/clients/say/options.c
index 77de4d8..aecfbe5 100644
--- a/src/clients/say/options.c
+++ b/src/clients/say/options.c
@@ -53,6 +53,7 @@ options_print_help(char *argv[])
           "-i, --volume           -     Set the volume (intensity) of the 
speech\n"
            "                               (between -100 and +100, default: 0) 
\n"
           "-o, --output-module    -     Set the output module\n"
+           "-O, --list-output-modules    Get the list of output modules\n"
           "-l, --language         -     Set the language (iso code)\n"
           "-t, --voice-type       -     Set the prefered voice type\n"
            "                               (male1, male2, male3, female1, 
female2\n"
@@ -155,6 +156,9 @@ options_parse(int argc, char *argv[])
         case 'o':
             OPT_SET_STR(output_module);
             break;
+        case 'O':
+            list_output_modules = 1;
+            break;
         case 't':
             OPT_SET_STR(voice_type);
             break;
diff --git a/src/clients/say/options.h b/src/clients/say/options.h
index c5e7226..80f6f47 100644
--- a/src/clients/say/options.h
+++ b/src/clients/say/options.h
@@ -27,6 +27,7 @@ signed int rate;
 signed int pitch;
 signed int volume;
 
+int list_output_modules;
 char *output_module;
 char *language;
 char *voice_type;
@@ -49,6 +50,7 @@ static struct option long_options[] = {
     {"pitch", 1, 0, 'p'},
     {"volume", 1, 0, 'i'},
     {"output-module", 1, 0, 'o'},
+    {"list-output-modules", no_argument, 0, 'O'},
     {"language", 1, 0, 'l'},
     {"voice-type", 1, 0, 't'},
     {"list-synthesis-voices", no_argument, 0, 'L'},
@@ -68,7 +70,7 @@ static struct option long_options[] = {
     {0, 0, 0, 0}
 };
 
-static char* short_options = "r:p:i:l:o:t:Ly:m:sxeP:N:n:wSCvh";
+static char* short_options = "r:p:i:l:o:Ot:Ly:m:sxeP:N:n:wSCvh";
 
 int options_parse(int argc, char *argv[]);
 void options_print_version();
diff --git a/src/clients/say/say.c b/src/clients/say/say.c
index c49dea2..f2813b6 100644
--- a/src/clients/say/say.c
+++ b/src/clients/say/say.c
@@ -69,6 +69,7 @@ int main(int argc, char **argv) {
     stop_previous = 0;
     cancel_previous = 0;
     list_synthesis_voices = 0;
+    list_output_modules = 0;
     synthesis_voice = NULL;
     pipe_mode = 0;
     priority = NULL;
@@ -79,7 +80,8 @@ int main(int argc, char **argv) {
 
     /* Check if the text to say or options are specified in the argument */
     msg_arg_required = (pipe_mode != 1) && (stop_previous != 1)
-                       && (cancel_previous != 1) && (list_synthesis_voices != 
1);
+                       && (cancel_previous != 1) && (list_synthesis_voices != 
1)
+                      && (list_output_modules != 1);
     if ((optind >= argc) && msg_arg_required) {
         options_print_help(argv);
         return 1;
@@ -107,6 +109,22 @@ int main(int argc, char **argv) {
         if(spd_set_output_module(conn, output_module))
             printf("Invalid output module!\n");
 
+    if (list_output_modules) {
+         char **list;
+         int i;
+
+         list = spd_list_modules(conn);
+
+         if (list != NULL) {
+             printf ("OUTPUT MODULES\n");
+             for (i = 0; list[i]; i++) {
+                 printf ("%s\n",list[i]);
+             }
+        } else {
+            printf("Output modules not found.\n");
+        }
+    }
+
     if (voice_type != NULL){
         if (!strcmp(voice_type, "male1")){
             if(spd_set_voice_type(conn, SPD_MALE1))
-- 
1.6.0.4




reply via email to

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