csukuangfj
commited on
Commit
•
f7cc7c3
1
Parent(s):
808a042
add a new model
Browse files
model.py
CHANGED
@@ -243,6 +243,43 @@ def _get_wenetspeech_pre_trained_model(repo_id):
|
|
243 |
return recognizer
|
244 |
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
def _get_english_model(repo_id: str) -> sherpa_onnx.OfflineRecognizer:
|
247 |
assert (
|
248 |
repo_id
|
@@ -285,6 +322,7 @@ def _get_english_model(repo_id: str) -> sherpa_onnx.OfflineRecognizer:
|
|
285 |
|
286 |
chinese_models = {
|
287 |
"csukuangfj/sherpa-onnx-conformer-zh-stateless2-2023-05-23": _get_wenetspeech_pre_trained_model, # noqa
|
|
|
288 |
}
|
289 |
|
290 |
english_models = {
|
|
|
243 |
return recognizer
|
244 |
|
245 |
|
246 |
+
def _get_multi_zh_hans_pre_trained_model(repo_id):
|
247 |
+
assert repo_id in ("zrjin/sherpa-onnx-zipformer-multi-zh-hans-2023-9-2",), repo_id
|
248 |
+
|
249 |
+
encoder_model = _get_nn_model_filename(
|
250 |
+
repo_id=repo_id,
|
251 |
+
filename="encoder-epoch-20-avg-1.onnx",
|
252 |
+
subfolder=".",
|
253 |
+
)
|
254 |
+
|
255 |
+
decoder_model = _get_nn_model_filename(
|
256 |
+
repo_id=repo_id,
|
257 |
+
filename="decoder-epoch-20-avg-1.onnx",
|
258 |
+
subfolder=".",
|
259 |
+
)
|
260 |
+
|
261 |
+
joiner_model = _get_nn_model_filename(
|
262 |
+
repo_id=repo_id,
|
263 |
+
filename="joiner-epoch-20-avg-1.onnx",
|
264 |
+
subfolder=".",
|
265 |
+
)
|
266 |
+
|
267 |
+
tokens = _get_token_filename(repo_id=repo_id, subfolder=".")
|
268 |
+
|
269 |
+
recognizer = sherpa_onnx.OfflineRecognizer.from_transducer(
|
270 |
+
tokens=tokens,
|
271 |
+
encoder=encoder_model,
|
272 |
+
decoder=decoder_model,
|
273 |
+
joiner=joiner_model,
|
274 |
+
num_threads=2,
|
275 |
+
sample_rate=16000,
|
276 |
+
feature_dim=80,
|
277 |
+
decoding_method="greedy_search",
|
278 |
+
)
|
279 |
+
|
280 |
+
return recognizer
|
281 |
+
|
282 |
+
|
283 |
def _get_english_model(repo_id: str) -> sherpa_onnx.OfflineRecognizer:
|
284 |
assert (
|
285 |
repo_id
|
|
|
322 |
|
323 |
chinese_models = {
|
324 |
"csukuangfj/sherpa-onnx-conformer-zh-stateless2-2023-05-23": _get_wenetspeech_pre_trained_model, # noqa
|
325 |
+
"zrjin/sherpa-onnx-zipformer-multi-zh-hans-2023-9-2": _get_multi_zh_hans_pre_trained_model, # noqa
|
326 |
}
|
327 |
|
328 |
english_models = {
|