Voice Activity Detection and BackgroundDetect()

Hey Asterisk Users,

I noticed something that seemed a bit odd, perhaps I’ve missed something. Perhaps it’s a bug.
If I enable Voice Activity Detection on my Yealink phone then BackgroundDetect() takes almost forever to go to its next stage. As if not receiving audio packets doesn’t increment the milliseconds for timeout?

(I suspect it’s catching blips of background noise which generate a packet then calculating the edge timings on those packets that are silent)

Please show us your dialplan.

Here it is, same effect with and without the jitter buffer.

exten => 30000,1,Answer()
same => n,Set(JITTERBUFFER(adaptive)=300,60)
same => n,MixMonitor(${UNIQUEID}.wav)
same => n,Set(i=1)
same => n,While($[${i} < 17])
same => n,Playback(/var/lib/asterisk/Lenny/Lenny${i})
same => n,BackgroundDetect(/var/lib/asterisk/Lenny/backgroundnoise,1500)
same => n,Set(i=$[${i} + 1])
same => n,EndWhile
same => n,Set(i=${RAND(5,16)})
same => n,While($[${i} < 17])
same => n,Playback(/var/lib/asterisk/Lenny/Lenny${i})
same => n,BackgroundDetect(/var/lib/asterisk/Lenny/backgroundnoise,1500)
same => n,Set(i=${RAND(2,15)})
same => n,EndWhile
same => n,Hangup

You don’t have a talk extension.

Per: Asterisk 18 Application_BackgroundDetect - Asterisk Project - Asterisk Project Wiki

Plays back filename , waiting for interruption from a given digit (the digit must start the beginning of a valid extension, or it will be ignored). During the playback of the file, audio is monitored in the receive direction, and if a period of non-silence which is greater than min ms yet less than max ms is followed by silence for at least sil ms, which occurs during the first analysistime ms, then the audio playback is aborted and processing jumps to the talk extension, if available.

See a working Lenny example:

Hi PitzKey,

It works without VAD on the original dialplan, but to demonstrate the point I implemented this one.
Issue still occurs.

[Lenny]
exten => talk,1,Set(i=${IF($[“0${i}”=“016”]?7:$[0${i}+1])})
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
same => n,Playback(/var/lib/asterisk/Lenny/Lenny${i})
same => n,BackgroundDetect(/var/lib/asterisk/Lenny/backgroundnoise,1500)

[realthings]

exten => 30000,1,Answer()
same => n,Set(JITTERBUFFER(adaptive)=300,60)
same => n,GoTo(Lenny,talk,1)

VAD isn’t supported in Asterisk, so it is entirely possible that some things expect a constant stream of audio and do not behave as expected when it is not present in particular older applications.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.