diff --git a/cli.c b/cli.c index 50d61f7..8b5c2a4 100644 --- a/cli.c +++ b/cli.c @@ -20,15 +20,20 @@ #include #include #include +#include #include "espeakup.h" /* program version */ extern const char *Version; +/* default voice */ +extern char *defaultVoice; + /* command line options */ -const char *shortOptions = "dhv"; +const char *shortOptions = "dhV:v"; const struct option longOptions[] = { + {"default-voice", required_argument, NULL, 'V'}, {"debug", no_argument, NULL, 'd'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, @@ -61,6 +66,9 @@ void process_cli(int argc, char **argv) do { opt = getopt_long(argc, argv, shortOptions, longOptions, NULL); switch (opt) { + case 'V': + defaultVoice = strdup(optarg); + break; case 'd': debug = 1; break; diff --git a/espeakup.c b/espeakup.c index 9f1ff05..7b8f8f5 100644 --- a/espeakup.c +++ b/espeakup.c @@ -38,6 +38,7 @@ const int defaultPitch = 5; const int defaultRate = 5; const int defaultVolume = 5; +char *defaultVoice = NULL; int debug = 0; int espeakup_is_running(void) @@ -120,6 +121,11 @@ int main(int argc, char **argv) espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, NULL, 0); /* Setup initial voice parameters */ + if (defaultVoice) { + set_voice(&s, defaultVoice); + free(defaultVoice); + defaultVoice = NULL; + } set_frequency(&s, defaultFrequency, ADJ_SET); set_pitch(&s, defaultPitch, ADJ_SET); set_rate(&s, defaultRate, ADJ_SET);