Promptrecorder

From aa-asterisk.org.uk wiki
Jump to: navigation, search

Recording prompts for use in the dialplan

We've all been there - written a nifty bit of dialplan code, but we need some prompts to go with it. How do we record them? Well, short of using a professional studio (or botching it on your PC), the answer is to hack Asterisk to do it for you...

You'll need this: File:Vitellphrase-phrases.tar which contains the phrases/prompts you need to run the code. Untar this to a directory of your choosing, however we recommend '/var/lib/asterisk/sounds/custom/'.

extensions-phrase.conf

; ----------------------------------------------------------
;               PHRASE RECORDING
; ----------------------------------------------------------
;
; Nick Barnes, Vitell, 2006 or so!
; Licence: CC Attribution-Share Alike 3.0 Unported
; http://creativecommons.org/licenses/by-sa/3.0/
;
; ----------------------------------------------------------
; Vitell - Asterisk, Linux and RouterOS consultants.
; No job too complex! Call us on:
; SIP: info@vitell.co.uk
; PSTN: +44-1676530540
; or e-mail info@vitell.co.uk
;
; ----------------------------------------------------------
; Installation
; ------------
; Save this file as '/etc/asterisk/extensions-phrase.conf'
; and include it in your main dialplan:
; #include /etc/asterisk/extensions-phrase.conf
; Then, somewhere in your dialplan, provide an extension
; which goes off to run this code. Something like
; exten => 18,1,Goto(vitell-phrase,s,1)
; We use 18, but you can, of course, use anything you want.
; Copy the three prompt files into whichever directory you want
; and then change the variables in the [vitell-phrase-vars]
; context, below to point to these prompts and the directory
; you want to put the recorded prompts in. Make sure these
; directories exist!
; ----------------------------------------------------------
; Use
; ---
; After dialing the extension to enter the phrase menu, select
; '1' to record a new phrase/prompt. Enter the number you want
; to give to this phrase and then press the hash key. After the
; beep, record your phrase and then press the hash key to end.
; The system will then play the phrase back at you.
; The phrase is recorded directly to the file:
; DIRECTORY/PHRASENUM.FORMAT
; (e.g. '/var/lib/asterisk/sounds/custom/1.alaw')
;
; To listen to a prompt, select '2' from the main menu and enter
; the phrase number followed by the hash key.
;
; Note
; ----
; * The recordings are made directly into the file and will overwrite
; any existing audio!
; * The system is set up so that all prompts are interruptable (i.e.
; you don't have to wait until the prompts have finished before you
; do whatever it is you want to do.
; * Does anybody ever read the instructions? I'll bet nobody sees
; this paragraph.
;
; And...
; ------
; That's it. Enjoy!
; ----------------------------------------------------------

[vitell-phrase-vars]
exten => s,1,NoOp(Vitell phrase variable settings)
;
; Which directory contains the prompts we are going to play
; to the caller (no trailing '/')
exten => s,n,Set(VP_PROMPTDIR=custom)
;
; And where do we want to record their prompts to? (no trailing
; '/'.
exten => s,n,Set(VP_RECDIR=custom)
;
; Maximum duration of recordings
; exten => s,n,Set(VP_MAXDUR=60)
;
; In what format?
exten => s,n,Set(VP_FORMAT=alaw)
;
; That's it!
exten => s,n,Return()

; ----------------------------------------------------------
; DON'T EDIT BELOW THIS LINE (unless you really know what
; you're doing!).
; ----------------------------------------------------------

[vitell-phrase]
exten => s,1,NoOp(Vitell phrase recording)
exten => s,n,Gosub(vitell-phrase-vars,s,1)
exten => s,n,Answer(500)
exten => s,n(menu),BackGround(${VP_PROMPTDIR}/phrase-menu)
exten => s,n,WaitExten(5)
exten => s,n,Goto(menu)

; Phrase Recording
exten => 1,1,NoOp()
exten => 1,n,Read(VP_PHRASEID,${VP_PROMPTDIR}/phrase-enternum,,,1,5)
exten => 1,n,GotoIf($["${VP_PHRASEID}" = ""]?s,menu)
exten => 1,n,Record(${VP_RECDIR}/${VP_PHRASEID}.${VP_FORMAT},,${VP_MAXDUR})
exten => 1,n,Background(${VP_RECDIR}/${VP_PHRASEID})
exten => 1,n,Goto(s,menu)

; Phrase review
exten => 2,1,NoOp()
exten => 2,n,Read(VP_PHRASEID,${VP_PROMPTDIR}/phrase-enternum,,,1,5)
exten => 2,n,GotoIf($["${VP_PHRASEID}" = ""]?s,menu)
exten => 2,n,Background(${VP_RECDIR}/${VP_PHRASEID})
exten => 2,n,Goto(s,menu)

exten => t,1,Hangup

exten => i,1,Background(${VP_PROMPTDIR}/phrase-invalid)
exten => i,n,Goto(s,menu)