[asterisk-users] Method to use SOX inside a Dialplan

Steve Edwards asterisk.org at sedwards.com
Sat Oct 10 20:31:54 CDT 2009


> Steve Edwards wrote:
>> 
>> The dialplan snippet would look something like:
>>
>>          exten = s,n,system(/path-to-sox/sox a.wav b.wav c.wav)
>> 
>> This would copy a.wav followed by b.wav to a new file, c.wav.

On Sat, 10 Oct 2009, Barton Fisher wrote:

> hmm, no luck.  Here's what I have:
>
> exten => append,1,Noop(${PHRASEID}) ; this is the full path to original 
> message without extension .wav

I'm on a "personal mission" to stamp out the abuse of the noop() 
application since there is a more versatile application, verbose(), 
specifically for this task :)

> exten => append,n,System(sox ${PHRASEID}.wav ${TEMPMESSAGE}.wav 
> ${PHRASEID}.wav)

> -- Executing [append at record:5] System("SIP/8001-0a0227c8", "sox 
> /var/lib/asterisk/sounds/custom/7146762004/1_17692.wav 
> /var/lib/asterisk/sounds/custom/7146762004/temp.wav 
> /var/lib/asterisk/sounds/custom/7146762004/1_17692.wav") in new stack

 	sox\
 		/var/lib/asterisk/sounds/custom/7146762004/1_17692.wav\
 		/var/lib/asterisk/sounds/custom/7146762004/temp.wav\
 		/var/lib/asterisk/sounds/custom/7146762004/1_17692.wav

The output file has the same name as one of the input files. If I execute 
"sox a.wav b.wav a.wav" I get "sox WARN wav: Premature EOF on .wav input 
file." Curiously, if I execute "sox a.wav b.wav b.wav" it works, but that 
is not what you want. In general, specifying an output file name the same 
as an input file name is a bad idea because the result is inconsistent 
from program to program.

What happens if you execute your command from a shell command line?

Is the path to sox in the environment of the process created by Asterisk?

If you append ">/tmp/stdout 2>/tmp/stderr" to your system() command line 
you may get more clues.

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list