DEV Community


Posted on • Updated on

Record and Hear your voice through Asterisk

Weekly sharing

Hi everyone, I am Ekim, a fresh Bootcamp graduate and an IT helper (I don't dare to call myself a programmer yet). Every Friday, I will share some of the work that I've done over the last week in a bid to get feedbacks from you guys and record my journey to become a programmer.


Asterisk basic set up


Last week was quite a fuzzy journey. Not much concrete output has been done. Although the progress is slow, I still would like to share how to record and play audio through Asterisk.

Recording through dialing 41XXXX

Let's create an endpoint of 1114 for our softphone.

  • In pjsip.conf,
;================================ TRANSPORTS ==
; Our primary transport definition for UDP communication behind NAT.
type = transport
protocol = udp
bind =
; NAT settings
;local_net =
;external_media_address =
;external_signaling_address =

;================================ CONFIG FOR SIP ITSP ==

allow = !all,ulaw,alaw

type = auth
auth_type = userpass

type = aor
max_contacts = 1

callerid = 1114 <1114>

password = 1114
username = 1114
Enter fullscreen mode Exit fullscreen mode

What I want to do here is to dial a number, which starts with 41 and is followed by any 4 digits, to record my voice on the softphone. And then, I would like hear my voice again when I dial 42 + any 4 digits I've just dialed.

  • So, in the extensions.conf
exten = _41XXXX,1,Answer
same = n,Record(record/${EXTEN:2}.gsm)      ; record your voice and save it in the name of XXXX, the any 4 digits you dialed and in .gsm format
same = n,Wait(1)
same = n,Hangup()

exten = _42XXXX,1,Answer
same = n,Wait(1)
same = n,Playback(record/${EXTEN:2})        ; play the audio file you recorded from /var/lib/asterisk/sounds/record
same = n,Wait(1)
same = n,Hangup()
Enter fullscreen mode Exit fullscreen mode

After that, add the load = in your modules.conf.

load =
load =
load =
load =
load =
load =
load =
load =
load =
load =        ; add this into your modules.conf, so that you do not need to load the module every time.
Enter fullscreen mode Exit fullscreen mode

It's time to restart the asterisk to make things ready.

sudo service asterisk restart
Enter fullscreen mode Exit fullscreen mode

Then remember to go to CLI to reload the dialplan and pjsip.

sudo asterisk -rvvvvv
Enter fullscreen mode Exit fullscreen mode
dialplan reload
core reload
Enter fullscreen mode Exit fullscreen mode

Open you softphone and do the following settings


  • The SIP server and Domain should be your Ubuntu's IP. You can check it by this command:

    ip addr

  • If you have problem connecting your softphone to your Ubuntu, please check that you've done these firewall settings: .

Hearing your voice

So, if you followed the aforementioned steps, you should be able to record your voice by dialing, for example, 411234. Noted that when you finish your recording, press # to finish the call. Do Not End The Call Right Away, or it won't save the recording.


After recording your voice, it's time to appreciate the cuss words you've just sworn yourself. (Yeah, I know it !!!! We all do it to ourselves.)

When you dial 421234, you should hear your recording straight away.



Usually, when we want someone to record an audio track, we won't just use the Record dialplan application alone because they won't have an idea that they need to press # to save the recording. Hence, it is better to record a track that guides them what to do after they record their voices. That's what we'll do next time. For the time being, stay healthy and stay tuned !!!

Top comments (0)