Skip to main content

mod_dptools: wait_for_silence

About

This page describes how the application wait_for_silence works.

Usage

wait_for_silence <silence_thresh> <silence_hits> <listen_hits> <timeout_ms> [<file>]

Description

Pause dialplan execution while waiting for a certain length of silence on the channel. When silence is detected, or when the timeout period has expired, dialplan processing will continue.

"Silence" is determined by a combination of the <silence_thresh> value and the <silence_hits> value.

  • The silence_thresh value is the silence threshold. The lower the value, the "quieter" the channel must be in order to be considered in a silent state. the numbers have to be *bigger* not smaller to make it harder to detect silence
  • The silence_hits value represents the number of consecutive frames received with an "energy level" below the silence_thresh value that must be seen before the channel is considered in a silent state. The higher this value, the longer the channel must be in a "silent" state before silence is detected.
  • The <listen_hits> value represents the number of frames of non-silence to be counted on the channel prior to engaging the silence detection. The higher this value, the more "noisy" frames that must be seen before silence detection begins.
  • The <timeout_ms> value represents the number of milliseconds that the wait_for_silence app will attempt to detect silence before giving up and moving on with the dialplan processing.
  • <file> is an optional sound file that can be read and analyzed for silence detection.

Dialplan Example

<action application="wait_for_silence" data="200 15 10 5000"/>
  • The above example will do the following:
  • Wait for 10 "noisy" frames to be heard, then
  • Wait for 15 consecutive "silent" frames (energy score less than 200) to be heard, then
  • Continue with dialplan processing

To emulate the behavior of the Asterisk WaitForSilence, which allows one to specify the number of iterations of the wait for silence process, simply stack as many wait_for_silence calls as desired. The following dialplan snippet will generally do a good job of waiting for an answering machine to finish its outgoing message before continuing:

<action application="wait_for_silence" data="200 15 15 5000"/>
<action application="sleep" data="1000"/>
<action application="wait_for_silence" data="200 15 15 5000"/>
<action application="sleep" data="1000"/>
<action application="wait_for_silence" data="200 15 15 5000"/>
<action application="sleep" data="1000"/>

Also see detect_silence for silence detection without requiring noise first.