HoneyTian commited on
Commit
cc48e0c
1 Parent(s): 2b2f7f6
Files changed (5) hide show
  1. Dockerfile +4 -0
  2. install.sh +73 -0
  3. main.py +2 -2
  4. silero/build_silero_vad.sh +0 -13
  5. silero/main.go +1 -1
Dockerfile CHANGED
@@ -14,8 +14,12 @@ ENV PATH="/code/vad_go_venv/bin:$PATH"
14
  RUN pip install --upgrade pip
15
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
16
 
 
 
17
  RUN bash build_vad_go.sh
18
 
 
 
19
  USER root
20
 
21
  RUN chmod -R 777 .
 
14
  RUN pip install --upgrade pip
15
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
16
 
17
+ RUN bash install.sh
18
+
19
  RUN bash build_vad_go.sh
20
 
21
+ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/code/thirdparty/onnxruntime-linux-x64-1.20.1/lib
22
+
23
  USER root
24
 
25
  RUN chmod -R 777 .
install.sh ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ # bash install.sh --stage 0 --stop_stage 2
4
+
5
+ verbose=true;
6
+ stage=-1
7
+ stop_stage=0
8
+
9
+
10
+ # parse options
11
+ while true; do
12
+ [ -z "${1:-}" ] && break; # break if there are no arguments
13
+ case "$1" in
14
+ --*) name=$(echo "$1" | sed s/^--// | sed s/-/_/g);
15
+ eval '[ -z "${'"$name"'+xxx}" ]' && echo "$0: invalid option $1" 1>&2 && exit 1;
16
+ old_value="(eval echo \\$$name)";
17
+ if [ "${old_value}" == "true" ] || [ "${old_value}" == "false" ]; then
18
+ was_bool=true;
19
+ else
20
+ was_bool=false;
21
+ fi
22
+
23
+ # Set the variable to the right value-- the escaped quotes make it work if
24
+ # the option had spaces, like --cmd "queue.pl -sync y"
25
+ eval "${name}=\"$2\"";
26
+
27
+ # Check that Boolean-valued arguments are really Boolean.
28
+ if $was_bool && [[ "$2" != "true" && "$2" != "false" ]]; then
29
+ echo "$0: expected \"true\" or \"false\": $1 $2" 1>&2
30
+ exit 1;
31
+ fi
32
+ shift 2;
33
+ ;;
34
+
35
+ *) break;
36
+ esac
37
+ done
38
+
39
+
40
+ work_dir="$(pwd)"
41
+ thirdparty_dir="$(pwd)/thirdparty"
42
+ pretrained_models_dir="$(pwd)/pretrained_models"
43
+ silero_vad_model_dir="${pretrained_models_dir}/silero_vad"
44
+
45
+ mkdir -p "${thirdparty_dir}"
46
+ mkdir -p "${pretrained_models_dir}"
47
+ mkdir -p "${silero_vad_model_dir}"
48
+
49
+
50
+ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then
51
+ $verbose && echo "stage 0: install onnxruntime"
52
+
53
+ cd "${thirdparty_dir}"
54
+
55
+ # install onnxruntime
56
+ wget https://github.com/microsoft/onnxruntime/releases/download/v1.20.1/onnxruntime-linux-x64-1.20.1.tgz
57
+ tar -zxvf onnxruntime-linux-x64-1.20.1.tgz
58
+ export C_INCLUDE_PATH=$C_INCLUDE_PATH:$(pwd)/onnxruntime-linux-x64-1.20.1/include
59
+ export LIBRARY_PATH=$LIBRARY_PATH:$(pwd)/onnxruntime-linux-x64-1.20.1/lib
60
+
61
+ fi
62
+
63
+
64
+ if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
65
+ $verbose && echo "stage 1: download silero_vad.onnx"
66
+
67
+ cd "${silero_vad_model_dir}"
68
+
69
+ # download model
70
+ # https://github.com/snakers4/silero-vad/tree/master/src/silero_vad/data
71
+ wget https://github.com/snakers4/silero-vad/raw/refs/heads/master/src/silero_vad/data/silero_vad.onnx
72
+
73
+ fi
main.py CHANGED
@@ -106,7 +106,7 @@ def main():
106
  uploaded_vad_engine = gr.Dropdown(choices=["nx_vad", "silero-vad"], value="nx_vad", label="vad_engine")
