Spaces:
Sleeping
Sleeping
go : add support for whisper_full_lang_id() (#1010)
Browse files* * 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]>
- bindings/go/whisper.go +16 -0
bindings/go/whisper.go
CHANGED
|
@@ -338,6 +338,18 @@ func (ctx *Context) Whisper_full_parallel(params Params, samples []float32, proc
|
|
| 338 |
}
|
| 339 |
}
|
| 340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
// Number of generated text segments.
|
| 342 |
// A segment can be a few words, a sentence, or even a paragraph.
|
| 343 |
func (ctx *Context) Whisper_full_n_segments() int {
|
|
@@ -451,3 +463,7 @@ func (t TokenData) T0() int64 {
|
|
| 451 |
func (t TokenData) T1() int64 {
|
| 452 |
return int64(t.t1)
|
| 453 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
}
|
| 339 |
}
|
| 340 |
|
| 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 |
+
|
| 353 |
// Number of generated text segments.
|
| 354 |
// A segment can be a few words, a sentence, or even a paragraph.
|
| 355 |
func (ctx *Context) Whisper_full_n_segments() int {
|
|
|
|
| 463 |
func (t TokenData) T1() int64 {
|
| 464 |
return int64(t.t1)
|
| 465 |
}
|
| 466 |
+
|
| 467 |
+
func (t TokenData) Id() Token {
|
| 468 |
+
return Token(t.id)
|
| 469 |
+
}
|