whisper: add tests and allow to set upload size (#237)

This commit is contained in:
Ettore Di Giacinto 2023-05-12 10:04:20 +02:00 committed by GitHub
parent 5115b2faa3
commit fd1df4e971
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 21 deletions

View file

@ -28,7 +28,7 @@ func audioToWav(src, dst string) error {
return nil
}
func Transcript(model whisper.Model, audiopath, language string) (string, error) {
func Transcript(model whisper.Model, audiopath, language string, threads uint) (string, error) {
dir, err := os.MkdirTemp("", "whisper")
if err != nil {
@ -65,8 +65,12 @@ func Transcript(model whisper.Model, audiopath, language string) (string, error)
}
context.SetThreads(threads)
if language != "" {
context.SetLanguage(language)
} else {
context.SetLanguage("auto")
}
if err := context.Process(data, nil); err != nil {