This patch completely dispenses with building flite_VOICE executables for each voice, replacing them all with symlinks to flite itself. The flite itself will now determine the desired voice -- if not explicitly given on command-line -- based on the name of the invoked program (argv[0]). -mi --- main/Makefile 2009-08-14 17:11:07.000000000 -0400 +++ main/Makefile 2014-12-02 01:11:35.000000000 -0500 @@ -116,3 +113,3 @@ do \ - $(INSTALL) $(BINDIR)/flite_$$i $(INSTALLBINDIR); \ + ln -s flite $(INSTALLBINDIR)/flite_$$i; \ done +++ main/flite_main.c 2014-12-02 01:05:49.000000000 -0500 @@ -51,4 +51,18 @@ void cst_alloc_debug_summary(); +/* Return 1 if the big string ends with the small one, 0 otherwise */ +static int +endsWith(const char *big, const char *small) +{ + size_t biglen, smallen; + + biglen = strlen(big); + smallen = strlen(small); + + if (smallen > biglen) + return 0; + return strcmp(big + (biglen - smallen), small) == 0; +} + static void flite_version() { @@ -299,6 +313,27 @@ if (filename == NULL) filename = "-"; /* stdin */ - if (desired_voice == 0) - desired_voice = flite_voice_select(NULL); + if (desired_voice == NULL) { + cst_voice *voice; + const cst_val *val; + const cst_lexicon *lex; + + /* Try to find the voice based on the executable filename */ + for (val = flite_voice_list; val; val = val_cdr(val)) { + voice = val_voice(val_car(val)); + /* First check the name of the voice itself: */ + if (endsWith(argv[0], voice->name)) { + desired_voice = voice; + break; + } + /* Ok, check the name of the voice's lexicon: */ + lex = val_lexicon(feat_val(voice->features, "lexicon")); + if (endsWith(argv[0], lex->name)) { + desired_voice = voice; + break; + } + } + if (desired_voice == NULL) + desired_voice = flite_voice_select(NULL); + } v = desired_voice;