]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
go : Enable VAD for Go bindings (#3563)
authorJosh Montoya <redacted>
Wed, 10 Dec 2025 11:31:36 +0000 (03:31 -0800)
committerGitHub <redacted>
Wed, 10 Dec 2025 11:31:36 +0000 (13:31 +0200)
* reset context.n so that NextSegment can be called for multiple Process calls

* enable VAD params

bindings/go/params.go
bindings/go/pkg/whisper/context.go
bindings/go/pkg/whisper/interface.go

index d8dee57e331101520256f32ea319dc5be52778b0..7d6a30d7fea31465e64a58965f0471ebe5fa3bae 100644 (file)
@@ -47,6 +47,38 @@ func (p *Params) SetPrintTimestamps(v bool) {
        p.print_timestamps = toBool(v)
 }
 
+// Voice Activity Detection (VAD)
+func (p *Params) SetVAD(v bool) {
+       p.vad = toBool(v)
+}
+
+func (p *Params) SetVADModelPath(path string) {
+       p.vad_model_path = C.CString(path)
+}
+
+func (p *Params) SetVADThreshold(t float32) {
+       p.vad_params.threshold = C.float(t)
+}
+
+func (p *Params) SetVADMinSpeechMs(ms int) {
+       p.vad_params.min_speech_duration_ms = C.int(ms)
+}
+
+func (p *Params) SetVADMinSilenceMs(ms int) {
+       p.vad_params.min_silence_duration_ms = C.int(ms)
+}
+
+func (p *Params) SetVADMaxSpeechSec(s float32) {
+       p.vad_params.max_speech_duration_s = C.float(s)
+}
+
+func (p *Params) SetVADSpeechPadMs(ms int) {
+       p.vad_params.speech_pad_ms = C.int(ms)
+}
+
+func (p *Params) SetVADSamplesOverlap(sec float32) {
+       p.vad_params.samples_overlap = C.float(sec)
+}
 
 // Set language id
 func (p *Params) SetLanguage(lang int) error {
index 294a0320c8a249e1f14ebee33f10e8e74e801404..d356d72cccb744047cbc6bf6e5b809e5e4cfab2c 100644 (file)
@@ -80,6 +80,39 @@ func (context *context) SetTranslate(v bool) {
        context.params.SetTranslate(v)
 }
 
+// Voice Activity Detection (VAD)
+func (context *context) SetVAD(v bool) {
+       context.params.SetVAD(v)
+}
+
+func (context *context) SetVADModelPath(path string) {
+       context.params.SetVADModelPath(path)
+}
+
+func (context *context) SetVADThreshold(t float32) {
+       context.params.SetVADThreshold(t)
+}
+
+func (context *context) SetVADMinSpeechMs(ms int) {
+       context.params.SetVADMinSpeechMs(ms)
+}
+
+func (context *context) SetVADMinSilenceMs(ms int) {
+       context.params.SetVADMinSilenceMs(ms)
+}
+
+func (context *context) SetVADMaxSpeechSec(s float32) {
+       context.params.SetVADMaxSpeechSec(s)
+}
+
+func (context *context) SetVADSpeechPadMs(ms int) {
+       context.params.SetVADSpeechPadMs(ms)
+}
+
+func (context *context) SetVADSamplesOverlap(sec float32) {
+       context.params.SetVADSamplesOverlap(sec)
+}
+
 func (context *context) SetSplitOnWord(v bool) {
        context.params.SetSplitOnWord(v)
 }
index e3122c44b763a8bf2ee8bd7f80824f361a5fe6b3..2b275dd34699bcddaac9a16a497c66dff2463ffc 100644 (file)
@@ -60,6 +60,15 @@ type Context interface {
        SetTemperature(t float32)         // Set temperature
        SetTemperatureFallback(t float32) // Set temperature incrementation
 
+       SetVAD(v bool)
+       SetVADModelPath(path string)
+       SetVADThreshold(t float32)
+       SetVADMinSpeechMs(ms int)
+       SetVADMinSilenceMs(ms int)
+       SetVADMaxSpeechSec(s float32)
+       SetVADSpeechPadMs(ms int)
+       SetVADSamplesOverlap(sec float32)
+
        // Process mono audio data and return any errors.
        // If defined, newly generated segments are passed to the
        // callback function during processing.