[asterisk-users] Synchronous dialplan execution for feedback while processing speech recognition and voice synth, for example.

Jonathan H lardconcepts at gmail.com
Fri Nov 18 17:45:25 CST 2016


Right, well I tried a few things (I mean, days of things) and this is
what I came up with.

2 Questions:
1: Is there a simpler way?
2: Is there a trick to pass back a variable to the calling channel,
rather than setting a global?

(This is for an agi process that can take up to ten seconds to query a
web API and come back with a list of maybe ten items).

[synctest3a]
; starts a new channel on 3b and sets the variable it's going to need
using "b" param
; starts music class using "m" param, and then makes the call

exten => s,1,Answer()
    same => n,Dial(Local/s at synctest3b,,gm(wait-long-process)b(synctest3b^setVar^1(from
calling channel)))
    same => n,Verbose(1,${test}) ; set by the global in 3b
    same => n,Set(GLOBAL(test)="") ; stop it polluting other calls
    same => n,Hangup()

[synctest3b]
; kicks into action with some long process (agi for example)
; when process is complete, it answers the call and sets global
; it then hangs up, music on hold stops, 3a resumes

exten => s,1,Wait(2)
    same => n,Verbose(1,${testVar})
    same => n,Set(GLOBAL(test)=true) ;
    same => n,Answer()
    same => n,Hangup()
exten => setVar,1,Set(testVar=${ARG1}) ; setter
    same => n,Return()

On 3 October 2016 at 23:48, Steve Edwards <asterisk.org at sedwards.com> wrote:
> On Mon, 3 Oct 2016, Jonathan H wrote:
>
>> I've googled and I'm probably missing something pretty newbie 101 here,
>> but is there any way, or fiddle, that I can play some audio to let the
>> caller know that their weather forecast is being fetched, which the two agis
>> are first recognising and then synthesizing the speech? I thought
>> "background" might do it, but it doesn't seem to work like that.
>
>
> Did something similar a decade ago :)
>
> I had a credit card processing AGI for an adult audiotext line. The owner
> was a real stickler for the 'caller experience' and didn't like the dead air
> waiting for the auth back from the card processor.
>
> My solution was to kick off a thread (the AGI was written in C, so I used
> pthreads) to play 'and get ready for a good time' and then issue the request
> to the card processor and waiting for the response in the mainline code.
>
> By the time the prompt finished, I had the response so pthread_join would
> 'finish' off the thread cleanly and the dead air magically disappeared.
>
> The only 'warning' is not to do any I/O to STDIN/STDOUT in the mainline --
> that would violate the AGI protocol and lead to things breaking in weird
> ways.
>
> --
> Thanks in advance,
> -------------------------------------------------------------------------
> Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
>             https://www.linkedin.com/in/steve-edwards-4244281
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
>       http://www.asterisk.org/community/astricon-user-conference
>
> New to Asterisk? Start here:
>       https://wiki.asterisk.org/wiki/display/AST/Getting+Started
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users



More information about the asterisk-users mailing list