Spaces:
Sleeping
Sleeping
update
Browse files- .gitattributes +1 -0
- examples/wenet/toolbox_infer.py +3 -3
- main.py +7 -7
- toolbox/k2_sherpa/{models.py → nn_models.py} +0 -0
.gitattributes
CHANGED
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
|
|
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
37 |
+
*.whl filter=lfs diff=lfs merge=lfs -text
|
examples/wenet/toolbox_infer.py
CHANGED
@@ -18,7 +18,7 @@ import torchaudio
|
|
18 |
|
19 |
from project_settings import project_path, temp_directory
|
20 |
from toolbox.k2_sherpa.utils import audio_convert
|
21 |
-
from toolbox.k2_sherpa import decode,
|
22 |
|
23 |
|
24 |
def get_args():
|
@@ -51,13 +51,13 @@ def main():
|
|
51 |
)
|
52 |
|
53 |
# load recognizer
|
54 |
-
m_dict =
|
55 |
|
56 |
local_model_dir = Path(args.model_dir)
|
57 |
nn_model_file = local_model_dir / m_dict["nn_model_file"]
|
58 |
tokens_file = local_model_dir / m_dict["tokens_file"]
|
59 |
|
60 |
-
recognizer =
|
61 |
repo_id=m_dict["repo_id"],
|
62 |
nn_model_file=nn_model_file.as_posix(),
|
63 |
tokens_file=tokens_file.as_posix(),
|
|
|
18 |
|
19 |
from project_settings import project_path, temp_directory
|
20 |
from toolbox.k2_sherpa.utils import audio_convert
|
21 |
+
from toolbox.k2_sherpa import decode, nn_models
|
22 |
|
23 |
|
24 |
def get_args():
|
|
|
51 |
)
|
52 |
|
53 |
# load recognizer
|
54 |
+
m_dict = nn_models.model_map["Chinese"][0]
|
55 |
|
56 |
local_model_dir = Path(args.model_dir)
|
57 |
nn_model_file = local_model_dir / m_dict["nn_model_file"]
|
58 |
tokens_file = local_model_dir / m_dict["tokens_file"]
|
59 |
|
60 |
+
recognizer = nn_models.load_recognizer(
|
61 |
repo_id=m_dict["repo_id"],
|
62 |
nn_model_file=nn_model_file.as_posix(),
|
63 |
tokens_file=tokens_file.as_posix(),
|
main.py
CHANGED
@@ -21,7 +21,7 @@ import torch
|
|
21 |
import torchaudio
|
22 |
|
23 |
from toolbox.k2_sherpa.examples import examples
|
24 |
-
from toolbox.k2_sherpa import decode,
|
25 |
from toolbox.k2_sherpa.utils import audio_convert
|
26 |
|
27 |
main_logger = logging.getLogger("main")
|
@@ -40,10 +40,10 @@ def get_args():
|
|
40 |
|
41 |
|
42 |
def update_model_dropdown(language: str):
|
43 |
-
if language not in
|
44 |
raise ValueError(f"Unsupported language: {language}")
|
45 |
|
46 |
-
choices =
|
47 |
choices = [c["repo_id"] for c in choices]
|
48 |
return gr.Dropdown(
|
49 |
choices=choices,
|
@@ -88,7 +88,7 @@ def process(
|
|
88 |
)
|
89 |
|
90 |
# model settings
|
91 |
-
m_list =
|
92 |
if m_list is None:
|
93 |
raise AssertionError("language invalid: {}".format(language))
|
94 |
|
@@ -104,7 +104,7 @@ def process(
|
|
104 |
nn_model_file = local_model_dir / m_dict["nn_model_file"]
|
105 |
tokens_file = local_model_dir / m_dict["tokens_file"]
|
106 |
|
107 |
-
recognizer =
|
108 |
repo_id=m_dict["repo_id"],
|
109 |
nn_model_file=nn_model_file.as_posix(),
|
110 |
tokens_file=tokens_file.as_posix(),
|
@@ -202,10 +202,10 @@ def main():
|
|
202 |
|
203 |
title = "# Automatic Speech Recognition with Next-gen Kaldi"
|
204 |
|
205 |
-
language_choices = list(
|
206 |
|
207 |
language_to_models = defaultdict(list)
|
208 |
-
for k, v in
|
209 |
for m in v:
|
210 |
repo_id = m["repo_id"]
|
211 |
language_to_models[k].append(repo_id)
|
|
|
21 |
import torchaudio
|
22 |
|
23 |
from toolbox.k2_sherpa.examples import examples
|
24 |
+
from toolbox.k2_sherpa import decode, nn_models
|
25 |
from toolbox.k2_sherpa.utils import audio_convert
|
26 |
|
27 |
main_logger = logging.getLogger("main")
|
|
|
40 |
|
41 |
|
42 |
def update_model_dropdown(language: str):
|
43 |
+
if language not in nn_models.model_map.keys():
|
44 |
raise ValueError(f"Unsupported language: {language}")
|
45 |
|
46 |
+
choices = nn_models.model_map[language]
|
47 |
choices = [c["repo_id"] for c in choices]
|
48 |
return gr.Dropdown(
|
49 |
choices=choices,
|
|
|
88 |
)
|
89 |
|
90 |
# model settings
|
91 |
+
m_list = nn_models.model_map.get(language)
|
92 |
if m_list is None:
|
93 |
raise AssertionError("language invalid: {}".format(language))
|
94 |
|
|
|
104 |
nn_model_file = local_model_dir / m_dict["nn_model_file"]
|
105 |
tokens_file = local_model_dir / m_dict["tokens_file"]
|
106 |
|
107 |
+
recognizer = nn_models.load_recognizer(
|
108 |
repo_id=m_dict["repo_id"],
|
109 |
nn_model_file=nn_model_file.as_posix(),
|
110 |
tokens_file=tokens_file.as_posix(),
|
|
|
202 |
|
203 |
title = "# Automatic Speech Recognition with Next-gen Kaldi"
|
204 |
|
205 |
+
language_choices = list(nn_models.model_map.keys())
|
206 |
|
207 |
language_to_models = defaultdict(list)
|
208 |
+
for k, v in nn_models.model_map.items():
|
209 |
for m in v:
|
210 |
repo_id = m["repo_id"]
|
211 |
language_to_models[k].append(repo_id)
|
toolbox/k2_sherpa/{models.py → nn_models.py}
RENAMED
File without changes
|