Why AGI script terminating?

test-VirtualBox*CLI> module load res_speech.so
Loaded res_speech.so
test-VirtualBox*CLI> module load res_agi.so
Loaded res_agi.so
test-VirtualBox*CLI> agi set debug on
AGI Debugging Enabled
test-VirtualBox*CLI> core set verbose 4
Console verbose was OFF and is now 4.
  == Setting global variable 'SIPDOMAIN' to ''
    -- Executing [1234@Long-Distance:1] Answer("PJSIP/1101-00000000", "") in new stack
       > 0x7f81a00210c0 -- Strict RTP learning after remote address set to:
       > 0x7f81a00210c0 -- Strict RTP qualifying stream type: audio
       > 0x7f81a00210c0 -- Strict RTP switching source address to
    -- Executing [1234@Long-Distance:2] AGI("PJSIP/1101-00000000", "speech-recog.agi,en-US") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
<PJSIP/1101-00000000>AGI Tx >> agi_request: speech-recog.agi
<PJSIP/1101-00000000>AGI Tx >> agi_channel: PJSIP/1101-00000000
<PJSIP/1101-00000000>AGI Tx >> agi_language: en
<PJSIP/1101-00000000>AGI Tx >> agi_type: PJSIP
<PJSIP/1101-00000000>AGI Tx >> agi_uniqueid: 1611306068.0
<PJSIP/1101-00000000>AGI Tx >> agi_version: 16.15.1
<PJSIP/1101-00000000>AGI Tx >> agi_callerid: 1101
<PJSIP/1101-00000000>AGI Tx >> agi_calleridname: Maria Berny
<PJSIP/1101-00000000>AGI Tx >> agi_callingpres: 0
<PJSIP/1101-00000000>AGI Tx >> agi_callingani2: 0
<PJSIP/1101-00000000>AGI Tx >> agi_callington: 0
<PJSIP/1101-00000000>AGI Tx >> agi_callingtns: 0
<PJSIP/1101-00000000>AGI Tx >> agi_dnid: 1234
<PJSIP/1101-00000000>AGI Tx >> agi_rdnis: unknown
<PJSIP/1101-00000000>AGI Tx >> agi_context: Long-Distance
<PJSIP/1101-00000000>AGI Tx >> agi_extension: 1234
<PJSIP/1101-00000000>AGI Tx >> agi_priority: 2
<PJSIP/1101-00000000>AGI Tx >> agi_enhanced: 0.0
<PJSIP/1101-00000000>AGI Tx >> agi_accountcode: 
<PJSIP/1101-00000000>AGI Tx >> agi_threadid: 140196669904640
<PJSIP/1101-00000000>AGI Tx >> agi_arg_1: en-US
<PJSIP/1101-00000000>AGI Tx >> 
<PJSIP/1101-00000000>AGI Rx << SET VARIABLE "confidence" "-1"
<PJSIP/1101-00000000>AGI Tx >> 200 result=1
<PJSIP/1101-00000000>AGI Rx << SET VARIABLE "utterance" "-1"
<PJSIP/1101-00000000>AGI Tx >> 200 result=1
<PJSIP/1101-00000000>AGI Rx << CHANNEL STATUS
<PJSIP/1101-00000000>AGI Tx >> 200 result=6
<PJSIP/1101-00000000>AGI Rx << GET FULL VARIABLE ${CHANNEL(audionativeformat)}
[Jan 22 14:31:08] ERROR[7489][C-00000001]: pbx_functions.c:651 ast_func_read2: Function CHANNEL not registered
<PJSIP/1101-00000000>AGI Tx >> 200 result=1 ()
<PJSIP/1101-00000000>AGI Rx << RECORD FILE /tmp/stt_tIZFBW sln "#" "5" BEEP "s=2"
    -- <PJSIP/1101-00000000> Playing 'beep.gsm' (language 'en')
