How to call and also include agi file at same time?

[Long-Distance]
;Simple speech recognition
exten => _11XX,1,Answer()
exten => _11XX,n,dial(pjsip/${EXTEN})
exten => _11XX,n,agi(speech-recog.agi,en-US)
exten => _11XX,n,Verbose(1,The text you just said is: ${utterance})
exten => _11XX,n,Verbose(1,The probability to be right is: ${confidence})
exten => _11XX,n,Hangup()

In the above code, I can just make call can’t Include my agi script.

For your reference, I working on real-time speech recognition and this agi script provide that Speech to Text.

Please explain what you are trying to achieve, rather than how you are trying to achieve it, as it looks like your current how may be based on fundamental misunderstandings of how Asterisk works.

It is particularly unclear to me as to who is the subject of the text to speech.

One of your misunderstandings seems to be a common one that Dial just mean dial. Dial includes the whole supervision of the outgoing call, and, in particular the bridge, so when Dial ends, there is no outgoing leg left.

If you want the initial calling party to drop out, you need to use Originate. If you want let Google know the complete contents of conversation, including both parties, you probably want to use a conference bridge. If you want them only to eavesdrop one side, you might want to use ChanSpy. The last two, in particular, are not trivial, but seem to be done often enough that Google should turn up some information on the details.

Recording the call and processing it when ti completes my be an approach to some scenarios.

first of all sorry, yeah I am new in asterisk, I started asterisk last from 3 weeks and I am basically a jr OOP programmer so this field very new to me.
Just like in OOP(Object Oriented Programming) call means go to another file’s module and complete execution and return back to the old program, so yes Because of my technical jargons misunderstanding annoying you, I am really sorry for my inconvenience and I’ll try to improve my self.

So let’s come to the point which you didn’t get, So David let’s take a simple example I have to parties 1101 and 1103, whenever I dial means send a call request to 1103, 1103 ringing and it accepts that and bridge established now I can communicate with that, Hope till here you get.

But now I want to implement SPEECH to TEXT translation whose code written in agi file, you can see I dial that in my dialplan at 3rd extent.

So SPEECH to TEXT is a totally external program so we do not worry about how it works.

But my main doubt here, the bridge established, I can communicate then why my

exten => _11XX,n,agi(speech-recog.agi,en-US)

this dialplan line is not executing?

What happened in my case,

It’s simply established call and then hanged.
Just like below code,

[Long-Distance]
;Simple speech recognition
exten => _11XX,1,Answer()
exten => _11XX,n,dial(pjsip/${EXTEN})
;exten => _11XX,n,agi(speech-recog.agi,en-US)
;exten => _11XX,n,Verbose(1,The text you just said is: ${utterance})
;exten => _11XX,n,Verbose(1,The probability to be right is: ${confidence})
exten => _11XX,n,Hangup()

It never executes those commented lines.

I am sorry I do not know much about ASTERISK and AGI that’s why I failed to debug.

