Skip to content

Commit 53f079f

Browse files
jaybinksJay Binks
andauthored
go : add support for whisper_full_lang_id() (ggml-org#1010)
* * Add support for whisper_full_lang_id() to go bindings * Expose token.id so we can test beg, eot etc --------- Co-authored-by: Jay Binks <[email protected]>
1 parent 11cad0a commit 53f079f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bindings/go/whisper.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ func (ctx *Context) Whisper_full_parallel(params Params, samples []float32, proc
338338
}
339339
}
340340

341+
// Return the id of the autodetected language, returns -1 if not found
342+
// Added to whisper.cpp in
343+
// https://github.com/ggerganov/whisper.cpp/commit/a1c1583cc7cd8b75222857afc936f0638c5683d6
344+
//
345+
// Examples:
346+
//
347+
// "de" -> 2
348+
// "german" -> 2
349+
func (ctx *Context) Whisper_full_lang_id() int {
350+
return int(C.whisper_full_lang_id((*C.struct_whisper_context)(ctx)))
351+
}
352+
341353
// Number of generated text segments.
342354
// A segment can be a few words, a sentence, or even a paragraph.
343355
func (ctx *Context) Whisper_full_n_segments() int {
@@ -451,3 +463,7 @@ func (t TokenData) T0() int64 {
451463
func (t TokenData) T1() int64 {
452464
return int64(t.t1)
453465
}
466+
467+
func (t TokenData) Id() Token {
468+
return Token(t.id)
469+
}

0 commit comments

Comments
 (0)