Spaces:
Sleeping
Sleeping
update
Browse files- examples/wenet/toolbox_infer.py +21 -10
examples/wenet/toolbox_infer.py
CHANGED
@@ -54,13 +54,13 @@ def main():
|
|
54 |
)
|
55 |
|
56 |
# audio convert
|
57 |
-
in_filename = Path(args.in_filename)
|
58 |
-
out_filename = Path(tempfile.gettempdir()) / "asr" / in_filename.name
|
59 |
-
out_filename.parent.mkdir(parents=True, exist_ok=True)
|
60 |
-
|
61 |
-
audio_convert(in_filename=in_filename.as_posix(),
|
62 |
-
|
63 |
-
|
64 |
|
65 |
# load recognizer
|
66 |
m_dict = models.model_map["Chinese"][0]
|
@@ -80,10 +80,21 @@ def main():
|
|
80 |
num_active_paths=2,
|
81 |
)
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
print("text: {}".format(text))
|
|
|
|
|
|
|
|
|
|
|
87 |
return
|
88 |
|
89 |
|
|
|
54 |
)
|
55 |
|
56 |
# audio convert
|
57 |
+
# in_filename = Path(args.in_filename)
|
58 |
+
# out_filename = Path(tempfile.gettempdir()) / "asr" / in_filename.name
|
59 |
+
# out_filename.parent.mkdir(parents=True, exist_ok=True)
|
60 |
+
#
|
61 |
+
# audio_convert(in_filename=in_filename.as_posix(),
|
62 |
+
# out_filename=out_filename.as_posix(),
|
63 |
+
# )
|
64 |
|
65 |
# load recognizer
|
66 |
m_dict = models.model_map["Chinese"][0]
|
|
|
80 |
num_active_paths=2,
|
81 |
)
|
82 |
|
83 |
+
s = recognizer.create_stream()
|
84 |
+
|
85 |
+
s.accept_wave_file(
|
86 |
+
temp_file.as_posix()
|
87 |
+
)
|
88 |
+
recognizer.decode_stream(s)
|
89 |
+
|
90 |
+
text = s.result.text.strip()
|
91 |
+
text = text.lower()
|
92 |
print("text: {}".format(text))
|
93 |
+
|
94 |
+
# text = decode.decode_by_recognizer(recognizer=recognizer,
|
95 |
+
# filename=temp_file.as_posix(),
|
96 |
+
# )
|
97 |
+
# print("text: {}".format(text))
|
98 |
return
|
99 |
|
100 |
|