[asterisk-users] Recording interface (pause/PLAY/RERECORD)
Leif Madsen
leif.madsen at asteriskdocs.org
Tue Jul 27 20:49:20 CDT 2010
On 10-07-27 08:39 PM, Michelle Dupuis wrote:
> Is there a prebuild module/dialplan which gives me a nice interface to recording messages? Assuming I can't use the voicemail command, I need to offer users a way to record, playback, erase, rerecord, etc.
>
> I can probably do it through dialplan but it feels like I'm reinventing the wheel.
Ya I haven't really written one generally yet, but here is something I'm
whipping together without testing :) I'll probably test it tomorrow during our
daily documentation session.
[globals]
CUSTOM_RECORDINGS=/var/lib/asterisk/sounds/en/custom
[subRecordPrompt]
exten => _[A-Za-z0-9].,1,NoOp()
; Safely handle extension name -- this will be our filename
same => n,Set(RecordedFilename=${FILTER(A-Za-z0-9,${EXTEN})})
same => n,Set(RandomNumber=${RAND()})
same => n,Answer()
; Record the prompt
same => n(record),Playback(please-enter-your&vm-message&after-the-tone)
same => n,Wait(1)
same =>
n,Record(${GLOBAL(CUSTOM_RECORDINGS)}/temporaryRecording-${RandomNumber}.wav)
; Ask how we want to handle the recording
same => n(handle_recording),Read(ActionItem,vm-review,1)
; Verify we got values we expect
same => n,GotoIf($['${ActionItem}' = '1' | '${ActionItem}' = '2' |
${ActionItem}' = 3]?valid_action)
same => n,Playback(wrong-try-again-smarty)
same => n,Goto(handle_recording)
same => n(valid_action),NoOp()
; Handle the recording
; 1 accept
; 2 review
; 3 re-record
same => n,GotoIf($['${ActionItem}' = '1']?accept,1) ; keep this recording
same => n,GotoIf($['${ActionItem}' = '3']?record) ; re-record it
; If we get here they pressed 2
same => n,Playback(${GLOBAL(CUSTOM_RECORDINGS)}/temporaryRecording-${RandomNumber})
same => n,Goto(handle_recording)
exten => accept,1,Verbose(2,Recording accepted!)
same => n,System(mv
${GLOBAL(CUSTOM_RECORDINGS)}/temporaryRecording-${RandomNumber}.wav
${GLOBAL(CUSTOM_RECORDINGS)}/${RecordedFilename}.wav)
exten => h,1,Verbose(2,Cleanup the file)
same => n,System(rm -f
${GLOBAL(CUSTOM_RECORDINGS)}/temporaryRecording-${RandomNumber}.wav)
...or something like that.
Leif Madsen.
More information about the asterisk-users
mailing list