mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-28 14:35:00 +00:00
Keep whisper models in memory (#233)
This commit is contained in:
parent
6b5e2b2bf5
commit
032dee256f
3 changed files with 49 additions and 12 deletions
|
@ -28,7 +28,7 @@ func audioToWav(src, dst string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func Transcript(modelpath, audiopath, language string) (string, error) {
|
||||
func Transcript(model whisper.Model, audiopath, language string) (string, error) {
|
||||
|
||||
dir, err := os.MkdirTemp("", "whisper")
|
||||
if err != nil {
|
||||
|
@ -58,13 +58,6 @@ func Transcript(modelpath, audiopath, language string) (string, error) {
|
|||
|
||||
data := buf.AsFloat32Buffer().Data
|
||||
|
||||
// Load the model
|
||||
model, err := whisper.New(modelpath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer model.Close()
|
||||
|
||||
// Process samples
|
||||
context, err := model.NewContext()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue