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

Use popen for flite.

This commit is contained in:
Witold Filipczyk 2006-12-29 00:21:30 +01:00 committed by Witold Filipczyk
parent 60fc3bd04f
commit 91be2ea6b8

View File

@ -74,18 +74,24 @@ write_to_festival(struct fest *fest)
return; return;
data = doc->data[fest->line].chars; data = doc->data[fest->line].chars;
if (festival.festival_or_flite == FESTIVAL_SYSTEM) if (festival.festival_or_flite == FESTIVAL_SYSTEM) {
add_to_string(&buf, "(SayText \""); add_to_string(&buf, "(SayText \"");
/* UTF-8 not supported yet. Does festival support UTF-8? */ /* UTF-8 not supported yet. Does 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;
if (ch == '"' || ch == '\\' || ch == '\'') if (ch == '"' || ch == '\\')
add_char_to_string(&buf, '\\'); add_char_to_string(&buf, '\\');
add_char_to_string(&buf, ch); add_char_to_string(&buf, ch);
} }
if (festival.festival_or_flite == FESTIVAL_SYSTEM)
add_to_string(&buf, "\")"); add_to_string(&buf, "\")");
} else { /* flite */
for (i = 0; i < len; i++) {
unsigned char ch = (unsigned char)data[i].data;
add_char_to_string(&buf, ch);
}
}
add_char_to_string(&buf, '\n'); add_char_to_string(&buf, '\n');
w = safe_write(fest->out, buf.source, buf.length); w = safe_write(fest->out, buf.source, buf.length);
@ -140,15 +146,18 @@ init_festival(void)
execl(FESTIVAL, "festival", "-i", NULL); execl(FESTIVAL, "festival", "-i", NULL);
_exit(0); _exit(0);
} else { } else {
char line[1024];
char command[1200];
do { do {
char line[1024];
FILE *out;
fgets(line, 1024, stdin); fgets(line, 1024, stdin);
snprintf(command, 1200, "%s -t '%s'", FLITE, line); out = popen(FLITE, "w");
system(command); if (out) {
putchar(' '); fputs(line, out);
fflush(stdout); pclose(out);
putchar(' ');
fflush(stdout);
}
} while (!feof(stdin)); } while (!feof(stdin));
_exit(0); _exit(0);
} }