Recording the Interop voice samples in Asterisk

by Matthew Gast

To record voice samples for the WMM comparison in my last post, I set up Asterisk for recording. I wound up using two approaches to this: a star code (*8) to preface extensions that indicated the call should be recorded, and an interactive voice demonstration.

First, the star code: by prefacing a number in the 5000 block of extensions beginning with *8, Asterisk would record the audio from the call. The snippet of the dial plan is only four lines. It picks up the the phone, calls the Monitor application, and then dials the extension after stripping off the *8. Here's what it looks like:

exten => _*85XXX,1,Answer
exten => _*85XXX,n,Monitor(wav,/tmp/monitor-${CALLERID(num)}-to-${EXTEN:2}-${TIMESTAMP},b)
exten => _*85XXX,n,Dial(SIP/${EXTEN:2})
exten => _*85XXX,n,Hangup

The audio from the phone call will be saved in two files, one for each direction ("-in" for the voice from the phone, and "-out" for audio from the remote extension). After making a call, I could go pick up the "-in" file, which is a recording of what the stream of voice data sounds like after reaching the PBX.

The second extension that I set up was a "demo extension" that also uses a recording to allow subjective assessment of voice quality. Upon calling in, Asterisk would answer the phone, tell the caller whether they were using encryption and/or prioritization, record a voice sample, and play it back, allowing a caller to hear what they had just said. Here's the dial plan code for it:

exten => 5901,1,Answer
exten => 5901,n,Playback(wmm-demo/welcome-wmm-demo)
exten => 5901,n,NoOp(Caller number is ${CALLERID(num)})
exten => 5901,n,GotoIf($[ ${CALLERID(num)} = 5221 ]?500)
exten => 5901,n,GotoIf($[ ${CALLERID(num)} = 5231 ]?100)
exten => 5901,n,GotoIf($[ ${CALLERID(num)} = 5232 ]?200)
exten => 5901,n,GotoIf($[ ${CALLERID(num)} = 5233 ]?300)
exten => 5901,n,GotoIf($[ ${CALLERID(num)} = 5234 ]?400)
exten => 5901,n,NoOp(You should never get here!)

exten => 5901,50,Playback(wmm-demo/wmm-demo-record-prompt)
exten => 5901,n,Record(/tmp/wmmdemo-${CALLERID(num)}:wav)
exten => 5901,n,Wait(1)
exten => 5901,n,Playback(/tmp/wmmdemo-${CALLERID(num)})
exten => 5901,n,Hangup

exten => 5901,100,NoOp(Clear/NoWMM handler)
exten => 5901,n,Playback(wmm-demo/nowmm-clear-greeting)
exten => 5901,n,Goto(50)

exten => 5901,200,NoOp(Clear/WMM handler)
exten => 5901,n,Playback(wmm-demo/wmm-clear-greeting)
exten => 5901,n,Goto(50)

exten => 5901,300,NoOp(WPA2/NoWMM handler)
exten => 5901,n,Playback(wmm-demo/wpa2-nowmm-greeting)
exten => 5901,n,Goto(50)

exten => 5901,400,NoOp(WPA2/WMM handler)
exten => 5901,n,Playback(wmm-demo/wpa2-wmm-greeting)
exten => 5901,n,Goto(50)

exten => 5901,500,NoOp(Unex handler)
exten => 5901,n,Playback(wmm-demo/unex-greeting)
exten => 5901,n,Goto(50)

The only hard part to writing the demo extension (actually, anything interesting in the original Asterisk dial plan language) is that I had goto statements stamped out of me many years ago in my first serious computer science class. I'm sure that Mrs. Guerin would be pleased that I can't write a goto statement without remembering the dire consequences for my grade, and that I'm considering switching to the Asterisk Expression Language.


2006-05-05 18:55:36
Gotos get used in AEL too you know...
Matthew Gast
2006-05-06 19:51:43
Yup, I know. At least there are fewer gotos in AEL. :)
2007-11-27 18:14:17
can anyone tell me how to record my voice and email it, i am a voice over artist and i have demo cd's but most casting directors want a sample of your voice online first, i would appreciate any info
thank you wendy