Connected to Asterisk 16.15.1 currently running on test-VirtualBox (pid = 5238)
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.
    -- Added contact 'sip:1103@192.168.1.2:56543;transport=UDP;rinstance=c894080b1efed129' to AOR '1103' with expiration of 60 seconds
  == Endpoint 1103 is now Reachable
  == Setting global variable 'SIPDOMAIN' to '192.168.1.5'
    -- Executing [1103@Long-Distance:1] Answer("PJSIP/1101-00000000", "") in new stack
       > 0x7f57f0035190 -- Strict RTP learning after remote address set to: 103.241.224.105:25568
       > 0x7f57f0035190 -- Strict RTP qualifying stream type: audio
       > 0x7f57f0035190 -- Strict RTP switching source address to 192.168.1.3:7078
    -- Executing [1103@Long-Distance:2] Dial("PJSIP/1101-00000000", "pjsip/1103") in new stack
    -- Called pjsip/1103
    -- PJSIP/1103-00000001 is ringing
    -- PJSIP/1103-00000001 is ringing
       > 0x7f57f0024140 -- Strict RTP learning after remote address set to: 192.168.1.2:58308
    -- PJSIP/1103-00000001 answered PJSIP/1101-00000000
    -- Channel PJSIP/1103-00000001 joined 'simple_bridge' basic-bridge <43ffb0c1-3a80-4647-8f63-faa87006706d>
       > 0x7f57f0024140 -- Strict RTP switching to RTP target address 192.168.1.2:58308 as source
    -- Channel PJSIP/1101-00000000 joined 'simple_bridge' basic-bridge <43ffb0c1-3a80-4647-8f63-faa87006706d>
       > Bridge 43ffb0c1-3a80-4647-8f63-faa87006706d: switching from simple_bridge technology to native_rtp
       > Locally RTP bridged 'PJSIP/1101-00000000' and 'PJSIP/1103-00000001' in stack
       > 0x7f57f0035190 -- Strict RTP learning complete - Locking on source address 192.168.1.3:7078
    -- Channel PJSIP/1103-00000001 left 'native_rtp' basic-bridge <43ffb0c1-3a80-4647-8f63-faa87006706d>
    -- Channel PJSIP/1101-00000000 left 'native_rtp' basic-bridge <43ffb0c1-3a80-4647-8f63-faa87006706d>
  == Spawn extension (Long-Distance, 1103, 2) exited non-zero on 'PJSIP/1101-00000000'
test-VirtualBox*CLI> 

Maybe this work for you, I can place a call but never my agi script execute

You should re-read david551’s explanation until it make sense :slight_smile:

Let’s look at this from a practical example.

From my handset, I dial 1101. Your dialplan answers my call, and then it dials endpoint 1101 whom we are assuming will answer my call. The dial() application handles all the dialing and bridging stuff until the call is terminated (either party hangs up).

The important thing to grasp is that the dial() application does not return and execute the next line of the dialplan until the call is terminated. Your AGI cannot execute until then. Even then, since you did not include the ‘g’ dial() option, execution will not continue after the dial() application, execution will continue at the ‘h’ extension (‘${context},h,1.’). Thus there is no way ANY subsequent step in the dialplan will be executed.

I suggest you take david551’s suggestion:

thanks, sedwards

I got some helpful points from your answer now I have some more clearance how Dial actual work.

But question is, can’t I execute agi() while dial() is running or not terminated yet?

Because happened what, first I need to call from any extension 1101 or 1103 then it’s established bridge and I can communicate but as I said earlier I need to SPEECH to TEXT translation in real-time means without hangup my current call or terminate bridge.

And one more thing can you give me a resource to understand more about those ‘g’ and ‘h’ command as far I know ‘h’ means hangup extension but I’m unclear on ‘g’ so.

Nope.

‘g’ - The dial() application (and it’s options) is documented at Application_Dial and at the Asterisk Command Line Interface (CLI) by entering ‘core show application dial’.
‘h’ - The ‘h’ extension is documented at Special Dialplan Extensions.

While the call is in progress you want to receive text?

1 Like

Yeah just like I say on call “Hello World” and my agi script take this as Audio input and send output to my cli in text, don’t worry about Speech To Text it’s all external part.

But point is I should not hangup my call.

So you say ‘hello world’ and the text ‘hello world’ is printed to the CLI. And then I say ‘my name is not world’ and this text is printed on the CLI so that as our conversation continues a live transcript is printed in the CLI?

That’s not how this works. This AGI records audio to a file and then ships it off to Google to transcribe it.

Yeah as I said it’s an external task we don’t need to worry about that right now, We just want that our agi should run during the call so we go further to transcribe. SPEECH to TEXT is not our concern.

It doesn’t work that way. Maybe you could investigate other methods of call control like async AGI, AMI, or ARI.

Only my record the call option is ruled out so far.

I would note that, even with a human palantype operator, real time text to speech requires back tracking.

Sorry david but this thing is not understand by me.

In that case you have taken on something beyond your skill level.

I know but I have to do no matter what

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