Spaces:
Sleeping
Sleeping
update
Browse files- Dockerfile +2 -2
- build_vad_go.sh +7 -3
- silero/build_silero_vad.sh +12 -0
- silero/go.mod +13 -0
- silero/go.sum +16 -0
- silero/main.go +63 -0
Dockerfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
FROM golang:1.
|
2 |
|
3 |
WORKDIR /data/GolandProjects/vad_go
|
4 |
|
5 |
COPY . /data/GolandProjects/vad_go
|
6 |
|
7 |
RUN apt-get update
|
8 |
-
RUN apt-get install -y python3-pip
|
9 |
|
10 |
RUN pip install --upgrade pip
|
11 |
RUN pip install --no-cache-dir --upgrade -r /data/GolandProjects/vad_go/requirements.txt
|
|
|
1 |
+
FROM golang:1.23
|
2 |
|
3 |
WORKDIR /data/GolandProjects/vad_go
|
4 |
|
5 |
COPY . /data/GolandProjects/vad_go
|
6 |
|
7 |
RUN apt-get update
|
8 |
+
RUN apt-get install -y python3-pip onnxruntime
|
9 |
|
10 |
RUN pip install --upgrade pip
|
11 |
RUN pip install --no-cache-dir --upgrade -r /data/GolandProjects/vad_go/requirements.txt
|
build_vad_go.sh
CHANGED
@@ -3,9 +3,13 @@
|
|
3 |
mkdir -p vad_bins/
|
4 |
|
5 |
# nx_vad
|
6 |
-
|
7 |
cd nx_vad
|
8 |
-
|
9 |
bash build_nx_vad.sh
|
10 |
-
|
11 |
cp ./build/nx_vad ../vad_bins/nx_vad
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
mkdir -p vad_bins/
|
4 |
|
5 |
# nx_vad
|
|
|
6 |
cd nx_vad
|
|
|
7 |
bash build_nx_vad.sh
|
|
|
8 |
cp ./build/nx_vad ../vad_bins/nx_vad
|
9 |
+
cd ..
|
10 |
+
|
11 |
+
# silero
|
12 |
+
cd silero
|
13 |
+
bash build_silero_vad.sh
|
14 |
+
cp ./build/silero ../vad_bins/silero
|
15 |
+
cd ..
|
silero/build_silero_vad.sh
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
mkdir build
|
4 |
+
|
5 |
+
go env -w GO111MODULE=on
|
6 |
+
go env GO111MODULE
|
7 |
+
|
8 |
+
go mod init silero
|
9 |
+
|
10 |
+
go mod tidy
|
11 |
+
|
12 |
+
go build -o build silero
|
silero/go.mod
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
module silero
|
2 |
+
|
3 |
+
go 1.23.4
|
4 |
+
|
5 |
+
require (
|
6 |
+
github.com/go-audio/wav v1.1.0
|
7 |
+
github.com/streamer45/silero-vad-go v0.2.1
|
8 |
+
)
|
9 |
+
|
10 |
+
require (
|
11 |
+
github.com/go-audio/audio v1.0.0 // indirect
|
12 |
+
github.com/go-audio/riff v1.0.0 // indirect
|
13 |
+
)
|
silero/go.sum
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
2 |
+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
3 |
+
github.com/go-audio/audio v1.0.0 h1:zS9vebldgbQqktK4H0lUqWrG8P0NxCJVqcj7ZpNnwd4=
|
4 |
+
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs=
|
5 |
+
github.com/go-audio/riff v1.0.0 h1:d8iCGbDvox9BfLagY94fBynxSPHO80LmZCaOsmKxokA=
|
6 |
+
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498=
|
7 |
+
github.com/go-audio/wav v1.1.0 h1:jQgLtbqBzY7G+BM8fXF7AHUk1uHUviWS4X39d5rsL2g=
|
8 |
+
github.com/go-audio/wav v1.1.0/go.mod h1:mpe9qfwbScEbkd8uybLuIpTgHyrISw/OTuvjUW2iGtE=
|
9 |
+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
10 |
+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
11 |
+
github.com/streamer45/silero-vad-go v0.2.1 h1:Li1/tTC4H/3cyw6q4weX+U8GWwEL3lTekK/nYa1Cvuk=
|
12 |
+
github.com/streamer45/silero-vad-go v0.2.1/go.mod h1:B+2FXs/5fZ6pzl6unUZYhZqkYdOB+3saBVzjOzdZnUs=
|
13 |
+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
14 |
+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
15 |
+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
16 |
+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
silero/main.go
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
package main
|
2 |
+
|
3 |
+
import (
|
4 |
+
"log"
|
5 |
+
"os"
|
6 |
+
|
7 |
+
"github.com/streamer45/silero-vad-go/speech"
|
8 |
+
|
9 |
+
"github.com/go-audio/wav"
|
10 |
+
)
|
11 |
+
|
12 |
+
func main() {
|
13 |
+
sd, err := speech.NewDetector(speech.DetectorConfig{
|
14 |
+
ModelPath: "../../src/silero_vad/data/silero_vad.onnx",
|
15 |
+
SampleRate: 16000,
|
16 |
+
Threshold: 0.5,
|
17 |
+
MinSilenceDurationMs: 100,
|
18 |
+
SpeechPadMs: 30,
|
19 |
+
})
|
20 |
+
if err != nil {
|
21 |
+
log.Fatalf("failed to create speech detector: %s", err)
|
22 |
+
}
|
23 |
+
|
24 |
+
if len(os.Args) != 2 {
|
25 |
+
log.Fatalf("invalid arguments provided: expecting one file path")
|
26 |
+
}
|
27 |
+
|
28 |
+
f, err := os.Open(os.Args[1])
|
29 |
+
if err != nil {
|
30 |
+
log.Fatalf("failed to open sample audio file: %s", err)
|
31 |
+
}
|
32 |
+
defer f.Close()
|
33 |
+
|
34 |
+
dec := wav.NewDecoder(f)
|
35 |
+
|
36 |
+
if ok := dec.IsValidFile(); !ok {
|
37 |
+
log.Fatalf("invalid WAV file")
|
38 |
+
}
|
39 |
+
|
40 |
+
buf, err := dec.FullPCMBuffer()
|
41 |
+
if err != nil {
|
42 |
+
log.Fatalf("failed to get PCM buffer")
|
43 |
+
}
|
44 |
+
|
45 |
+
pcmBuf := buf.AsFloat32Buffer()
|
46 |
+
|
47 |
+
segments, err := sd.Detect(pcmBuf.Data)
|
48 |
+
if err != nil {
|
49 |
+
log.Fatalf("Detect failed: %s", err)
|
50 |
+
}
|
51 |
+
|
52 |
+
for _, s := range segments {
|
53 |
+
log.Printf("speech starts at %0.2fs", s.SpeechStartAt)
|
54 |
+
if s.SpeechEndAt > 0 {
|
55 |
+
log.Printf("speech ends at %0.2fs", s.SpeechEndAt)
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
err = sd.Destroy()
|
60 |
+
if err != nil {
|
61 |
+
log.Fatalf("failed to destroy detector: %s", err)
|
62 |
+
}
|
63 |
+
}
|