Detect silence while playing sound

I am developing an java-asterisk application that is calling subscribers to deliver messages. At some moments during the call, I need to monitor whether the subscriber is talking or is silent. I need to monitor that for a fairly long time (1-3 seconds) but don’t want to interrupt the flow of the outgoing message.
The way I am doing it now is as below

streamFile(*file A*);
streamFile(*file B*);[/code]

This works fine but it is only a 300ms detect and a 1s timeout, so from the subscriber point of view the silence between file A and file B is almost unnoticeable. But if I want to listen for longer (say 3 seconds for example) then the subscriber’s experience will be ruined.

What I would need is a function similar to “WaitForSilence” but that:


  • runs in parallel to the script;
  • delivers its outcome in a variable channel with a name that I define (as there might be several calls to the function, and I need to get all the results)[/ul]

I’ve been looking for more than aweek now and couldn’t find a way to do that. Any ideas?

You will always get some echo, so you will never get silence.

More importantly, Asterisk will be running autoservice which will throw away everything except DTMF digits. Basically your requirement is not supported.

I’m not sure if AGI allows access to both the send and receiver audio streams, If it does, remember to set your silence threshold high enough to cope with the worst case echo.