[Asterisk-doc] Asterisk Cookbook - a simple gsm file recorder

Randy Resnick asterisk-doc@lists.digium.com
Sat, 12 Jun 2004 12:07:44 +0200


Usual disclaimer - if this is not appropriate or not good enough, just 
hit delete :) My own feeling is this collection should at least start 
simple.

==============
Description:
Create a simple way to record 10 different gsm sound files. This is also 
a way to test the quality of the connection, since the file is played 
back. The recorded files can be used for other dialplans when renamed 
and moved to the appropriate directory.

Use:
Upon dialing a number between 100 and 109, the user hears recorded 
instructions, the number you dialed and a beep. Then, the Record() 
application does its thing.
When the user hits the # key, recording is stopped and the file is 
played back. After playback, the call is unceremoniously hung up. The 
recorded /tmp/recnn.gsm file can be manually moved to the sounds 
directory for use by the system.

Suggested improvements:
- add a goodbye sound file before hanging up
- definitely add an AbsoluteTimeout()
- add "auto-move" to sounds

Files modified: extensions.conf

Required files: /var/lib/asterisk/sounds/recording_instructions.gsm

*** extensions.conf

[globals]
RECORDER=_10X ; Make this a variable to change it easily
; The above will allow for a  three-digit number between 100 and 109

; Include this context in your dialplan
[recorder]
; Record a gsm voice file to /tmp
; File will be named for the second and third digits
; For example, 103 will be saved as /tmp/rec103.gsm
exten => ${RECORDER},1,Playback(recording_instructions)
exten => ${RECORDER},2,Saydigits(${EXTEN:1:2})
exten => ${RECORDER},3,Setvar(fnumber=${EXTEN:1:2})
exten => ${RECORDER},4,Wait(1)
exten => ${RECORDER},5,Record(/tmp/rec${fnumber}:gsm)
exten => ${RECORDER},6,Wait(1)
exten => ${RECORDER},7,Playback(/tmp/rec${fnumber})
exten => ${RECORDER},8,wait(1)
exten => ${RECORDER},9,Hangup

Variation on the same theme: record a file named from the callerid. 
Assuming the recorder is only in an internal extensions context, the 
CALLERID will be something like n, nn, nnn, or nnnn.

exten => ${RECORDER},1,Playback(recording_instructions)
exten => ${RECORDER},2,Wait(1)
exten => ${RECORDER},3,Record(/tmp/caller${CALLERIDNUM}:gsm)
exten => ${RECORDER},4,Wait(1)
exten => ${RECORDER},5,Playback(/tmp/caller${CALLERIDNUM})
exten => ${RECORDER},6,wait(1)
exten => ${RECORDER},7,Hangup

Suggested improvements:
- add a test to make sure there is an acceptable CALLERIDNUM
- make the file playback automatically without needing to hit #

=================

rr