mirror of
https://github.com/xzeldon/whisper-api-server.git
synced 2024-12-27 11:15:45 +00:00
xzeldon
a025285256
Additionally, made the following changes: ∙ - Allow listening only on local interfaces ∙ - Update project structure
30 lines
562 B
Go
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
|
|
}
|