I'm trying to send a stream of the end of a file (via tail -f) to festival, which is a text to speech program. tail -f ./filename | festival --tts works fine for this.
Here's my problem: I'd like change the stream coming out of tail -f so that festival can better synthesize it, and to avoid it speaking entire timestamps. I know that programs like sed and grep can do this. unfortunately tail -f ./filename | sed 's/:/ says/' | festival --tts does not output any sound.
yes, I have check to see if tail -f ./filename | sed 's/:/ says/' outputs anything, and it does that just fine.
I've also tried this with grep and I can not get festival --tts to say anything after I've edited my stream.
Anything that allows my stream to be edited, then spoken would be welcomed, I'm not tied down to sed and grep.
tail -f
by itself won't work because festival is waiting for the input stream to close before it outputs audio. Withtail -f
as input, the input stream will never close.However, you can use the bash
read
command to break the tail output up, run it through grep, and pass it to festival in a separate process with a script like this:If your grep filter isn't returning much data, it will take some time before the grep buffer fills and flushes. To reduce the size of the grep buffer, use
grep --line-buffered something
. sed has similar buffering capabilities, and you can use the-u
(unbuffered) option in sed to disable them.