mirror of
https://github.com/mudler/LocalAI.git
synced 2026-03-31 21:25:59 -04:00
* feat(gallery): Switch to expandable box instead of pop-over and display model files Signed-off-by: Richard Palethorpe <io@richiejp.com> * feat(ui, backends): Add individual backend logging Signed-off-by: Richard Palethorpe <io@richiejp.com> * fix(ui): Set the context settings from the model config Signed-off-by: Richard Palethorpe <io@richiejp.com> --------- Signed-off-by: Richard Palethorpe <io@richiejp.com>
41 lines
978 B
Go
41 lines
978 B
Go
package backend
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/mudler/LocalAI/core/config"
|
|
"github.com/mudler/LocalAI/core/schema"
|
|
"github.com/mudler/LocalAI/pkg/grpc/proto"
|
|
"github.com/mudler/LocalAI/pkg/model"
|
|
)
|
|
|
|
func VAD(request *schema.VADRequest,
|
|
ctx context.Context,
|
|
ml *model.ModelLoader,
|
|
appConfig *config.ApplicationConfig,
|
|
modelConfig config.ModelConfig) (*schema.VADResponse, error) {
|
|
opts := ModelOptions(modelConfig, appConfig)
|
|
vadModel, err := ml.Load(opts...)
|
|
if err != nil {
|
|
recordModelLoadFailure(appConfig, modelConfig.Name, modelConfig.Backend, err, nil)
|
|
return nil, err
|
|
}
|
|
|
|
req := proto.VADRequest{
|
|
Audio: request.Audio,
|
|
}
|
|
resp, err := vadModel.VAD(ctx, &req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
segments := []schema.VADSegment{}
|
|
for _, s := range resp.Segments {
|
|
segments = append(segments, schema.VADSegment{Start: s.Start, End: s.End})
|
|
}
|
|
|
|
return &schema.VADResponse{
|
|
Segments: segments,
|
|
}, nil
|
|
}
|