HydrogenAudio

Lossy Audio Compression => Opus => Topic started by: psridhar on 2019-09-09 04:17:31

Title: Using Opus 1.3.1 for VAD
Post by: psridhar on 2019-09-09 04:17:31
Heya,

I need to perform VAD for this service I am working on and my plan is to use Opus 1.3.1 to provide it. As far as a I can tell, the only way to do that is to opus_encode the audio and then check if the number of output bytes is less than 2.

Code: [Select]
unsigned char output_frame[4000];
int bytes;
if ((bytes = opus_encode(encoder_.get(), frame, 80, output_frame, 4000)) < 2) {
    return false;
}
return true;

The audio here is 8khz mono channel audio with 16 bit depth.

My trouble is when I run this function on all 0s, it still encodes to 5 bytes. If I run

Code: [Select]
opus_encoder_ctl(encoder_.get(), OPUS_GET_IN_DTX(&result));

The result is false even though the input is all 0s.

1). What am I doing wrong here? Shouldn't all 0s trigger DTX?
2). Is there a simpler way I can just invoke the VAD without also having to encode the audio and then throw the result away?

Thanks,
Prashant

Title: Re: Using Opus 1.3.1 for VAD
Post by: lithopsian on 2019-09-09 10:57:52
Have you set DTX on?