Call Audio Capturing

Hi, I am new to asterisks and I was running asterisk for the first time. I have installed asterisk 16.6 and freepbx, and I am using Zoiper5 to make calls. I want to capture call audio in real-time using the asterisk dialplan and send that audio stream to another process. However, I was unable to run the dialplan. My extensions_custom.conf file looks like below:

exten=>2020,1,System(‘/home/taimoor/Desktop/ast-python/test.py’)

However, the python script does not run when I make the call to extension 2020.

Instead of system app try agi() and enable the debug mode for AGI

I am running agi(test.py) in my dialplan now:
the python script is as followed:

#!/usr/bin/env python
import os
import sys

f = open(“demofile.txt”, “w”)
f.write(“Now the file has more content!”)
f.close()

The dialplan is extensions_custom.conf :

exten=>2020,1,Answer()
exten=>2020,n,Set(i=5)
exten=>2020,n,While($[${i}<10])
exten=>2020,n,Wait(2)
exten=>2020,n,Monitor(wav,/var/lib/asterisk/sounds/taimoor,o)
exten=>2020,n,Wait(10)
exten=>2020,n,StopMonitor()
exten=>2020,n,Agi(test.py)
exten=>2020,n,EndWhile

The agi debug from CLI is:

<PJSIP/2021-00000025>AGI Tx >> agi_request: test.py
<PJSIP/2021-00000025>AGI Tx >> agi_channel: PJSIP/2021-00000025
<PJSIP/2021-00000025>AGI Tx >> agi_language: en
<PJSIP/2021-00000025>AGI Tx >> agi_type: PJSIP
<PJSIP/2021-00000025>AGI Tx >> agi_uniqueid: 1582617383.37
<PJSIP/2021-00000025>AGI Tx >> agi_version: 16.6.1
<PJSIP/2021-00000025>AGI Tx >> agi_callerid: 2021
<PJSIP/2021-00000025>AGI Tx >> agi_calleridname: 2021
<PJSIP/2021-00000025>AGI Tx >> agi_callingpres: 0
<PJSIP/2021-00000025>AGI Tx >> agi_callingani2: 0
<PJSIP/2021-00000025>AGI Tx >> agi_callington: 0
<PJSIP/2021-00000025>AGI Tx >> agi_callingtns: 0
<PJSIP/2021-00000025>AGI Tx >> agi_dnid: 2020
<PJSIP/2021-00000025>AGI Tx >> agi_rdnis: unknown
<PJSIP/2021-00000025>AGI Tx >> agi_context: from-internal
<PJSIP/2021-00000025>AGI Tx >> agi_extension: 2020
<PJSIP/2021-00000025>AGI Tx >> agi_priority: 3
<PJSIP/2021-00000025>AGI Tx >> agi_enhanced: 0.0
<PJSIP/2021-00000025>AGI Tx >> agi_accountcode:
<PJSIP/2021-00000025>AGI Tx >> agi_threadid: 140350435944192
<PJSIP/2021-00000025>AGI Tx >>
<PJSIP/2021-00000025>AGI Rx << Saad Akhtar
<PJSIP/2021-00000025>AGI Tx >> 510 Invalid or unknown command

Has your python file executable permission? You can add it by command chmod +x test.py

It looks like what ever executed sent the text string “Saad Akhtar” to Asterisk which violates AGI protocol.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.