1

Sorry in advance if my question makes no sense to you. I am newbie in asterisk, and what I am trying to do is writing a dial plan which can connects 2 soft phone end point (VoIP client end points) and then try to detect silence in ongoing call. I am able to make through call by using following dial plan

exten = 100, 1, Answer() 
same =  100, n, Monitor()
same =  100, n, Dial(SIP/client1,15) 

when I dialed 100, it makes call to client1, which I received gracefully and now call is on going, now I mute my both end mics (caller and callee), the call is still going. Recording of each channel is creating properly. Now I need to fire an event whenever there is silence detected for 3 seconds and I need to grab that audio chunk till silence.

Any idea how I can achieve this objective ?

Zubair
  • 33
  • 1
  • 8

2 Answers2

4

In Asterisk 13, you can use the TALK_DETECT dialplan function:

Synopsis

Raises notifications when Asterisk detects silence or talking on a channel.

Description

The TALK_DETECT function enables events on the channel it is applied to. These events can be emited over AMI, ARI, and potentially other Asterisk modules that listen for the internal notification.

Keep in mind that TALK_DETECT only looks for audio coming from the device side of the channel, i.e., the read side. Thus, if we want to raise events for both channels, we need to apply it to each channel. As an example, the following would apply talk detection to both channels by using a pre-dial handler on the outbound channel:

[default]

exten => 100,1,Answer()
 same => n,Set(TALK_DETECT(set)=)
 same => n,Monitor()
 same => n,Dial(SIP/client1,15,b(default^apply_talk_detect^1)) 
 same => n,Hangup()

exten => apply_talk_detect,1,NoOp()
 same => n,Set(TALK_DETECT(set)=)
 same => n,Return()

Using this, you should get the AMI event ChannelTalkingStart event when talking is detected, and ChannelTalkingStop event when one of the channels stops talking. Your external application can then look to see if there is a three second gap between the events, and take action accordingly.

Matt Jordan
  • 2,899
  • 1
  • 27
  • 29
  • Great Tip Matt, But I need to pick the audio chunk, problem here is, the Monitor file is not available until the call get finish. How can I get it ? – Zubair Jan 03 '16 at 12:38
  • 1
    If you need the audio in realtime, then using Monitor directly is not appropriate. Instead, you could use ChanSpy to forward that audio to some other location. If what you want is an audio file, you would send the spying channel into a Record application. When your events fire using the Talk Detection events I mentioned, you would hang up the spying channel and retrieve the file that it created. – Matt Jordan Jan 03 '16 at 16:47
  • Thanks Matt, this one works exactly what I want. Answer accepted – Zubair Jan 06 '16 at 14:31
  • 1
    Hi Matt, Just have a question can we apply TALK_DETECT on receiving channel ? as in above solution the initiator is under detection but not receiver – Zubair Jan 15 '16 at 12:09
1

There are no such functionality in asterisk

You can create your own c/c++ application or attach another channel using ChanSpy and use SilenceDetect command + UserEvent command.

However such dialplan is not for newbie,sorry

Tirtha
  • 529
  • 2
  • 10
  • 23
arheops
  • 15,544
  • 1
  • 21
  • 27