Skip to main content

Voice activity detection (VAD)

The Voice activity detection - or VAD - is a tool that we use to detect silences in speech to pause/resume the recording. In this way, the user can expedite the process of record without the necessity of start or pause the recordings, because the voice activity detection do this work.

Basic operation

The VAD is activated passing two parameters in the initialization: useVAD which takes true and input which takes browsermic.

IMPORTANT: this functionality can not be used with auto or speechmike input.

With the VAD active two events are triggered: iaraSpeechRecognitionVADVoiceStart which detects voice activity and iaraSpeechRecognitionVADVoiceStop which detects when there is no voice activity.

Tip: VAD also uses the eventos shown in the Funcionamento tab in the Eventos section.

Basic usage

Remember to listen the events iaraSpeechRecognitionVADVoiceStart and iaraSpeechRecognitionVADVoiceStop:

//Events added after the instantiation of the recognizer, but before its start.

var recognition = new IaraSpeechRecognition();

recognition.addEventListener(
"iaraSpeechRecognitionVADVoiceStart",
function (event) {
console.log("Atividade de voz detectada ...");
console.log(JSON.stringify(event.detail, null, 4));
}
);

recognition.addEventListener(
"iaraSpeechRecognitionVADVoiceStop",
function (event) {
console.log(
"Paramos de detectar atividade de voz, começe a falar novamente para transcrevermos."
);
console.log(JSON.stringify(event.detail, null, 4));
}
);

recognition
.init({
userId: myUserId,
apiToken: myApiToken,
forceConnection: true,
interimResults: true,
input: "browsermic",
useVAD: true,
})
.done(function (e) {
console.log('Pronto para gravar. Pressione o botão "Iniciar".');

recognition.onstart = function () {
console.log("Estamos escutando ...");
};

recognition.onstop = function () {
console.log("Gravação finalizada.");
};
});
Tip: see the section Voice recognition to learn more about Iara recognition.