0

I've been using the say command in terminal to get my computer to talk, ie.

say "Hello"

How can I pipe the text of a .txt file to the say command to get it to read aloud the text in a file ?

2

Actually say has this option (see man say)

say -f stuff.txt

Or you can use command substitution...

say $(cat stuff.txt)

this passes the output of cat stuff.txt as an argument to say (the quotes " " are not needed)

1
  • That's too awesome. I should have figured that out. Thanks a lot! – wayneeusa Jul 30 '16 at 4:44
1

I am just adding that if you really want to pipe the output of a command to the say command, you can use named pipes.

Basically, just doing

mkfifo myNamedPipe
say -f myNamedPipe &
cat > myNamedPipe

should allow you to use speech synthesis on an arbitrary source (here, words from the keyboard using cat).

I do not however have the required configuration to actually try this, so I could have got something wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.