Skip to content

Commit beb9512

Browse files
authored
go : add WhisperLangAutoDetect method to go binding (ggml-org#451)
1 parent 47737b2 commit beb9512

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

bindings/go/pkg/whisper/context.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ func (context *context) PrintTimings() {
117117
context.model.ctx.Whisper_print_timings()
118118
}
119119

120+
// Use mel data at offset_ms to try and auto-detect the spoken language
121+
// Make sure to call whisper_pcm_to_mel() or whisper_set_mel() first.
122+
// Returns the probabilities of all languages.
123+
func (context *context) WhisperLangAutoDetect(offset_ms int, n_threads int) ([]float32, error) {
124+
langProbs, err := context.model.ctx.Whisper_lang_auto_detect(offset_ms, n_threads)
125+
if err != nil {
126+
return nil, err
127+
}
128+
return langProbs, nil
129+
}
130+
120131
// Process new sample data and return any errors
121132
func (context *context) Process(data []float32, cb SegmentCallback) error {
122133
if context.model.ctx == nil {

0 commit comments

Comments
 (0)