-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Centralized Request Middleware - also adds VAD tests
Signed-off-by: Dave Lee <[email protected]>
- Loading branch information
1 parent
708cba0
commit d08311f
Showing
56 changed files
with
481,022 additions
and
803 deletions.
There are no files selected for viewing
240,024 changes: 240,024 additions & 0 deletions
240,024
.bruno/LocalAI Test Requests/vad/vad test audio.bru
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
meta { | ||
name: vad test too few | ||
type: http | ||
seq: 1 | ||
} | ||
|
||
post { | ||
url: {{PROTOCOL}}{{HOST}}:{{PORT}}/vad | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
Content-Type: application/json | ||
} | ||
|
||
body:json { | ||
{ | ||
"model": "silero-vad", | ||
"audio": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
backend: silero-vad | ||
name: silero-vad | ||
parameters: | ||
model: silero-vad.onnx | ||
download_files: | ||
- filename: silero-vad.onnx | ||
uri: https://huggingface.co/onnx-community/silero-vad/resolve/main/onnx/model.onnx | ||
sha256: a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
backend: silero-vad | ||
name: silero-vad | ||
parameters: | ||
model: silero-vad.onnx | ||
download_files: | ||
- filename: silero-vad.onnx | ||
uri: https://huggingface.co/onnx-community/silero-vad/resolve/main/onnx/model.onnx | ||
sha256: a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
backend: silero-vad | ||
name: silero-vad | ||
parameters: | ||
model: silero-vad.onnx | ||
download_files: | ||
- filename: silero-vad.onnx | ||
uri: https://huggingface.co/onnx-community/silero-vad/resolve/main/onnx/model.onnx | ||
sha256: a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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, | ||
backendConfig config.BackendConfig) (*schema.VADResponse, error) { | ||
opts := ModelOptions(backendConfig, appConfig) | ||
vadModel, err := ml.Load(opts...) | ||
if 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.