Robin commited on
Commit
d45536d
·
unverified ·
1 Parent(s): 91ae4b0

go : add WhisperLangAutoDetect method to go binding (#451)

Browse files
Files changed (1) hide show
  1. bindings/go/pkg/whisper/context.go +11 -0
bindings/go/pkg/whisper/context.go CHANGED
@@ -117,6 +117,17 @@ func (context *context) PrintTimings() {
117
  context.model.ctx.Whisper_print_timings()
118
  }
119
 
 
 
 
 
 
 
 
 
 
 
 
120
  // Process new sample data and return any errors
121
  func (context *context) Process(data []float32, cb SegmentCallback) error {
122
  if context.model.ctx == nil {
 
117
  context.model.ctx.Whisper_print_timings()
118
  }
119
 
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
+
131
  // Process new sample data and return any errors
132
  func (context *context) Process(data []float32, cb SegmentCallback) error {
133
  if context.model.ctx == nil {