[Freeswitch-users] mod_avmd false positives, ineffecient

Michael Collins msc at freeswitch.org
Mon Apr 9 21:18:02 MSD 2012

Thank you for taking the time not only to make code improvements but also
to inform the community of what you did and why. I suspect that EricDC is
going to be the one who is in the best position to comment on the changes
since he's the author of mod_avmd. In the meantime, though, if any out
there is using mod_avmd and is in a position to try out David's changes and
report back on jira then that would be most appreciated.


On Mon, Apr 9, 2012 at 8:47 AM, David Brazier <davidjbrazier at gmail.com>wrote:

> Hi
> I've been testing mod_avmd and got a lot of false positives - i.e. normal
> speech detected as beep.  As I understand it, the basic approach is to look
> for audio with one very dominant frequency - the beep.  It does this by
> getting a frequency estimate and then calculats the amplitude of the audio
> at that frequency, looking for a consistent run of high amplitudes.  But
> I've found a few things that are either not right or I have misunderstood:
> 1.  The expensive desa2 frequency estimate is calculated on every sample,
> and worse, as each frame arrives (say 160 samples) it calculates the desa2
> for every sample in the circular buffer - 800 samples (rounded up to 1024 I
> think?).  So that is using excessive CPU, and anyway I don't think the
> frequency estimate should be calculated on every sample, because in normal
> speech, the frequency is changing and so successive samples might register
> a high amplitude but with different frequencies, causing false positives.
> 2.  The amplitude function doesn't appear to produce a constant result
> when the input audio is a pure tone, although the deas2 frequency estimate
> is close.
> 3.  The running mean sma_b is tested against zero - which basically means
> any positive amplitude meeting the "valid" cases will count as a detected
> beep.
> I have re-worked mod_avmd.c to:
> 1.  Calculate the frequency only once every 10ms (sine len).
> 2.  Calculate the running variance of frequency over the required beep
> length (100ms) - ie. last 10 estimates.
> This is producing good results - would welcome comment & if anyone else
> can try it that would be great.  Could be further tided up as it doesn't
> really require a circular buffer for samples at all - could just do the
> desa2 calculation direct from the sample buffer, at least once per frame (2
> per frame for 8000kHz, 20ms frames).  Also, goertzel.c isn't used by the
> module at all, and amplitude.c isn't used in my version and can be removed.
> Raised as http://jira.freeswitch.org/browse/FS-4090 with proposed patch.
> Regards
> David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120409/d64b143d/attachment.html 

Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list