From: Robin Date: Thu, 26 Jan 2023 23:14:20 +0000 (-0800) Subject: go : add WhisperLangAutoDetect method to go binding (#451) X-Git-Tag: upstream/1.7.4~1590 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=beb9512be34bf2389e276caf4cb0d06ff0d022b7;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp go : add WhisperLangAutoDetect method to go binding (#451) --- diff --git a/bindings/go/pkg/whisper/context.go b/bindings/go/pkg/whisper/context.go index a4496b88..b26a4b73 100644 --- a/bindings/go/pkg/whisper/context.go +++ b/bindings/go/pkg/whisper/context.go @@ -117,6 +117,17 @@ func (context *context) PrintTimings() { context.model.ctx.Whisper_print_timings() } +// Use mel data at offset_ms to try and auto-detect the spoken language +// Make sure to call whisper_pcm_to_mel() or whisper_set_mel() first. +// Returns the probabilities of all languages. +func (context *context) WhisperLangAutoDetect(offset_ms int, n_threads int) ([]float32, error) { + langProbs, err := context.model.ctx.Whisper_lang_auto_detect(offset_ms, n_threads) + if err != nil { + return nil, err + } + return langProbs, nil +} + // Process new sample data and return any errors func (context *context) Process(data []float32, cb SegmentCallback) error { if context.model.ctx == nil {