csukuangfj commited on
Commit
134853d
1 Parent(s): c68440f

add a new model

Browse files
Files changed (1) hide show
  1. model.py +51 -1
model.py CHANGED
@@ -168,6 +168,10 @@ def get_pretrained_model(
168
  return chinese_english_mixed_models[repo_id](
169
  repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
170
  )
 
 
 
 
171
  elif repo_id in tibetan_models:
172
  return tibetan_models[repo_id](
173
  repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
@@ -790,7 +794,7 @@ def _get_french_pre_trained_model(
790
  repo_id: str,
791
  decoding_method: str,
792
  num_active_paths: int,
793
- ):
794
  assert repo_id in [
795
  "shaojieli/sherpa-onnx-streaming-zipformer-fr-2023-04-14",
796
  ], repo_id
@@ -925,6 +929,44 @@ def _get_gigaspeech_pre_trained_model_onnx(
925
  return recognizer
926
 
927
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
928
  @lru_cache(maxsize=10)
929
  def _get_paraformer_en_pre_trained_model(
930
  repo_id: str,
@@ -1157,10 +1199,17 @@ russian_models = {
1157
  "alphacep/vosk-model-small-ru": _get_russian_pre_trained_model,
1158
  }
1159
 
 
 
 
 
 
 
1160
  all_models = {
1161
  **chinese_models,
1162
  **english_models,
1163
  **chinese_english_mixed_models,
 
1164
  # **japanese_models,
1165
  **tibetan_models,
1166
  **arabic_models,
@@ -1173,6 +1222,7 @@ language_to_models = {
1173
  "Chinese": list(chinese_models.keys()),
1174
  "English": list(english_models.keys()),
1175
  "Chinese+English": list(chinese_english_mixed_models.keys()),
 
1176
  # "Japanese": list(japanese_models.keys()),
1177
  "Tibetan": list(tibetan_models.keys()),
1178
  "Arabic": list(arabic_models.keys()),
 
168
  return chinese_english_mixed_models[repo_id](
169
  repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
170
  )
171
+ elif repo_id in chinese_cantonese_english_models:
172
+ return chinese_cantonese_english_models[repo_id](
173
+ repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
174
+ )
175
  elif repo_id in tibetan_models:
176
  return tibetan_models[repo_id](
177
  repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
 
794
  repo_id: str,
795
  decoding_method: str,
796
  num_active_paths: int,
797
+ ) -> sherpa_onnx.OfflineRecognizer:
798
  assert repo_id in [
799
  "shaojieli/sherpa-onnx-streaming-zipformer-fr-2023-04-14",
800
  ], repo_id
 
929
  return recognizer
930
 
931
 
932
+ @lru_cache(maxsize=10)
933
+ def _get_paraformer_zh_yue_en_pre_trained_model(
934
+ repo_id: str,
935
+ decoding_method: str,
936
+ num_active_paths: int,
937
+ ) -> sherpa_onnx.OfflineRecognizer:
938
+ assert repo_id in [
939
+ "csukuangfj/sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en",
940
+ ], repo_id
941
+
942
+ encoder_model = _get_nn_model_filename(
943
+ repo_id=repo_id,
944
+ filename="encoder.int8.onnx",
945
+ subfolder=".",
946
+ )
947
+
948
+ decoder_model = _get_nn_model_filename(
949
+ repo_id=repo_id,
950
+ filename="decoder.int8.onnx",
951
+ subfolder=".",
952
+ )
953
+
954
+ tokens = _get_token_filename(repo_id=repo_id, subfolder=".")
955
+
956
+ recognizer = sherpa_onnx.OnlineRecognizer.from_paraformer(
957
+ tokens=tokens,
958
+ encoder=encoder_model,
959
+ decoder=decoder_model,
960
+ num_threads=2,
961
+ sample_rate=16000,
962
+ feature_dim=80,
963
+ decoding_method=decoding_method,
964
+ max_active_paths=num_active_paths,
965
+ )
966
+
967
+ return recognizer
968
+
969
+
970
  @lru_cache(maxsize=10)
971
  def _get_paraformer_en_pre_trained_model(
972
  repo_id: str,
 
1199
  "alphacep/vosk-model-small-ru": _get_russian_pre_trained_model,
1200
  }
1201
 
1202
+ chinese_cantonese_english_models = {
1203
+ "csukuangfj/sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en": _get_paraformer_zh_yue_en_pre_trained_model,
1204
+ # "csukuangfj/sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en": _get_paraformer_en_pre_trained_model,
1205
+ }
1206
+
1207
+
1208
  all_models = {
1209
  **chinese_models,
1210
  **english_models,
1211
  **chinese_english_mixed_models,
1212
+ **chinese_cantonese_english_models,
1213
  # **japanese_models,
1214
  **tibetan_models,
1215
  **arabic_models,
 
1222
  "Chinese": list(chinese_models.keys()),
1223
  "English": list(english_models.keys()),
1224
  "Chinese+English": list(chinese_english_mixed_models.keys()),
1225
+ "Chinese+English+Cantonese": list(chinese_cantonese_english_models.keys()),
1226
  # "Japanese": list(japanese_models.keys()),
1227
  "Tibetan": list(tibetan_models.keys()),
1228
  "Arabic": list(arabic_models.keys()),