Spaces:
Sleeping
Sleeping
update
Browse files- examples/parse_vad_result.py +45 -0
- main.py +2 -2
examples/parse_vad_result.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/python3
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
|
5 |
+
|
6 |
+
def main():
|
7 |
+
asr_result = """
|
8 |
+
sample rate: 8000
|
9 |
+
sample number: 39120
|
10 |
+
do StreamingVad Init...
|
11 |
+
5
|
12 |
+
3520
|
13 |
+
VadFlagPrepare
|
14 |
+
3820
|
15 |
+
VadFlagSpeaking
|
16 |
+
4360
|
17 |
+
VadFlagNoSpeech
|
18 |
+
4360
|
19 |
+
VadFlagPrepare
|
20 |
+
4600
|
21 |
+
VadFlagSpeaking
|
22 |
+
"""
|
23 |
+
|
24 |
+
pattern = r"(\d+)[\r\n]+VadFlagPrepare[\r\n]+(\d+)[\r\n]+VadFlagSpeaking[\r\n]+(\d+)[\r\n]+VadFlagNoSpeech[\r\n]+(\d+)[\r\n]+VadFlagPrepare[\r\n]+(\d+)[\r\n]+VadFlagSpeaking"
|
25 |
+
# pattern = r"(\d+)[\r\n]+VadFlagNoSpeech"
|
26 |
+
|
27 |
+
match = re.search(pattern, asr_result, flags=re.IGNORECASE | re.DOTALL)
|
28 |
+
if match is not None:
|
29 |
+
print(match.group(0))
|
30 |
+
print("-" * 15)
|
31 |
+
print(match.group(1))
|
32 |
+
print("-" * 15)
|
33 |
+
print(match.group(2))
|
34 |
+
print("-" * 15)
|
35 |
+
print(match.group(3))
|
36 |
+
print("-" * 15)
|
37 |
+
print(match.group(4))
|
38 |
+
print("-" * 15)
|
39 |
+
print(match.group(5))
|
40 |
+
|
41 |
+
return
|
42 |
+
|
43 |
+
|
44 |
+
if __name__ == '__main__':
|
45 |
+
main()
|
main.py
CHANGED
@@ -40,13 +40,13 @@ def process_uploaded_file(filename: str) -> str:
|
|
40 |
)
|
41 |
vad_result = Command.popen(cmd)
|
42 |
|
43 |
-
pattern = "
|
44 |
match = re.search(pattern, vad_result, flags=re.IGNORECASE | re.DOTALL)
|
45 |
|
46 |
if match is None:
|
47 |
raise AssertionError("run vad failed: \n{}".format(vad_result))
|
48 |
|
49 |
-
text = match.group(
|
50 |
|
51 |
return text
|
52 |
|
|
|
40 |
)
|
41 |
vad_result = Command.popen(cmd)
|
42 |
|
43 |
+
pattern = r"(\d+)[\r\n]+VadFlagPrepare[\r\n]+(\d+)[\r\n]+VadFlagSpeaking[\r\n]+(\d+)[\r\n]+VadFlagNoSpeech[\r\n]+(\d+)[\r\n]+VadFlagPrepare[\r\n]+(\d+)[\r\n]+VadFlagSpeaking"
|
44 |
match = re.search(pattern, vad_result, flags=re.IGNORECASE | re.DOTALL)
|
45 |
|
46 |
if match is None:
|
47 |
raise AssertionError("run vad failed: \n{}".format(vad_result))
|
48 |
|
49 |
+
text = match.group(0)
|
50 |
|
51 |
return text
|
52 |
|