Spaces:
Sleeping
Sleeping
update
Browse files- Dockerfile +0 -1
- main.py +12 -2
Dockerfile
CHANGED
@@ -12,7 +12,6 @@ RUN pip install --no-cache-dir --upgrade -r /data/GolandProjects/vad_go/requirem
|
|
12 |
|
13 |
RUN bash build_vad_go.sh
|
14 |
|
15 |
-
# main
|
16 |
WORKDIR /data/GolandProjects/vad_go
|
17 |
|
18 |
USER root
|
|
|
12 |
|
13 |
RUN bash build_vad_go.sh
|
14 |
|
|
|
15 |
WORKDIR /data/GolandProjects/vad_go
|
16 |
|
17 |
USER root
|
main.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import argparse
|
4 |
import logging
|
|
|
5 |
from pathlib import Path
|
6 |
import platform
|
7 |
import re
|
@@ -29,8 +30,11 @@ def get_args():
|
|
29 |
args = parser.parse_args()
|
30 |
return args
|
31 |
|
32 |
-
|
33 |
def process_uploaded_file(filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> str:
|
|
|
|
|
|
|
|
|
34 |
filename = Path(filename).as_posix()
|
35 |
|
36 |
main_logger.info("do vad: {}".format(filename))
|
@@ -40,7 +44,13 @@ def process_uploaded_file(filename: str, silence_time: float = 0.3, longest_acti
|
|
40 |
)
|
41 |
vad_result = Command.popen(cmd)
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
|
46 |
def shell(cmd: str):
|
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import argparse
|
4 |
import logging
|
5 |
+
import json
|
6 |
from pathlib import Path
|
7 |
import platform
|
8 |
import re
|
|
|
30 |
args = parser.parse_args()
|
31 |
return args
|
32 |
|
|
|
33 |
def process_uploaded_file(filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> str:
|
34 |
+
return
|
35 |
+
|
36 |
+
|
37 |
+
def run_nx_vad(filename: str, silence_time: float = 0.3, longest_activate: float = 3.0) -> str:
|
38 |
filename = Path(filename).as_posix()
|
39 |
|
40 |
main_logger.info("do vad: {}".format(filename))
|
|
|
44 |
)
|
45 |
vad_result = Command.popen(cmd)
|
46 |
|
47 |
+
pattern = "(\\d+)[\r\n]VadFlagPrepare[\r\n](\\d+)[\r\n]VadFlagSpeaking(?:[\r\n](?:\\d+)[\r\n]VadFlagPause[\r\n](?:\\d+)[\r\n]VadFlagSpeaking)?[\r\n](\\d+)[\r\n]VadFlagNoSpeech"
|
48 |
+
|
49 |
+
vad_timestamps = re.findall(pattern, vad_result, flags=re.DOTALL)
|
50 |
+
|
51 |
+
vad_timestamps: str = json.dumps(vad_timestamps, ensure_ascii=False)
|
52 |
+
|
53 |
+
return vad_timestamps
|
54 |
|
55 |
|
56 |
def shell(cmd: str):
|