mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Added espeak as another speech synthesis engine.
This commit is contained in:
parent
322b003e22
commit
0da23da6b2
@ -93,11 +93,14 @@ if test "x$CONFIG_DOC" != xno; then
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROGS(ESPEAK, "speak", [/usr/bin/speak])
|
||||
AC_PATH_PROGS(FESTIVAL, "festival", [/usr/bin/festival])
|
||||
AC_SUBST(FESTIVAL)
|
||||
AC_DEFINE_UNQUOTED(FESTIVAL, "$FESTIVAL", [Festival])
|
||||
AC_PATH_PROGS(FLITE, "flite", [/usr/bin/flite])
|
||||
AC_SUBST(ESPEAK)
|
||||
AC_SUBST(FESTIVAL)
|
||||
AC_SUBST(FLITE)
|
||||
AC_DEFINE_UNQUOTED(ESPEAK, "$ESPEAK", [Espeak])
|
||||
AC_DEFINE_UNQUOTED(FESTIVAL, "$FESTIVAL", [Festival])
|
||||
AC_DEFINE_UNQUOTED(FLITE, "$FLITE", [Flite])
|
||||
AC_SUBST(ASCIIDOC_FLAGS)
|
||||
AC_SUBST(CONFIG_ASCIIDOC)
|
||||
|
@ -755,10 +755,11 @@ static struct option_info config_options_info[] = {
|
||||
N_("Speech.")),
|
||||
|
||||
INIT_OPT_INT("document.speech", N_("Default speech system"),
|
||||
"system", 0, 0, 1, 0,
|
||||
"system", 0, 0, 2, 0,
|
||||
N_("Default speech system:\n"
|
||||
"0 is festival\n"
|
||||
"1 is flite")),
|
||||
"1 is flite\n"
|
||||
"2 is espeak")),
|
||||
|
||||
INIT_OPT_TREE("document", N_("URI passing"),
|
||||
"uri_passing", OPT_SORT | OPT_AUTOCREATE,
|
||||
|
@ -52,6 +52,7 @@ read_from_festival(struct fest *fest)
|
||||
|
||||
#define FESTIVAL_SYSTEM 0
|
||||
#define FLITE_SYSTEM 1
|
||||
#define ESPEAK_SYSTEM 2
|
||||
|
||||
static void
|
||||
write_to_festival(struct fest *fest)
|
||||
@ -75,7 +76,7 @@ write_to_festival(struct fest *fest)
|
||||
return;
|
||||
|
||||
data = doc->data[fest->line].chars;
|
||||
if (festival.festival_or_flite == FESTIVAL_SYSTEM) {
|
||||
if (festival.speech_system == FESTIVAL_SYSTEM) {
|
||||
add_to_string(&buf, "(SayText \"");
|
||||
/* UTF-8 not supported yet. Does festival support UTF-8? */
|
||||
for (i = 0; i < len; i++) {
|
||||
@ -113,11 +114,18 @@ init_festival(void)
|
||||
int out_pipe[2] = {-1, -1};
|
||||
pid_t cpid;
|
||||
|
||||
festival.festival_or_flite = get_opt_int("document.speech.system");
|
||||
if (festival.festival_or_flite == FESTIVAL_SYSTEM) {
|
||||
festival.speech_system = get_opt_int("document.speech.system");
|
||||
switch (festival.speech_system) {
|
||||
case FESTIVAL_SYSTEM:
|
||||
default:
|
||||
if (access(FESTIVAL, X_OK)) return 1;
|
||||
} else {
|
||||
break;
|
||||
case FLITE_SYSTEM:
|
||||
if (access(FLITE, X_OK)) return 1;
|
||||
break;
|
||||
case ESPEAK_SYSTEM:
|
||||
if (access(ESPEAK, X_OK)) return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c_pipe(in_pipe) || c_pipe(out_pipe)) {
|
||||
@ -137,31 +145,40 @@ init_festival(void)
|
||||
return 1;
|
||||
}
|
||||
if (!cpid) {
|
||||
unsigned char *program;
|
||||
|
||||
dup2(out_pipe[1], 1);
|
||||
dup2(in_pipe[0], 0);
|
||||
close(out_pipe[0]);
|
||||
close(in_pipe[1]);
|
||||
close(2);
|
||||
close_all_non_term_fd();
|
||||
if (festival.festival_or_flite == FESTIVAL_SYSTEM) {
|
||||
switch (festival.speech_system) {
|
||||
case FESTIVAL_SYSTEM:
|
||||
default:
|
||||
execl(FESTIVAL, "festival", "-i", NULL);
|
||||
_exit(0);
|
||||
} else {
|
||||
do {
|
||||
char line[1024];
|
||||
FILE *out;
|
||||
|
||||
fgets(line, 1024, stdin);
|
||||
out = popen(FLITE, "w");
|
||||
if (out) {
|
||||
fputs(line, out);
|
||||
pclose(out);
|
||||
putchar(' ');
|
||||
fflush(stdout);
|
||||
}
|
||||
} while (!feof(stdin));
|
||||
_exit(0);
|
||||
case FLITE_SYSTEM:
|
||||
program = FLITE;
|
||||
break;
|
||||
case ESPEAK_SYSTEM:
|
||||
program = ESPEAK;
|
||||
break;
|
||||
}
|
||||
do {
|
||||
char line[1024];
|
||||
FILE *out;
|
||||
|
||||
fgets(line, 1024, stdin);
|
||||
out = popen(program, "w");
|
||||
if (out) {
|
||||
fputs(line, out);
|
||||
pclose(out);
|
||||
putchar(' ');
|
||||
fflush(stdout);
|
||||
}
|
||||
} while (!feof(stdin));
|
||||
_exit(0);
|
||||
} else {
|
||||
close(out_pipe[1]);
|
||||
close(in_pipe[0]);
|
||||
@ -175,6 +192,7 @@ init_festival(void)
|
||||
}
|
||||
#undef FESTIVAL_SYSTEM
|
||||
#undef FLITE_SYSTEM
|
||||
#undef ESPEAK_SYSTEM
|
||||
|
||||
void
|
||||
run_festival(struct session *ses, struct document_view *doc_view)
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#ifndef EL__VIEWER_TEXT_FESTIVAL_H
|
||||
#define EL__VIEWER_TEXT_FESTIVAL_H
|
||||
|
||||
@ -10,7 +9,7 @@ struct fest {
|
||||
int line;
|
||||
int in;
|
||||
int out;
|
||||
int festival_or_flite;
|
||||
int speech_system;
|
||||
unsigned int running:1;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user