How to play and record wav in Asterisk?

Hi,

I’m working mainly with SIP proxies such as kamailio/opensips, that’s why this may be bit lame question, but I have to implement this quite fast, so have no time for studying this time. I’m doing some kind of quality measuring, asterisk will play wav, another asterisk will record the voice and compare the wavs. I have already the algorithm for comparing the wavs (it also trims the silence at the beginning and calculates similarity).

So, how could I do these things on asterisk:

  1. Externally (with some API) make a call from asterisk and play wav and hangup the call. What interface/API/module should I install to make such calls ?

  2. How should I configure the extension/route/whatever on the another asterisk so it will pickup the call and record the wav?

Thanks.

Hi

This should help/ give you an idea

viewtopic.php?f=1&t=79562&hilit=+test&sid=f2aaec111b6d879be1f5679369cd9ad7#p162106

Ian

[quote=“ianplain”]Hi

This should help/ give you an idea

forums.digium.com/viewtopic.php? … d7#p162106

Ian[/quote]

Thank you, this helped a lot. Now I know finally how the extensions can be configured. One question, if I use Record , it will stop and do not process any other commands from the context (I’m using freepbx as well)

-- Executing [200@from-internal:3] Record("SIP/100-00000023", "asterisk-recording%d:ulaw") in new stack -- <SIP/100-00000023> Playing 'beep' (language 'en')

It is configured as in the example:

exten => 200,1,Answer exten => 200,2,Wait(2) exten => 200,3,Record(asterisk-recording%d:ulaw) exten => 200,4,Wait(2) exten => 200,5,Playback(${RECORDED_FILE}) exten => 200,6,Wait(2) exten => 200,7,Hangup

It should continue and play the file, am I wrong?

Hi

I think the syntax has changed and no one has changed the wiki

[code] -= Info about application ‘Record’ =-

[Synopsis]
Record to a file.

[Description]
If filename contains ‘%d’, these characters will be replaced with a number
incremented by one each time the file is recorded. Use ‘core show file formats’
to see the available formats on your system User can press ‘#’ to terminate
the recording and continue to the next priority. If the user hangs up during
a recording, all data will be lost and the application will terminate.
${RECORDED_FILE}: Will be set to the final filename of the recording.
${RECORD_STATUS}: This is the final status of the command
DTMF:A terminating DTMF was received (’#’ or ‘*’, depending upon
option ‘t’)
SILENCE:The maximum silence occurred in the recording.
SKIP:The line was not yet answered and the ‘s’ option was specified.
TIMEOUT:The maximum length was reached.
HANGUP:The channel was hung up.
ERROR:An unrecoverable error occurred, which resulted in a WARNING
to the logs.

[Syntax]
Record(filename.format[,silence[,maxduration[,options]]])

[Arguments]
format
Is the format of the file type to be recorded (wav, gsm, etc).
silence
Is the number of seconds of silence to allow before returning.
maxduration
Is the maximum recording duration in seconds. If missing or 0 there
is no maximum.
options
a: Append to existing recording rather than replacing.
n: Do not answer, but record anyway if line not yet answered.
q: quiet (do not play a beep tone).
s: skip recording if the line is not yet answered.
t: use alternate ‘*’ terminator key (DTMF) instead of default '#'
x: Ignore all terminator keys (DTMF) and keep recording until hangup.
k: Keep recorded file upon hangup.
y: Terminate recording if any DTMF digit is received.

[/code]

I understand everything from your code except for one thing:

exten => 427999,n,SendDTMF(1234ww)

It means, it will generate the DTMF tones but for what reason? It will then execute this extension code on the other side?

exten => 1234,1,Noop(I heard that and alls OK)
exten => 1234,n,System(/usr/local/sbin/calltest.sh OK)
exten => 1234,n,Record(/tmp/monkey.wav)
exten => 1234,n,Hangup()

I do not understand, how or when this code is executed. Asterisk will recognize and parse the DTMF ? Or is there something I have to configure further? Because everything works but after DTMF tones nothing happens and the code is not executed. Thanks

Hi

Ok

this code was from a test system.

so heres what it did

serverA calls 123 that serverB , ServerB answers and serverA dials 321 which waits for digits

ServerB when its answered the call it plays a message and then “dials” 1234 this is picked up on serverA and the call is passed to the 1234 extension that runs a script and plays monkeys then hangs up, ServerA will also have hungp as well

This script is used for testing a systems running and functioning correctly , the script that is run is linked to nagios.

if you want any more help contact me directly