Whisper::Vad
Voice Activity Detection (VAD) subsystem.
Loads a standalone VAD model and detects speech segments in audio data independently of the main Whisper transcription pipeline.
vad = Whisper::Vad.new("/path/to/silero-vad.onnx")
segments = vad.detect(samples)
segments.each { |seg| puts "Speech: #{seg.start_seconds}s - #{seg.end_seconds}s" }
vad.close
Constructors
Instance methods
closed?
Sourcedetect(samples : Array(Float32), threshold : Float32 = 0.5_f32, min_speech_duration_ms : Int32 = 250, min_silence_duration_ms : Int32 = 100, max_speech_duration_s : Float32 = Float32::MAX, speech_pad_ms : Int32 = 30, samples_overlap : Float32 = 0.0_f32) : Array(SpeechSegment)
Runs speech detection on audio samples and returns speech segments.
samples must be 32-bit float PCM audio normalized to [-1.0, 1.0], mono, at 16kHz. VAD parameters can be customized via optional keyword arguments.
Runs speech probability computation on audio samples.
Returns true if speech was detected, and makes probabilities
accessible via #n_probs and #probs.
finalize
Sourcesegments_from_probs(threshold : Float32 = 0.5_f32, min_speech_duration_ms : Int32 = 250, min_silence_duration_ms : Int32 = 100, max_speech_duration_s : Float32 = Float32::MAX, speech_pad_ms : Int32 = 30, samples_overlap : Float32 = 0.0_f32) : Array(SpeechSegment)
Computes speech segments from previously computed probabilities.
Requires detect_speech to have been called first.