Some checks failed
CodeQL / Analyze (go) (push) Successful in 6m28s
Docker Image / build-docker (push) Failing after 13m26s
Lint and Testing / lint (push) Successful in 11m17s
Lint and Testing / test (push) Successful in 11m17s
Lint and Testing / golangci (push) Successful in 2m40s
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package config
|
|
|
|
import "fmt"
|
|
|
|
type Whisper struct {
|
|
OutputFormat []string `yaml:"output_format"`
|
|
Model string `yaml:"model"`
|
|
AudioPath string `yaml:"audio_path"`
|
|
Language string `yaml:"language"`
|
|
Prompt string `yaml:"prompt"`
|
|
OutputFolder string `yaml:"output_folder"`
|
|
OutputFilename string `yaml:"output_filename"`
|
|
Threads uint `yaml:"threads"`
|
|
MaxContext uint `yaml:"max_context"`
|
|
BeamSize uint `yaml:"beam_size"`
|
|
EntropyThold float64 `yaml:"entropy_thold"`
|
|
VAD VAD `yaml:"vad"`
|
|
Debug bool `yaml:"debug"`
|
|
SpeedUp bool `yaml:"speedup"`
|
|
Translate bool `yaml:"translate"`
|
|
PrintProgress bool `yaml:"print_progress"`
|
|
PrintSegment bool `yaml:"print_segment"`
|
|
}
|
|
|
|
func (c *Whisper) ValidateModel() error {
|
|
if c.Model == "" {
|
|
return fmt.Errorf("model is required")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *Whisper) Validate() error {
|
|
if err := c.ValidateModel(); err != nil {
|
|
return err
|
|
}
|
|
if c.AudioPath == "" {
|
|
return fmt.Errorf("audio path is required")
|
|
}
|
|
if err := c.VAD.WithDefaults().Validate(); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|