mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-03 06:12:55 +00:00
Support reading input from named pipes
Added support for line-by-line input reading from unix FIFOs.
This commit is contained in:
committed by
Reece H. Dunn
parent
252c894e59
commit
7659aaa2e8
+13
-3
@@ -652,12 +652,20 @@ int main(int argc, char **argv)
|
||||
flag_stdin = 2;
|
||||
}
|
||||
} else {
|
||||
struct stat st;
|
||||
if (stat(filename, &st) != 0) {
|
||||
fprintf(stderr, "Failed to stat() file '%s'\n", filename);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
filesize = GetFileLength(filename);
|
||||
f_text = fopen(filename, "r");
|
||||
if (f_text == NULL) {
|
||||
fprintf(stderr, "Failed to read file '%s'\n", filename);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (S_ISFIFO(st.st_mode)) {
|
||||
flag_stdin = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_text != NULL) {
|
||||
@@ -672,11 +680,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (flag_stdin == 2) {
|
||||
// line by line input on stdin
|
||||
while (fgets(p_text, max, stdin) != NULL) {
|
||||
// line by line input on stdin or from FIFO
|
||||
while (fgets(p_text, max, f_text) != NULL) {
|
||||
p_text[max-1] = 0;
|
||||
espeak_Synth(p_text, max, 0, POS_CHARACTER, 0, synth_flags, NULL, NULL);
|
||||
|
||||
}
|
||||
if (f_text != stdin) {
|
||||
fclose(f_text);
|
||||
}
|
||||
} else {
|
||||
// bulk input on stdin
|
||||
|
||||
Reference in New Issue
Block a user