asterisk silence detection on connected call

2019-08-10 12:08发布

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 ?

2条回答
仙女界的扛把子
2楼-- · 2019-08-10 12:57

There are no such functionallity in asterisk

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

However such diaplan is not for newbie,sorry

查看更多
唯我独甜
3楼-- · 2019-08-10 13:15

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.

查看更多
登录 后发表回答