Synchronous Dialplan Execution For Feedback While Processing Speech Recognition And Voice Synth, For Example.
I’ve got an agi that recognises speech (via Google) and another that turns text into speech (tts) (via Microsoft Translate).
Both are web APIs, both called via seperate python AGIs.
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.
Both agis take about 2.5 seconds, so that’s 5 seconds of silence.
Yes, I’m aware of software applications that will quickly recognise and synthesize speech on the local machine, but they’re not suitable for the application.
I realise there’s probably a pythonic way of forking processes, but the way it is now, both agis are nice seperate single purpose functions and it all just looks quite neat as it is.
Many thanks.
One thought on - Synchronous Dialplan Execution For Feedback While Processing Speech Recognition And Voice Synth, For Example.
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@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()