mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-01-02 18:56:41 +00:00
231bebca7d
* Initial import of golang bindings * Updated makefile rules * Updated bindings * Makefile update to add in more tests
62 lines
1.4 KiB
Go
Executable File
62 lines
1.4 KiB
Go
Executable File
package main
|
|
|
|
import (
|
|
"flag"
|
|
)
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// TYPES
|
|
|
|
type Flags struct {
|
|
*flag.FlagSet
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// LIFECYCLE
|
|
|
|
func NewFlags(name string, args []string) (*Flags, error) {
|
|
flags := &Flags{
|
|
FlagSet: flag.NewFlagSet(name, flag.ContinueOnError),
|
|
}
|
|
|
|
// Register the command line arguments
|
|
registerFlags(flags)
|
|
|
|
// Parse command line
|
|
if err := flags.Parse(args); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// Return success
|
|
return flags, nil
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// PUBLIC METHODS
|
|
|
|
func (flags *Flags) GetModel() string {
|
|
return flags.Lookup("model").Value.String()
|
|
}
|
|
|
|
func (flags *Flags) GetLanguage() string {
|
|
return flags.Lookup("language").Value.String()
|
|
}
|
|
|
|
func (flags *Flags) IsSpeedup() bool {
|
|
return flags.Lookup("speedup").Value.String() == "true"
|
|
}
|
|
|
|
func (flags *Flags) IsTokens() bool {
|
|
return flags.Lookup("tokens").Value.String() == "true"
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// PRIVATE METHODS
|
|
|
|
func registerFlags(flag *Flags) {
|
|
flag.String("model", "", "Path to the model file")
|
|
flag.String("language", "", "Language")
|
|
flag.Bool("speedup", false, "Enable speedup")
|
|
flag.Bool("tokens", false, "Display tokens")
|
|
}
|