Adding in a way to retrieve the detected language for golang bindings

Adding in a function, GetDetectedLanguage, which will retrieve the detected language, if available.
This commit is contained in:
Amanda Der Bedrosian 2024-09-26 11:20:12 -07:00
parent cdce0ff157
commit 8d60666cbc
2 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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