We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Voice activity detection
Install the browser SDK:
npm install @wfloat/wfloat-web
Load the model and detect speech regions in an audio file:
import { loadVadModel } from "@wfloat/wfloat-web";
const vad = await loadVadModel("snakers4/silero-vad");
const file = document.querySelector<HTMLInputElement>("#audio-file")?.files?.[0];
if (!file) throw new Error("Choose an audio file first.");
const result = await vad.detect({ audio: file });
for (const segment of result.segments) {
console.log(segment.startSec, segment.endSec);
}
For live detection, use vad.createSession({ onSpeechStart, onSpeechEnd }), then call session.startMicrophone() and session.stopMicrophone().
Install the React Native SDK:
npm install @wfloat/react-native-wfloat
Run pod install from the app’s ios directory, and configure microphone permission for the target platform. Then create a live VAD session:
import { loadVadModel } from '@wfloat/react-native-wfloat';
const vad = await loadVadModel('snakers4/silero-vad');
const session = await vad.createSession({
onSpeechStart(event) {
console.log('speech started near', event.startSec);
},
onSpeechEnd(segment) {
console.log(segment.startSec, segment.endSec);
},
});
await session.startMicrophone();
// Call these when detection is no longer needed.
await session.stopMicrophone();
await session.close();
For existing mono PCM samples, call vad.detect({ audio, sampleRate: 16000 }).
Install the Python SDK:
pip install wfloat
Load the model and detect speech in a mono 16 kHz, 16-bit PCM WAV file:
import wfloat
vad = wfloat.load_vad_model(
"snakers4/silero-vad",
threshold=0.5,
min_silence_duration_sec=0.5,
min_speech_duration_sec=0.25,
)
result = vad.detect(audio="recording.wav")
for segment in result.segments:
print(segment.start_sec, segment.end_sec)
For in-memory audio, pass a sequence of floating-point mono samples and set sample_rate=16000.