There are basically two common ways to record your own sounds for asterisk. One is to use professional recording equipment and software to record, edit, and convert the sound files. Although this will give you the best possible sound files, it can be cumbersome to setup. The next option is to use your own Asterisk phones to record the sounds. This is quick, easy, and can still provide decent audio files.
The Recording Directory
In this lesson we will use the Record() application within Asterisk to record sounds using the phone. The sounds will be recorded to the /usr/share/asterisk/sounds/recordings directory and then played back for verification.
To get started verify that there is a recordings folder located in the /usr/share/asterisk/sounds directory. If there isn’t a recordings folder, it will need to be created. The recordings directory will most likely only have write permissions for the root user of the Linux system. This will need to be changed so that Asterisk can write the new sound files to this folder. To change the ownership of the folder to Asterisk use the following command:
sudo chown asterisk:asterisk /usr/share/asterisk/sounds/recordings
Recording Extension in the Dialplan
Now we can open the /etc/asterisk/extensions.conf file and modify the dialplan to add an extension that will record audio. Open the extensions.conf file and add the following to the [phones] context:
exten => 210,1,NoOp(voice recording)
same => n,Answer
same => n,Record(recordings/test.gsm)
same => Hangup
The second line of the extension 210 uses the Answer application. Since there is no physical pickup of the telephone line, this allows Asterisk to pick the call up and move to the Recording() application. The Recording() application is set to record a new file named test.gsm in the recordings directory. To end the recording application, you must use the # from the phone, this will then move to procedures to Hangup and successfully save the recording. If you hangup the phone without pressing #, the recording will not be saved.
Playback Extension in the Dialplan
Now lets add a new extension that will be used to listen to the recording. Open up the extensions.conf file and add the following to the [phones] context:
exten => 211,1,NoOp(voice playback)
same => n,Playback(recordings/test)
same => Hangup
Test to make sure you can record and playback your sound recordings.