Answering Machine Detection with WaitForSilence

From Etel

Jump to: navigation, search

Contents

Title

WaitForSilence() Answering Machine Detection

Problem

Using WaitForSilence() to detect when to start the Play() application when leaving a message on an answering machine.

Solution

When using the WaitForSilence() application, there are three parameters.


SILENCE DURATION is the duration, in milliseconds, of silence to wait for
SILENCE OCCURANCES is the number of occurances for a silence of duration in milliseconds
SILENCE TIMEOUT is the total time for the application to wait after the timeout it will release control back to the dialplan

[amd-stuff]
exten => 11,1,NoOp( Starting exten 11 AMD stuff)
exten => 11,n,Set(SILENCEDURATION=4300)
exten => 11,n,Set(SILENCEOCCURANCES="")
exten => 11,n,Set(SILENCETIMEOUT=38)
exten => 11,n,NoOp( SILENCEDURATION=${SILENCEDURATION} )
exten => 11,n,NoOp( SILENCEOCCURANCES=${SILENCEOCCURANCES} )
exten => 11,n,NoOp( SILENCETIMEOUT=${SILENCETIMEOUT} )
exten => 11,n,Answer
exten => 11,n,WaitForSilence(${SILENCEDURATION},${SILENCEOCCURANCES},${SILENCETIMEOUT})
exten => 11,n,NoOp(Retnd WAITSTATUS=${WAITSTATUS} )
exten => 11,n,Playback(lax/lax-important-msg-from)
exten => 11,n,Playback(tt-weasels)
exten => 11,n,Wait(1)
exten => 11,n,Hangup


The Associated Call File

#This is a sample file that can be dumped in /var/spool/asterisk/outgoing
# to generate a call.
Channel: Zap/3/7780811
Context: amd-stuff
Extension: 11
Priority: 1
#
Callerid: Call Msg Service <(856) 555-5555>



Verbosity is at least 3
    -- Attempting call on Zap/3/7780811 for 11@amd-stuff:1 (Retry 1)
    -- Executing [11@amd-stuff:1] NoOp("Zap/3-1", " Starting exten 11 AMD stuff") in new stack
    -- Executing [11@amd-stuff:2] Set("Zap/3-1", "SILENCEDURATION=4300") in new stack
    -- Executing [11@amd-stuff:3] Set("Zap/3-1", "SILENCEOCCURANCES=""") in new stack
    -- Executing [11@amd-stuff:4] Set("Zap/3-1", "SILENCETIMEOUT=38") in new stack
    -- Executing [11@amd-stuff:5] NoOp("Zap/3-1", " SILENCEDURATION=4300 ") in new stack
    -- Executing [11@amd-stuff:6] NoOp("Zap/3-1", " SILENCEOCCURANCES= ") in new stack
    -- Executing [11@amd-stuff:7] NoOp("Zap/3-1", " SILENCETIMEOUT=38 ") in new stack
    -- Executing [11@amd-stuff:9] Answer("Zap/3-1", "") in new stack
    -- Executing [11@amd-stuff:10] WaitForSilence("Zap/3-1", "4300||38") in new stack
    -- Waiting 1 time(s) for 4300 ms silence with 0 timeout
    -- Exiting with 4300ms silence >= 4300ms required
    -- Executing [11@amd-stuff:11] NoOp("Zap/3-1", "Retnd WAITSTATUS=SILENCE ") in new stack
    -- Executing [11@amd-stuff:12] Playback("Zap/3-1", "lax/lax-important-msg-from") in new stack
    -- <Zap/3-1> Playing 'lax/lax-important-msg-from' (language 'en')
    -- Executing [11@amd-stuff:13] Playback("Zap/3-1", "tt-weasels") in new stack
    -- <Zap/3-1> Playing 'tt-weasels' (language 'en')
    -- <Zap/3-1> Playing 'lax/lax-important-msg-from' (language 'en')
    -- Executing [11@amd-stuff:15] Wait("Zap/3-1", "1") in new stack
    -- Executing [11@amd-stuff:16] Hangup("Zap/3-1", "") in new stack
  == Spawn extension (amd-stuff, 11, 16) exited non-zero on 'Zap/3-1'
    -- Hungup 'Zap/3-1'
[Nov  6 00:13:48] NOTICE[2540]: pbx_spool.c:351 attempt_thread: Call completed to Zap/3/7780811

Discussion


This example is setup to test a variety of answering machines.
We use the Set() application to provide easy access to changing the parameters to WaitForSilence().
The WaitForSilence() is used immediately after the Answer() and the dialplan will wait 38 seconds for one occurance of silence of duration of 4300 milliseconds before returning control back to the dialplan.
In the CLI> output, notice the '-- Waiting 1 time(s) for 4300ms silence'. and the next line '-- Exiting with 4300ms silence'. The dialplan was waiting for the answering machine message to complete, beep, and stop to record the inbound voice or message. Note, each answering machine may have its own time limit it waits before hanging up when there is no audio/voice detected.
To use this, the call file is moved to the /var/spool/asterisk/outgoing directory. Asterisk picks up that .call file and processes the call.
This application sets the channel variable named WAITSTATUS to either SILENCE (silience found) or TIMEOUT (timeout reached). In this example, we print out the WAITSTATUS but do not act on it.

See Also:


AMD()
WaitForRing()

Metadata

  • By: Dave Cantera
  • Solves problem (optional; a problem from the Solutions Needed list
  • Outline reference (optional); a link to a chapter in the outline or, even better, to a specific topic
Personal tools