We are in the process right now of creating an application that needs asynchronous AMD. Specifically, we are implementing LumenVox’s CPA product and the use case is this:
* Reminder call is placed to recipient
* Recipient answers (don’t yet know if it is a human or a machine)
* Outgoing message begins to play
* If a human is detected, stop playback and connect to an agent
* If a machine is detected, keep playing back until…
* If a beep is detected, stop and restart playback
The only way to achieve this is if we can have an async speech recognizer running while simultaneously playing output, which isn’t possible with Dialplan today, and would require a specialized app even if it were implemented that way. Instead, we are hoping to have a lower-level primitive to do signals detection and playback asynchronously.
In an ideal world, ARI would provide primitives for playback (file or TTS) and input (DTMF or ASR). Some more background from discussion related to our project, courtesy Ben Langfeld:
The asynchronous example is more complex. While Adhearsion sees both the input and output components as being asynchronous, this is a fake facility provided by Punchblock to make Asterisk look like an async server when it is not. Both components are implemented atop synchronous Asterisk dialplan applications:
This means that given the simplest approach to implementation discussed above, the output would be executed, followed by the input being queued and executed once the output had completed. If we were to swap the two, not only would we now have a coordination problem where we have to queue cancellation of the output to paper over the race condition introduced by potentially being asked to stop it before we have a handle on it, we would have the same blocking problem with
So that rules out combining one of the UniMRCP dialplan applications with the
Playback() application in this fashion. There are two other remaining solutions that come to mind:
A prompt command to combine the output and input into a single dialplan application invocation (
MRCPRecog() for native file playback,
SynthAndRecog() for TTS). This avoids the problem of multiple dialplan applications blocking one another, but introduces a fresh one: these applications terminate output as soon as recognition completes (or earlier if barge-in is enabled). There is no opportunity to inject logic to filter the recognition result prior to terminating the output, nor do I think this would make sense.
The Asterisk Speech API (
SpeechBackground(), etc). If
SpeechBackground() this would be the obvious solution, but it unfortunately is not.
SpeechBackground() actually sits in a loop, directing audio frames to the recognizer while simultaneously rendering frames of audio (the first option is a file path). The app does not return until recognition has completed, so cannot be combined with
Playback(). Upon recognition completion, the output will be terminated, regardless of the recognition result, so this suffers the same problem as Rayo Prompt. It is also not possible to use any other output renderer, such as a TTS engine via MRCP.
- Can we implement Asterisk/Lumenvox CPA in way to be compatible with the adhearsion-cpa controller methods API?
The problems stated above leave us with only one option: extra capability must be introduced to Asterisk in order to handle simultaneous dialplan applications, or to introduce a true async version of
SpeechBackground(). The viability of this is something that must be discussed with the Asterisk project / Digium. Note that FreeSWITCH already has this capability, but would also need less invasive changes to cope with LumenVox CPA as stated above; a far more approachable task.
In short, the adhearsion-cpa API can be honoured for the synchronous detection case trivially. It cannot be honoured for the async case, nor can any equivalent alternative be introduced, without changes to Asterisk.
Principal/Technology Strategist, Mojo Lingo
Mojo Lingo -- Voice applications that work like magic