How to read text from file using Swift/Cepstral?

Hello everybody,

I am trying to get my Asterisk to read some text from a file using Swift/Cepstral.
Somehow I cannot figure out how to do it.

My dialplan (extensions.conf) snippet looks like this:

exten => 1222,1,Answer() exten => 1222,n,Playback(hello-world) exten => 1222,n,System(/opt/swift/bin/swift -f /etc/asterisk/testtext) exten => 1222,n,Wait exten => 1222,n,Hangup()

The console says:

== Console is full duplex [May 24 13:11:12] NOTICE[20747]: console_video.c:133 console_video_start: voice only, console video support not present -- Executing [1222@default:1] Answer("Console/dsp", "") in new stack << Console call has been answered >> -- Executing [1222@default:2] Playback("Console/dsp", "hello-world") in new stack -- <Console/dsp> Playing 'hello-world.gsm' (language 'en') -- Executing [1222@default:3] System("Console/dsp", "/opt/swift/bin/swift -f /etc/asterisk/testtext") in new stack -- Executing [1222@default:4] Wait("Console/dsp", "") in new stack -- Executing [1222@default:5] Hangup("Console/dsp", "") in new stack == Spawn extension (default, 1222, 5) exited non-zero on 'Console/dsp' << Hangup on console >>

The hello-world plays, but then I just get silence.
Does anybody see what I am doing wrong?

Swift in itself works, e.g. this here is working:

exten => 1,1,Swift(You pressed button 1) exten => 1,n,Hangup()

I use Asterisk 10.2.1.

Maybe somebody can help.


I would read the file contents and store them as a variable then use app_swift to read the variable.

you I thing are calling swift via a system command not app_swift.


Hello Ian,

I now tried like this:

exten => 1222,1,Answer() exten => 1222,n,ReadFile(message=/etc/asterisk/testtext,255) exten => 1222,n,Swift(${message}) exten => 1222,n,Wait exten => 1222,n,Hangup()

This is not working either.

I hope I did not make a mistake using the variable.

Can you please give me an example of how you think I should call app_swift? I don’t really know any other way of calling swift from the dialplan.

Thanks in advance.

Hello everybody!

I now figured out how to do it. My solution looks like this:

exten => 1222,1,Answer() exten => 1222,n,Set(MESSAGE=${FILE(/etc/asterisk/testtext)}) exten => 1222,n,Swift(${MESSAGE}) exten => 1222,n,Wait exten => 1222,n,Hangup()

Ian, thank you very much! Your hints got me on the right track.

I hope this will be beneficial to others as well.

Kind regards,


Glad to be of help.

Why not use festival?

exten => s,1,System(cat ‘${ARG1}’ | text2wave -f 8000 -o /tmp/${CHANNEL}.wav)
same => n,Playback(/tmp/${CHANNEL})
same => n,System(rm -o /tmp/${CHANNEL}.wav)

Oops, see you have a solution already, but this would work too.

Voice choices and quality.

for quick and dirty we use flite for nice and clean we use Swift