[Jan 22 14:31:09] WARNING[7489][C-00000001]: file.c:1504 ast_writefile: No such format 'sln'
<PJSIP/1101-00000000>AGI Tx >> 200 result=-1 (writefile)
    -- <PJSIP/1101-00000000>AGI Script speech-recog.agi completed, returning -1
    -- Executing [1234@Long-Distance:3] Verbose("PJSIP/1101-00000000", "1,The text you just said is: -1") in new stack
 The text you just said is: -1
    -- Executing [1234@Long-Distance:4] Verbose("PJSIP/1101-00000000", "1,The probability to be right is: -1") in new stack
 The probability to be right is: -1
    -- Executing [1234@Long-Distance:5] Hangup("PJSIP/1101-00000000", "") in new stack
  == Spawn extension (Long-Distance, 1234, 5) exited non-zero on 'PJSIP/1101-00000000'

I am trying to call agi script but it terminates and give an error like above what am I doing wrong?

My PJSIP.conf:
pjsip1.txt (944 Bytes)
My Extensions.conf:
extensions1.txt (322 Bytes)

Can anybody tell what is the error?

Not without the contents of the script.

speech-recog.txt (8.6 KB)


Official author of the above script is Lefteris Zafiris
hope this will help
Note: I can’t upload .agi file that’s why I changed the extension of a file to .txt.

Sorry for my half explanation and do not provide Name of the author.

As it says, Asterisk doesn’t have a format called sln.

I thought you wanted real time speech to text, but you seem to be recording the audio.

As a general point, you are using language features that write to standard error, but you don’t seem to have redirected standard error to a file, so finding the output of those may be difficult.

It’s interesting that you don’t use a class library for AGI. Whilst I have reservations about them, as they seem to add little value and obscure what is really happening, most people seem to use them.

yeah david but I made below step
make menuselect
make install

and in menuselect I select sln media type and install that.

And yes I am tried to real time speech to text but due to some leak of knowledge I first record that and then send to api for speech to text.

But David can you please tell me what is this,

Thank you

I don’t understand that, as I thought that that function was implemented in the Asterisk core. Maybe it is treating it as a request for a global variable, because you haen’t provided a channel name. Unfortunately the wiki, for GET FULL VARIABLE, appears to be wrong in multiple ways, but I don’t have time to look at the code to find out exactly how it does work.

1 Like

It is provided by the func_channel module.

@Yash3120 Are you selectively loading modules? If so, then you are using functionality from modules you haven’t loaded (such as func_channel and format_sln).

thanks error gone yeah I load module manually

Yash3120 is not the author of the AGI, Lefteris Zafiris (zaf@fastmail.com) is.

Yes, you can see I given link of official GitHub link in above one the thread.

And sorry for my inconvenience I did not mention his full name, I just provide github link.

I apologies for that.

If you load it manually, it will ‘go away’ again when you restart Asterisk.

You should take a look at your ‘modules.conf’ file.

I note this, yeah okay I have enable at auto load so I don’t have to load everytime.

Thanks :+1:

That’s an interesting perspective.

An AGI library does obscure the foundations of the protocol:

  1. Asterisk ‘owns’ STDIN/STDOUT and anything you do to those streams is not going to end well.
  2. The protocol is ‘single line oriented, request and response’ meaning you issue a single line request, and you get a single line response (IIRC).
  3. You have to read the ‘AGI environment’ Asterisk gives you before you can do anything – even if you don’t need anything from it.

But using a library makes the feature available to a class of programmers who don’t wake up in the morning excited that they can start the day with a deep dive into the Asterisk source code.

I fall somewhere inbetween :slight_smile:

I know the protocol pretty well (at least I used to :slight_smile: ) and I use a library because it improves the quality of my code and reduces the quantity of code I have to write.


client_id = agi_get_integer_variable("CLIENT-ID");

beats typing the approximately 100 lines of C code that implement it.

The no SLN format can be part of the problem

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