Skip to content

Commit

Permalink
Adding in a way to retrieve the detected language for golang bindings
Browse files Browse the repository at this point in the history
Adding in a function, GetDetectedLanguage, which will retrieve the detected language, if available.
  • Loading branch information
aderbedr committed Sep 26, 2024
1 parent cdce0ff commit 8d60666
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bindings/go/pkg/whisper/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ func (context *context) IsLANG(t Token, lang string) bool {
}
}

func (context *context) GetDetectedLanguage() string {
return whisper.Whisper_lang_str(context.model.ctx.Whisper_full_lang_id())
}

///////////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS

Expand Down
10 changes: 6 additions & 4 deletions bindings/go/pkg/whisper/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ type Model interface {

// Context is the speech recognition context.
type Context interface {
SetLanguage(string) error // Set the language to use for speech recognition, use "auto" for auto detect language.
SetTranslate(bool) // Set translate flag
IsMultilingual() bool // Return true if the model is multilingual.
Language() string // Get language
SetLanguage(string) error // Set the language to use for speech recognition, use "auto" for auto detect language.
SetTranslate(bool) // Set translate flag
IsMultilingual() bool // Return true if the model is multilingual.
Language() string // Get language
GetDetectedLanguage() string // Get auto detected language


SetOffset(time.Duration) // Set offset
SetDuration(time.Duration) // Set duration
Expand Down

0 comments on commit 8d60666

Please sign in to comment.