How to use AMD Answering Machine Detection on Asterisk in Oracle Linux 9.3
To Use AMD - Answering Machine Detection On Asterisk On Oracle Linux 9.3
Introduction:
This application attempts to detect an answering machine, based on the timing patterns. This application is usually used by outbound calls originating from either call files or the Asterisk Manager Interface. This application sets the AMDSTATUS variable is set to one of the following, to show what type of call was detected.
Procedure:
Step 1: Check the OS version by using the below command
[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3
Step 2: Check the status of the Asterisk by using the below command
[root@linuxhelp ~]# systemctl status asterisk.service
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
Active: active (running) since Mon 2024-02-19 04:02:05 IST; 2 months 18 days ago
Docs: man:systemd-sysv-generator(8)
Process: 1001 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
Main PID: 1062
Tasks: 37 (limit: 21739)
Memory: 63.3M
CPU: 8.945s
CGroup: /system.slice/asterisk.service
├─1056 /bin/sh /usr/sbin/safe_asterisk
└─5831 /usr/sbin/asterisk -f -vvvg -c
Feb 19 04:02:05 linuxhelp systemd[1]: Starting LSB: Asterisk PBX...
Feb 19 04:02:05 linuxhelp asterisk[1001]: Starting asterisk:
Feb 19 04:02:05 linuxhelp systemd[1]: asterisk.service: Can't open PID file /run/asterisk/asterisk.pid (yet?) after start: Operation not permitted
Feb 19 04:02:05 linuxhelp systemd[1]: asterisk.service: Supervising process 1062 which is not our child. We'll most likely not notice when it exits.
Feb 19 04:02:05 linuxhelp systemd[1]: Started LSB: Asterisk PBX.
Step 3: Move to the Asterisk Directory by using the below command
[root@linuxhelp ~]# cd /etc/asterisk/
Step 4: Edit the extensions.conf file by using the below command
[root@linuxhelp asterisk]# vim /etc/extensions.conf
[internal]
exten => 167,1,Answer()
exten => 167,n,AMD()
exten => 167,n,GotoIf("${AMDSTATUS}" = "HUMAN"]?allow:deny)
exten => 167,n(deny),WaitForSilence(20)
exten => 167,n,Playback(asterisk-friend)
exten => 167,n,Hangup()
exten => 167,n(allow),NoOp(Call from the ${EXTEN} is Detected as a Human)
exten => 167,n,Dial(PJSIP/${EXTEN})
exten => 167,n,Playback(im-sorry)
exten => 167,n,Hangup()
Step 5: Go to the Asterisk CLI mode by using the below command
[root@linuxhelp asterisk]# asterisk -rvvvvvvvvvvvvvv
Asterisk 20.5.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.5.0 currently running on linuxhelp (pid = 6252)
linuxhelp*CLI>
Step 6: Reload the dialplan by using the below command
linuxhelp*CLI> dialplan reload
Dialplan reloaded.
-- Time to scan old dialplan and merge leftovers back into the new: 0.000009 sec
-- Time to restore hints and swap in new dialplan: 0.000009 sec
-- Time to delete the old dialplan: 0.000009 sec
-- Total time merge_contexts_delete: 0.000027 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
Step 7: Make a call from 168 to 167 by using the Zoiper and Microsip Software as shown in the below image.
Output:-
linuxhelp*CLI>
-- Executing [167@internal:1] Answer("PJSIP/168-00000002", "") in new stack
> 0x7fefdc03d1f0 -- Strict RTP learning after remote address set to: 192.168.6.102:4000
-- Executing [167@internal:2] AMD("PJSIP/168-00000002", "") in new stack
-- AMD: PJSIP/168-00000002 168 (N/A) (Fmt: ulaw)
-- AMD: initialSilence [2500] greeting [1500] afterGreetingSilence [800] totalAnalysisTime [5000] minimumWordLength [100] betweenWordsSilence [50] maximumNumberOfWords [2] silenceThreshold [256] maximumWordLength [5000]
> 0x7fefdc03d1f0 -- Strict RTP switching to RTP target address 192.168.6.102:4000 as source
-- AMD: Channel [PJSIP/168-00000002]. Changed state to STATE_IN_SILENCE
-- AMD: Channel [PJSIP/168-00000002]. ANSWERING MACHINE: silenceDuration:2500 initialSilence:2500
-- Executing [167@internal:3] GotoIf("PJSIP/168-00000002", ""MACHINE" = "HUMAN"]?allow:deny") in new stack
-- Goto (internal,167,7)
-- Executing [167@internal:7] NoOp("PJSIP/168-00000002", "Call from the 167 is Detected as a Human") in new stack
-- Executing [167@internal:8] Dial("PJSIP/168-00000002", "PJSIP/167") in new stack
-- Called PJSIP/167
-- PJSIP/167-00000003 is ringing
> 0x7fefdc03d1f0 -- Strict RTP learning complete - Locking on source address 192.168.6.102:4000
> 0x7fefdc02ea00 -- Strict RTP learning after remote address set to: 192.168.6.102:8000
> 0x7fefdc02ea00 -- Strict RTP switching to RTP target address 192.168.6.102:8000 as source
-- PJSIP/167-00000003 answered PJSIP/168-00000002
-- Channel PJSIP/167-00000003 joined 'simple_bridge' basic-bridge <aaeed59b-b235-4114-9cbc-1f1b4f5a81e5>
-- Channel PJSIP/168-00000002 joined 'simple_bridge' basic-bridge <aaeed59b-b235-4114-9cbc-1f1b4f5a81e5>
> Bridge aaeed59b-b235-4114-9cbc-1f1b4f5a81e5: switching from simple_bridge technology to native_rtp
> Locally RTP bridged 'PJSIP/168-00000002' and 'PJSIP/167-00000003' in stack
> 0x7fefdc02ea00 -- Strict RTP learning complete - Locking on source address 192.168.6.102:8000
-- Channel PJSIP/167-00000003 left 'native_rtp' basic-bridge <aaeed59b-b235-4114-9cbc-1f1b4f5a81e5>
-- Channel PJSIP/168-00000002 left 'native_rtp' basic-bridge <aaeed59b-b235-4114-9cbc-1f1b4f5a81e5>
== Spawn extension (internal, 167, 8) exited non-zero on 'PJSIP/168-00000002'
linuxhelp*CLI>
Step 8: Exit from the asterisk CLI mode by using the below command.
linuxhelp*CLI> exit
Step 9: Path of the amd.conf file where we edit the AMD configuration by using the below command
[root@linuxhelp asterisk]# cat amd.conf
;
; Answering Machine Detection Configuration
;
[general]
total_analysis_time = 5000 ; Maximum time allowed for the algorithm to decide
; on whether the audio represents a HUMAN, or a MACHINE
silence_threshold = 256 ; If the average level of noise in a sample does not reach
; this value, from a scale of 0 to 32767, then we will consider
; it to be silence.
;playback_file = ; Audio file to play while AMD is running, so the caller
; does not just hear silence. Note that specifying this here
; will apply to ALL AMD runs, so you may wish to set it
; in the dialplan as an argument to AMD() instead.
; Default is no audio file (not to play anything).
; Greeting ;
initial_silence = 2500 ; Maximum silence duration before the greeting.
; If exceeded, then the result is detection as a MACHINE.
after_greeting_silence = 800 ; Silence after detecting a greeting.
; If exceeded, then the result is detection as a HUMAN
greeting = 1500 ; Maximum length of a greeting. If exceeded, then the
; result is detection as a MACHINE.
; Word detection ;
min_word_length = 100 ; Minimum duration of Voice to considered as a word
maximum_word_length = 5000 ; Maximum duration of a single Voice utterance allowed.
between_words_silence = 50 ; Minimum duration of silence after a word to consider
; the audio what follows as a new word
maximum_number_of_words = 2 ; Maximum number of words in the greeting
; If exceeded, then the result is detection as a MACHINE
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps to use AMD Answering Machine Detection on Asterisk on Oracle Linux 9.3. Your feedback is much welcome.
Comments ( 0 )
No comments available