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

Barton Fisher bpvoipcom at gmail.com
Sat Oct 10 18:42:00 CDT 2009



Steve Edwards wrote:
> On Sat, 10 Oct 2009, Bart Fisher wrote:
>
>   
>> I'm trying create a feature that allows a callers to add more speech to 
>> his recording. I think this can be done inside a dialplan, but I can't 
>> find an example of how to do this.
>>
>> Basically,after he records the primary message, a menu would play asking 
>> if he wants to append to this message.  If yes, then he would record a 
>> temp file with the additional message and when done, I want SOX to add 
>> the temp message to the primary message making it one larger message.
>>
>> Would you mind showing me an example of how to run SOX inside the 
>> dialplan?
>>     
>
> The system() dialplan application will allow you to run any executable.
>
> If you plan on concatenating more than 32 input files you'll have to make 
> sure you have sox v14.3.0 or later.
>
> 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.
>
> I would code the entire feature up as an AGI so you can hide all the ugly 
> details like creating files with unique file names, maybe running 
> normalize on the pieces before concatenation, error handling, maybe even 
> trimming the leading and trailing silence off each file so the gaps are 
> consistent, allowing the caller to listen to the new file and accept or 
> re-record the "suffix," cleaning up in case the caller hangs up, etc, etc, 
> etc.
>
>   

hmm, no luck.  Here's what I have:

exten => append,1,Noop(${PHRASEID}) ; this is the full path to original 
message without extension .wav
exten => append,n,Playback(custom/dax/record)
exten => 
append,n,Set(TEMPMESSAGE=/var/lib/asterisk/sounds/custom/${IVR-EXTEN}/temp);this 
is the full path to temp message without extension .wav
exten => append,n,Record(${TEMPMESSAGE}:wav|4|369) ; Begin recording new 
message
exten => append,n,System(sox ${PHRASEID}.wav ${TEMPMESSAGE}.wav 
${PHRASEID}.wav)
exten => append,n,system(rm ${TEMPMESSAGE}.wav)
exten => append,n,Goto(record,${IVR-EXTEN},confirm); go back and play 
entire message


-- Goto (record,append,1)
-- Executing [append at record:1] NoOp("SIP/8001-0a0227c8", 
"/var/lib/asterisk/sounds/custom/7146762004/1_17692") in new stack
-- Executing [append at record:2] Playback("SIP/8001-0a0227c8", 
"custom/dax/record") in new stack
-- <SIP/8001-0a0227c8> Playing 'custom/dax/record' (language 'en')
-- Executing [append at record:3] Set("SIP/8001-0a0227c8", 
"TEMPMESSAGE=/var/lib/asterisk/sounds/custom/7146762004/temp") in new stack
-- Executing [append at record:4] Record("SIP/8001-0a0227c8", 
"/var/lib/asterisk/sounds/custom/7146762004/temp:wav|4|369") in new stack
-- <SIP/8001-0a0227c8> Playing 'beep' (language 'en')
-- 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
-- Executing [append at record:6] System("SIP/8001-0a0227c8", "rm 
/var/lib/asterisk/sounds/custom/7146762004/temp.wav") in new stack
-- Executing [append at record:7] Goto("SIP/8001-0a0227c8", 
"record|7146762004|confirm") in new stack
-- Goto (record,7146762004,39)

Anything wrong?

Bart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20091010/e3f12562/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bhfisher.vcf
Type: text/x-vcard
Size: 249 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20091010/e3f12562/attachment.vcf 


More information about the asterisk-users mailing list