whisper-api-server/internal/resources/model.go
xzeldon a025285256
Implement automatic model and Whisper.dll downloading
Additionally, made the following changes:
∙ - Allow listening only on local interfaces
∙ - Update project structure
2023-10-05 21:05:30 +03:00

30 lines
562 B
Go

package resources
import (
"fmt"
"path/filepath"
)
func GetModel(modelType string) (string, error) {
fileURL := fmt.Sprintf("https://huggingface.co/ggerganov/whisper.cpp/resolve/main/%s", modelType)
filePath := modelType
isModelFileExists := IsFileExists(filePath)
if !isModelFileExists {
fmt.Println("Model not found.")
err := DownloadFile(fileURL, filePath)
if err != nil {
return "", err
}
}
absPath, err := filepath.Abs(filePath)
if err != nil {
return "", err
}
fmt.Printf("Model found: %s\n", absPath)
return filePath, nil
}