add support for setting the default voice

This adds support for a --default-voice or -V (upper case) command line
option which will set the default voice espeakup uses.  This takes a
name of an espeak voice -- for example:

espeakup --default-voice=en-us

or

espeakup -V en-us
This commit is contained in:
William Hubbs 2009-03-07 14:34:49 -06:00
commit 2351b5d489
2 changed files with 15 additions and 1 deletions

10
cli.c
View file

@ -20,15 +20,20 @@
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;

View file

@ -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);