1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-08-25 21:44:47 -04:00

speech: added flite - the alternative synthesis engine.

Added the document.speech.system option:
0 - festival
1 - flite

Flite is faster and uses less memory than Festival.
This commit is contained in:
Witold Filipczyk 2006-12-26 22:40:22 +01:00 committed by Witold Filipczyk
parent 600b147a72
commit e965d07055
4 changed files with 46 additions and 6 deletions

View File

@ -96,6 +96,9 @@ fi
AC_PATH_PROGS(FESTIVAL, "festival", [/usr/bin/festival]) AC_PATH_PROGS(FESTIVAL, "festival", [/usr/bin/festival])
AC_SUBST(FESTIVAL) AC_SUBST(FESTIVAL)
AC_DEFINE_UNQUOTED(FESTIVAL, "$FESTIVAL", [Festival]) AC_DEFINE_UNQUOTED(FESTIVAL, "$FESTIVAL", [Festival])
AC_PATH_PROGS(FLITE, "flite", [/usr/bin/flite])
AC_SUBST(FLITE)
AC_DEFINE_UNQUOTED(FLITE, "$FLITE", [Flite])
AC_SUBST(ASCIIDOC_FLAGS) AC_SUBST(ASCIIDOC_FLAGS)
AC_SUBST(CONFIG_ASCIIDOC) AC_SUBST(CONFIG_ASCIIDOC)
AC_SUBST(CONFIG_POD2HTML) AC_SUBST(CONFIG_POD2HTML)
@ -1342,6 +1345,7 @@ EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
[ --enable-utf-8 enable UTF-8 support]) [ --enable-utf-8 enable UTF-8 support])
EL_LOG_CONFIG(FESTIVAL, [festival], []) EL_LOG_CONFIG(FESTIVAL, [festival], [])
EL_LOG_CONFIG(FLITE, [flite], [])
AC_ARG_ENABLE(weehoofooboomookerchoo, AC_ARG_ENABLE(weehoofooboomookerchoo,
[ [

View File

@ -744,6 +744,15 @@ static struct option_info config_options_info[] = {
"compress_empty_lines", 0, 0, "compress_empty_lines", 0, 0,
N_("Compress successive empty lines to only one in displayed text.")), N_("Compress successive empty lines to only one in displayed text.")),
INIT_OPT_TREE("document", N_("Speech"),
"speech", 0,
N_("Speech.")),
INIT_OPT_INT("document.speech", N_("Default speech system"),
"system", 0, 0, 1, 0,
N_("Default speech system:\n"
"0 is festival\n"
"1 is flite")),
INIT_OPT_TREE("document", N_("URI passing"), INIT_OPT_TREE("document", N_("URI passing"),
"uri_passing", OPT_SORT | OPT_AUTOCREATE, "uri_passing", OPT_SORT | OPT_AUTOCREATE,

View File

@ -49,6 +49,9 @@ read_from_festival(struct fest *fest)
NULL, NULL, fest); NULL, NULL, fest);
} }
#define FESTIVAL_SYSTEM 0
#define FLITE_SYSTEM 1
static void static void
write_to_festival(struct fest *fest) write_to_festival(struct fest *fest)
{ {
@ -71,7 +74,8 @@ write_to_festival(struct fest *fest)
return; return;
data = doc->data[fest->line].chars; data = doc->data[fest->line].chars;
add_to_string(&buf, "(SayText \""); if (festival.festival_or_flite == FESTIVAL_SYSTEM)
add_to_string(&buf, "(SayText \"");
/* UTF-8 not supported yet. If festival support UTF-8? */ /* UTF-8 not supported yet. If festival support UTF-8? */
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
unsigned char ch = (unsigned char)data[i].data; unsigned char ch = (unsigned char)data[i].data;
@ -80,7 +84,9 @@ write_to_festival(struct fest *fest)
add_char_to_string(&buf, '\\'); add_char_to_string(&buf, '\\');
add_char_to_string(&buf, ch); add_char_to_string(&buf, ch);
} }
add_to_string(&buf, "\")\n"); if (festival.festival_or_flite == FESTIVAL_SYSTEM)
add_to_string(&buf, "\")");
add_char_to_string(&buf, '\n');
w = safe_write(fest->out, buf.source, buf.length); w = safe_write(fest->out, buf.source, buf.length);
if (w >= 0) { if (w >= 0) {
@ -100,8 +106,12 @@ init_festival(void)
int out_pipe[2] = {-1, -1}; int out_pipe[2] = {-1, -1};
pid_t cpid; pid_t cpid;
if (access(FESTIVAL, X_OK)) festival.festival_or_flite = get_opt_int("document.speech.system");
return 1; if (festival.festival_or_flite == FESTIVAL_SYSTEM) {
if (access(FESTIVAL, X_OK)) return 1;
} else {
if (access(FLITE, X_OK)) return 1;
}
if (c_pipe(in_pipe) || c_pipe(out_pipe)) { if (c_pipe(in_pipe) || c_pipe(out_pipe)) {
if (in_pipe[0] >= 0) close(in_pipe[0]); if (in_pipe[0] >= 0) close(in_pipe[0]);
@ -126,8 +136,22 @@ init_festival(void)
close(in_pipe[1]); close(in_pipe[1]);
close(2); close(2);
close_all_non_term_fd(); close_all_non_term_fd();
execl(FESTIVAL, "festival", "-i", NULL); if (festival.festival_or_flite == FESTIVAL_SYSTEM) {
_exit(0); execl(FESTIVAL, "festival", "-i", NULL);
_exit(0);
} else {
char line[1024];
char command[1200];
do {
fgets(line, 1024, stdin);
snprintf(command, 1200, "%s -t \"%s\"", FLITE, line);
system(command);
putchar(' ');
fflush(stdout);
} while (!feof(stdin));
_exit(0);
}
} else { } else {
close(out_pipe[1]); close(out_pipe[1]);
close(in_pipe[0]); close(in_pipe[0]);
@ -139,6 +163,8 @@ init_festival(void)
return 0; return 0;
} }
} }
#undef FESTIVAL_SYSTEM
#undef FLITE_SYSTEM
void void
run_festival(struct session *ses, struct document_view *doc_view) run_festival(struct session *ses, struct document_view *doc_view)

View File

@ -10,6 +10,7 @@ struct fest {
int line; int line;
int in; int in;
int out; int out;
int festival_or_flite;
unsigned int running:1; unsigned int running:1;
}; };