csukuangfj
commited on
Commit
·
8cf187c
1
Parent(s):
2d2a512
add a new model
Browse files- model.py +34 -0
- requirements.txt +4 -1
model.py
CHANGED
@@ -164,6 +164,10 @@ def get_pretrained_model(
|
|
164 |
return chinese_models[repo_id](
|
165 |
repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
|
166 |
)
|
|
|
|
|
|
|
|
|
167 |
elif repo_id in english_models:
|
168 |
return english_models[repo_id](
|
169 |
repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
|
@@ -1092,6 +1096,31 @@ def _get_paraformer_en_pre_trained_model(
|
|
1092 |
return recognizer
|
1093 |
|
1094 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1095 |
@lru_cache(maxsize=10)
|
1096 |
def _get_paraformer_pre_trained_model(
|
1097 |
repo_id: str,
|
@@ -1239,6 +1268,10 @@ def _get_multi_zh_hans_pre_trained_model(
|
|
1239 |
return recognizer
|
1240 |
|
1241 |
|
|
|
|
|
|
|
|
|
1242 |
chinese_models = {
|
1243 |
"csukuangfj/sherpa-onnx-paraformer-zh-2024-03-09": _get_paraformer_pre_trained_model,
|
1244 |
"luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2": _get_wenetspeech_pre_trained_model, # noqa
|
@@ -1339,6 +1372,7 @@ all_models = {
|
|
1339 |
}
|
1340 |
|
1341 |
language_to_models = {
|
|
|
1342 |
"Chinese": list(chinese_models.keys()),
|
1343 |
"English": list(english_models.keys()),
|
1344 |
"Chinese+English": list(chinese_english_mixed_models.keys()),
|
|
|
164 |
return chinese_models[repo_id](
|
165 |
repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
|
166 |
)
|
167 |
+
elif repo_id in chinese_dialect_models:
|
168 |
+
return chinese_dialect_models[repo_id](
|
169 |
+
repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
|
170 |
+
)
|
171 |
elif repo_id in english_models:
|
172 |
return english_models[repo_id](
|
173 |
repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
|
|
|
1096 |
return recognizer
|
1097 |
|
1098 |
|
1099 |
+
@lru_cache(maxsize=5)
|
1100 |
+
def _get_chinese_dialect_models(
|
1101 |
+
repo_id: str, decoding_method: str, num_active_paths: int
|
1102 |
+
) -> sherpa_onnx.OfflineRecognizer:
|
1103 |
+
assert repo_id in [
|
1104 |
+
"csukuangfj/sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04",
|
1105 |
+
], repo_id
|
1106 |
+
|
1107 |
+
nn_model = _get_nn_model_filename(
|
1108 |
+
repo_id=repo_id,
|
1109 |
+
filename="model.int8.onnx",
|
1110 |
+
subfolder=".",
|
1111 |
+
)
|
1112 |
+
|
1113 |
+
tokens = _get_token_filename(repo_id=repo_id, subfolder=".")
|
1114 |
+
|
1115 |
+
recognizer = sherpa_onnx.OfflineRecognizer.from_telespeech_ctc(
|
1116 |
+
paraformer=nn_model,
|
1117 |
+
tokens=tokens,
|
1118 |
+
num_threads=2,
|
1119 |
+
)
|
1120 |
+
|
1121 |
+
return recognizer
|
1122 |
+
|
1123 |
+
|
1124 |
@lru_cache(maxsize=10)
|
1125 |
def _get_paraformer_pre_trained_model(
|
1126 |
repo_id: str,
|
|
|
1268 |
return recognizer
|
1269 |
|
1270 |
|
1271 |
+
chinese_models = {
|
1272 |
+
"csukuangfj/sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04": _get_chinese_dialect_models,
|
1273 |
+
}
|
1274 |
+
|
1275 |
chinese_models = {
|
1276 |
"csukuangfj/sherpa-onnx-paraformer-zh-2024-03-09": _get_paraformer_pre_trained_model,
|
1277 |
"luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2": _get_wenetspeech_pre_trained_model, # noqa
|
|
|
1372 |
}
|
1373 |
|
1374 |
language_to_models = {
|
1375 |
+
"超多种中文方言": list(chinese_dialect_models.keys()),
|
1376 |
"Chinese": list(chinese_models.keys()),
|
1377 |
"English": list(english_models.keys()),
|
1378 |
"Chinese+English": list(chinese_english_mixed_models.keys()),
|
requirements.txt
CHANGED
@@ -9,4 +9,7 @@ sentencepiece>=0.1.96
|
|
9 |
numpy
|
10 |
|
11 |
huggingface_hub
|
12 |
-
|
|
|
|
|
|
|
|
9 |
numpy
|
10 |
|
11 |
huggingface_hub
|
12 |
+
|
13 |
+
https://huggingface.co/csukuangfj/sherpa-onnx-wheels /resolve/main/sherpa_onnx-1.9.26-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
14 |
+
|
15 |
+
#sherpa-onnx>=1.9.21
|