Festival reading from file: possible?

Following an interesting part in “Asterisk TFOT” book on setting Festival to work with Asterisk, I am trying to make Festival read from a text file rather than hardcoding the text to be spoken into the Festival () function.
So, instead of:

exten =>s,n,Festival(Hello from Festival)

I would like to pass the contents of a text file into Festival so that it will read them aloud:

exten =>s,n,Festival(address-of-the-text-file-to-be-read)

How to get Festival read from file while it is working with asterisk?

perhaps this blog entry (and links) might help : lorancestinson.blogspot.com/2006 … -talk.html

using his script as a start, you should be able to pass a file location to the AGI and then text2wav this before streaming it out.

ok, this has bugged me all morning :open_mouth:

exten => 316,1,Answer exten => 316,2,System(text2wave -o /var/lib/asterisk/sounds/custom/${UNIQUEID}.ulaw -otype ulaw /tmp/tony.txt) exten => 316,3,Playback(custom/${UNIQUEID}) exten => 316,4,System(rm -f /var/lib/asterisk/sounds/custom/${UNIQUEID}.ulaw exten => 316,5,Hangup()

Thank you baconbuttie,
So there’s no way of just passing an address to Festival, better use text2wave and then Playback() the resulting wav.
Looking at the code you provided, I am not sure what are you trying to do. Perhaps saving the value of the variable UNIQUEID in a text file and then read it via text2wave? If that is the case, why are you using text2wave to write to tony.txt? Again, I only guess the intention…

errr … that’s a working example. it reads the txt file, outputs it to the custom sounds directory with the uniqueid as part of the filename, then plays it before finally deleting it.