# Are there any realtime voice activity detection (VAD) implementations available?

I'm looking for a realtime VAD implementation like Discord/Mumble/Teamspeak have.

My goal is to have a system that let's me use the same VAD for all my VoIP applications, as well as something I can use to facilitate VAD for push to talk only applications.

Mumble is open source though I wasn't able to find what I needed when I had a look.

• It might be worth looking at github.com/wiseman/py-webrtcvad, looks like the Python bindinds as well as the C code are MIT-licensed. – bk138 Dec 23 '19 at 22:34

So, this is not an answer in the quality I'd like it to be, but the Mumble VAD is in AudioInput.c , as a quick browsing yielded:

speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_GET_PROB, &prob);
fSpeechProb = static_cast<float>(prob) / 100.0f;

// clean microphone level: peak of filtered signal attenuated by AGC gain
dPeakCleanMic = qMax(dPeakSignal - gainValue, -96.0f);
float level = (g.s.vsVAD == Settings::SignalToNoise) ? fSpeechProb : (1.0f + dPeakCleanMic / 96.0f);

bool bIsSpeech = false;

bIsSpeech = true;


What's done here is that Speex, a FOSS voice codec and utility pack is used to get an estimate for the silence->voice transition. Whyever, Mumble converts that probability value (probabilities: $\in[0,1]$) to a percentage, and then compares it to the internal setting.

So the algorithm of interest here is definitely not within Mumble, but libspeexdsp!

Funnily, that's basically where it goes down in speexdsp's preprocess.dsp

/* FIXME: This VAD is a kludge */
st->speech_prob = Pframe;
{
if (st->speech_prob > st->speech_prob_start || (st->was_speech && st->speech_prob > st->speech_prob_continue))
{
st->was_speech=1;
return 1;
} else
{
st->was_speech=0;
return 0;
}
} else {
return 1;
}


So, this really just boils down to an SNR estimate of the current audio frame:

/* Speech probability of presence for the entire frame is based on the average filterbank a priori SNR */
Zframe = 0;
for (i=N;i<N+M;i++)