MCPcopy
hub / github.com/mudler/LocalAI / VAD

Function VAD

core/backend/vad.go:12–43  ·  view source on GitHub ↗
(request *schema.VADRequest,
	ctx context.Context,
	ml *model.ModelLoader,
	appConfig *config.ApplicationConfig,
	modelConfig config.ModelConfig)

Source from the content-addressed store, hash-verified

10)
11
12func VAD(request *schema.VADRequest,
13 ctx context.Context,
14 ml *model.ModelLoader,
15 appConfig *config.ApplicationConfig,
16 modelConfig config.ModelConfig) (*schema.VADResponse, error) {
17 // model.WithContext(ctx) overrides the app-context default set in
18 // ModelOptions so distributed routing decisions reach the request's
19 // X-LocalAI-Node holder via distributedhdr.Stamp.
20 opts := ModelOptions(modelConfig, appConfig, model.WithContext(ctx))
21 vadModel, err := ml.Load(opts...)
22 if err != nil {
23 recordModelLoadFailure(appConfig, modelConfig.Name, modelConfig.Backend, err, nil)
24 return nil, err
25 }
26
27 req := proto.VADRequest{
28 Audio: request.Audio,
29 }
30 resp, err := vadModel.VAD(ctx, &req)
31 if err != nil {
32 return nil, err
33 }
34
35 segments := []schema.VADSegment{}
36 for _, s := range resp.Segments {
37 segments = append(segments, schema.VADSegment{Start: s.Start, End: s.End})
38 }
39
40 return &schema.VADResponse{
41 Segments: segments,
42 }, nil
43}

Callers 4

VADMethod · 0.92
VADMethod · 0.92
VADEndpointFunction · 0.92

Calls 5

WithContextFunction · 0.92
ModelOptionsFunction · 0.85
recordModelLoadFailureFunction · 0.85
LoadMethod · 0.65
VADMethod · 0.65

Tested by

no test coverage detected