james: patches to improve usability: - add default voice (-m option is optional now) - add stdout mode (don't have to specify file/pipe) - add raw PCM mode (not enveloped by WAV header) - add continuous read mode (read all lines in the file, not only the first one). note: stdout/raw/continuous mode are linked together. That is, continous output is always done in raw mode and to enable it all you need to do is output to stdout (that is, don't specify -o option). diff -ur flite+hts_engine-1.05/bin/flite_hts_engine.c f/bin/flite_hts_engine.c --- flite+hts_engine-1.05/bin/flite_hts_engine.c 2013-12-24 21:24:01.000000000 +0700 +++ f/bin/flite_hts_engine.c 2014-09-14 11:50:55.029651917 +0700 @@ -50,6 +50,7 @@ #include "flite_hts_engine.h" #define INPUT_BUFF_SIZE 1024 +#define DEFAULT_VOICE "/usr/share/hts/voice/cmu_us_arctic_slt.htsvoice" /* usage: output usage */ static void usage(void) @@ -84,6 +85,7 @@ fprintf(stderr, " -z i : audio buffer size (if i==0, turn off) [ 0][ 0-- ]\n"); fprintf(stderr, " infile:\n"); fprintf(stderr, " text file [stdin]\n"); + fprintf(stderr, "james patch: if -o is not specified, output to stdout in raw, continuous mode.\n"); fprintf(stderr, "\n"); exit(0); @@ -96,15 +98,11 @@ FILE *fp_txt = stdin; char *fn_txt = NULL; char *fn_wav = NULL; - char *fn_voice = NULL; + char *fn_voice = DEFAULT_VOICE; /* Flite+hts_engine */ Flite_HTS_Engine engine; - /* parse command line */ - if (argc == 1) - usage(); - /* initialize engine */ Flite_HTS_Engine_initialize(&engine); @@ -208,8 +206,16 @@ /* synthesis */ if (fn_txt != NULL) fp_txt = fopen(fn_txt, "r"); - if (fgets(buff, INPUT_BUFF_SIZE, fp_txt) != NULL && strlen(buff) > 0) - Flite_HTS_Engine_synthesize(&engine, buff, fn_wav); + if (fn_wav) + { // single-shot wav output + if (fgets(buff, INPUT_BUFF_SIZE, fp_txt) != NULL && strlen(buff) > 0) + Flite_HTS_Engine_synthesize(&engine, buff, fn_wav); + } + else + { // raw continous output (mono, S16_LE, 48khz) + while (fgets(buff, INPUT_BUFF_SIZE, fp_txt) != NULL && strlen(buff) > 0) + Flite_HTS_Engine_synthesize(&engine, buff, fn_wav); + } if (fn_txt != NULL) fclose(fp_txt); diff -ur flite+hts_engine-1.05/lib/flite_hts_engine.c f/lib/flite_hts_engine.c --- flite+hts_engine-1.05/lib/flite_hts_engine.c 2013-12-24 21:24:01.000000000 +0700 +++ f/lib/flite_hts_engine.c 2014-09-14 11:38:23.953039580 +0700 @@ -230,6 +230,8 @@ fp = fopen(wav, "wb"); HTS_Engine_save_riff(&f->engine, fp); fclose(fp); + } else { // raw output to stdout + HTS_Engine_save_generated_speech(&f->engine, stdout); } HTS_Engine_refresh(&f->engine);