107
  uploaded_silence_time = gr.Slider(minimum=0.0, maximum=1.0, value=0.3, step=0.01, label="silence time")
108
  uploaded_longest_activate = gr.Slider(minimum=0.0, maximum=20.0, value=3.0, step=0.1, label="longest activate")
109
- upload_button = gr.Button("Run VAD")
110
  uploaded_output = gr.Textbox(label="outputs")
111
 
112
  gr.Examples(
@@ -137,7 +137,7 @@ def main():
137
  )
138
  with gr.TabItem("shell"):
139
  shell_text = gr.Textbox(label="cmd")
140
- shell_button = gr.Button("run")
141
  shell_output = gr.Textbox(label="output")
142
 
143
  shell_button.click(
 
106
  uploaded_vad_engine = gr.Dropdown(choices=["nx_vad", "silero-vad"], value="nx_vad", label="vad_engine")
107
  uploaded_silence_time = gr.Slider(minimum=0.0, maximum=1.0, value=0.3, step=0.01, label="silence time")
108
  uploaded_longest_activate = gr.Slider(minimum=0.0, maximum=20.0, value=3.0, step=0.1, label="longest activate")
109
+ upload_button = gr.Button("Run VAD", variant="primary")
110
  uploaded_output = gr.Textbox(label="outputs")
111
 
112
  gr.Examples(
 
137
  )
138
  with gr.TabItem("shell"):
139
  shell_text = gr.Textbox(label="cmd")
140
+ shell_button = gr.Button("run", variant="primary")
141
  shell_output = gr.Textbox(label="output")
142
 
143
  shell_button.click(
silero/build_silero_vad.sh CHANGED
@@ -1,19 +1,6 @@
1
  #!/usr/bin/env bash
2
  # https://github.com/snakers4/silero-vad/tree/master/examples/go
3
 
4
- # install onnxruntime
5
- wget https://github.com/microsoft/onnxruntime/releases/download/v1.20.1/onnxruntime-linux-x64-1.20.1.tgz
6
- tar -zxvf onnxruntime-linux-x64-1.20.1.tgz
7
- export C_INCLUDE_PATH=$C_INCLUDE_PATH:$(pwd)/onnxruntime-linux-x64-1.20.1/include
8
- export LIBRARY_PATH=$LIBRARY_PATH:$(pwd)/onnxruntime-linux-x64-1.20.1/lib
9
- #export LD_LIBRARY_PATH=$(pwd)/onnxruntime-linux-x64-1.20.1/lib:$LD_LIBRARY_PATH
10
- cp $(pwd)/onnxruntime-linux-x64-1.20.1/lib/* /usr/local/lib/
11
-
12
- # download model
13
- # https://github.com/snakers4/silero-vad/tree/master/src/silero_vad/data
14
- wget https://github.com/snakers4/silero-vad/raw/refs/heads/master/src/silero_vad/data/silero_vad.onnx
15
-
16
- # build
17
  mkdir build
18
 
19
  go env -w GO111MODULE=on
 
1
  #!/usr/bin/env bash
2
  # https://github.com/snakers4/silero-vad/tree/master/examples/go
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  mkdir build
5
 
6
  go env -w GO111MODULE=on
silero/main.go CHANGED
@@ -11,7 +11,7 @@ import (
11
 
12
  func main() {
13
  sd, err := speech.NewDetector(speech.DetectorConfig{
14
- ModelPath: "./silero/silero_vad.onnx",
15
  SampleRate: 8000,
16
  Threshold: 0.5,
17
  MinSilenceDurationMs: 100,
 
11
 
12
  func main() {
13
  sd, err := speech.NewDetector(speech.DetectorConfig{
14
+ ModelPath: "./pretrained_models/silero_vad/silero_vad.onnx",
15
  SampleRate: 8000,
16
  Threshold: 0.5,
17
  MinSilenceDurationMs: 100,