I’m using python for AGI but I’m facing a problem which is: stream file & get data command not playing sound, here under my code and configurations and debugging output:
sip.conf:
[general]
#include “/etc/asterisk/myip.conf”
;--------------Networing Part----------------------
;
context=sip_in ; Default context for incoming calls. Defaults to ‘default’
udpbindaddr=0.0.0.0:5010 ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
tcpenable=no ; Enable server for incoming TCP connections (default is no)
transport=udp ; Set the default transports. The order determines the primary default transport.
; If tcpenable=no and the transport set is tcp, we will fallback to UDP.
srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; Note: Asterisk only uses the first host
; in SRV records
; Disabling DNS SRV lookups disables the
; ability to place SIP calls based on domain
; names to some other SIP users on the Internet
; Specifying a port in a SIP peer definition or
; when dialing outbound calls will supress SRV
; lookups for that peer or call.
canreinvite=yes
;---------------Codec negotiation------------------
;
;disallow=all ; First disallow all codecs
;allow=ulaw ; Allow codecs in order of preference
;allow=ilbc,g729,ulaw ; see https://wiki.asterisk.org/wiki/display/AST/RTP+Packetization
allow=all
;------ for framing options
autoframing=yes ; Set packetization based on the remote endpoint’s (ptime)
; preferences. Defaults to no.
;
useragent=IMS-CRBT ; Allows you to change the user agent string
; The default user agent string also contains the Asterisk
; version. If you don’t want to expose this, change the
; useragent string.
python code:
#!/usr/bin/python3
import sys
from asterisk.agi import *
agi = AGI()
agi.verbose(“python agi started”)
callerId = agi.env[‘agi_callerid’]
agi.verbose(“call from %s” % callerId)
while True:
agi.stream_file(‘vm-extension’)
result = agi.wait_for_digit(-1)
agi.verbose(“got digit %s” % result)
if result.isdigit():
agi.say_number(result)
else:
agi.verbose(“bye!”)
agi.hangup()
sys.exit()
CLI debugging output:
Launched AGI Script /etc/asterisk/ivr2.py
<SIP/10.192.93.170-00000000>AGI Tx >> agi_request: /etc/asterisk/ivr2.py
<SIP/10.192.93.170-00000000>AGI Tx >> agi_channel: SIP/10.192.93.170-00000000
<SIP/10.192.93.170-00000000>AGI Tx >> agi_language: en
<SIP/10.192.93.170-00000000>AGI Tx >> agi_type: SIP
<SIP/10.192.93.170-00000000>AGI Tx >> agi_uniqueid: 1575963726.0
<SIP/10.192.93.170-00000000>AGI Tx >> agi_version: 16.6.2
<SIP/10.192.93.170-00000000>AGI Tx >> agi_callerid: 993998879
<SIP/10.192.93.170-00000000>AGI Tx >> agi_calleridname: 993998879
<SIP/10.192.93.170-00000000>AGI Tx >> agi_callingpres: 0
<SIP/10.192.93.170-00000000>AGI Tx >> agi_callingani2: 0
<SIP/10.192.93.170-00000000>AGI Tx >> agi_callington: 0
<SIP/10.192.93.170-00000000>AGI Tx >> agi_callingtns: 0
<SIP/10.192.93.170-00000000>AGI Tx >> agi_dnid: IMS-CRBT-IVR
<SIP/10.192.93.170-00000000>AGI Tx >> agi_rdnis: unknown
<SIP/10.192.93.170-00000000>AGI Tx >> agi_context: sip_in
<SIP/10.192.93.170-00000000>AGI Tx >> agi_extension: IMS-CRBT-IVR
<SIP/10.192.93.170-00000000>AGI Tx >> agi_priority: 1
<SIP/10.192.93.170-00000000>AGI Tx >> agi_enhanced: 0.0
<SIP/10.192.93.170-00000000>AGI Tx >> agi_accountcode:
<SIP/10.192.93.170-00000000>AGI Tx >> agi_threadid: 139771390002944
<SIP/10.192.93.170-00000000>AGI Tx >>
<SIP/10.192.93.170-00000000>AGI Rx << VERBOSE “python agi started” 1
/etc/asterisk/ivr2.py: python agi started
<SIP/10.192.93.170-00000000>AGI Tx >> 200 result=1
<SIP/10.192.93.170-00000000>AGI Rx << VERBOSE “call from 993998879” 1
/etc/asterisk/ivr2.py: call from 993998879
<SIP/10.192.93.170-00000000>AGI Tx >> 200 result=1
<SIP/10.192.93.170-00000000>AGI Rx << STREAM FILE vm-extension “” 0
– <SIP/10.192.93.170-00000000> Playing ‘vm-extension.gsm’ (escape_digits=) (sample_offset 0) (language ‘en’)
<SIP/10.192.93.170-00000000>AGI Tx >> 200 result=0 endpos=8800
I tried many similar codes and got the same result
please any help about this problem
Many Thanks in Advance