csukuangfj commited on
Commit
72452c7
1 Parent(s): cc12677

add arabic models

Browse files
examples.py CHANGED
@@ -197,4 +197,23 @@ examples = [
197
  4,
198
  "./test_wavs/tibetan/a_0_cacm-A70_31118.wav",
199
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  ]
 
197
  4,
198
  "./test_wavs/tibetan/a_0_cacm-A70_31118.wav",
199
  ],
200
+ # arabic
201
+ [
202
+ "Arabic",
203
+ "AmirHussein/icefall-asr-mgb2-conformer_ctc-2022-27-06" "greedy_search",
204
+ 4,
205
+ "./test_wavs/arabic/94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0051454:0052244.wav",
206
+ ],
207
+ [
208
+ "Arabic",
209
+ "AmirHussein/icefall-asr-mgb2-conformer_ctc-2022-27-06" "greedy_search",
210
+ 4,
211
+ "./test_wavs/arabic/94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0052244:0053004.wav",
212
+ ],
213
+ [
214
+ "Arabic",
215
+ "AmirHussein/icefall-asr-mgb2-conformer_ctc-2022-27-06" "greedy_search",
216
+ 4,
217
+ "./test_wavs/arabic/94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0053813:0054281.wav",
218
+ ],
219
  ]
model.py CHANGED
@@ -51,6 +51,10 @@ def get_pretrained_model(
51
  return tibetan_models[repo_id](
52
  repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
53
  )
 
 
 
 
54
  else:
55
  raise ValueError(f"Unsupported repo_id: {repo_id}")
56
 
@@ -402,6 +406,42 @@ def _get_tibetan_pre_trained_model(
402
  return recognizer
403
 
404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  chinese_models = {
406
  "luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2": _get_wenetspeech_pre_trained_model, # noqa
407
  "yuekai/icefall-asr-aishell2-pruned-transducer-stateless5-A-2022-07-12": _get_aishell2_pretrained_model, # noqa
@@ -427,11 +467,16 @@ tibetan_models = {
427
  "syzym/icefall-asr-xbmu-amdo31-pruned-transducer-stateless5-2022-11-29": _get_tibetan_pre_trained_model, # noqa
428
  }
429
 
 
 
 
 
430
  all_models = {
431
  **chinese_models,
432
  **english_models,
433
  **chinese_english_mixed_models,
434
  **tibetan_models,
 
435
  }
436
 
437
  language_to_models = {
@@ -439,4 +484,5 @@ language_to_models = {
439
  "English": list(english_models.keys()),
440
  "Chinese+English": list(chinese_english_mixed_models.keys()),
441
  "Tibetan": list(tibetan_models.keys()),
 
442
  }
 
51
  return tibetan_models[repo_id](
52
  repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
53
  )
54
+ elif repo_id in arabic_models:
55
+ return arabic_models[repo_id](
56
+ repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
57
+ )
58
  else:
59
  raise ValueError(f"Unsupported repo_id: {repo_id}")
60
 
 
406
  return recognizer
407
 
408
 
409
+ @lru_cache(maxsize=10)
410
+ def _get_arabic_pre_trained_model(
411
+ repo_id: str,
412
+ decoding_method: str,
413
+ num_active_paths: int,
414
+ ):
415
+ assert repo_id in [
416
+ "AmirHussein/icefall-asr-mgb2-conformer_ctc-2022-27-06",
417
+ ], repo_id
418
+
419
+ nn_model = _get_nn_model_filename(
420
+ repo_id=repo_id,
421
+ filename=filename,
422
+ )
423
+
424
+ tokens = _get_token_filename(repo_id=repo_id, subfolder="data/lang_bpe_5000")
425
+
426
+ feat_config = sherpa.FeatureConfig()
427
+ feat_config.fbank_opts.frame_opts.samp_freq = sample_rate
428
+ feat_config.fbank_opts.mel_opts.num_bins = 80
429
+ feat_config.fbank_opts.frame_opts.dither = 0
430
+
431
+ config = sherpa.OfflineRecognizerConfig(
432
+ nn_model=nn_model,
433
+ tokens=tokens,
434
+ use_gpu=False,
435
+ feat_config=feat_config,
436
+ decoding_method=decoding_method,
437
+ num_active_paths=num_active_paths,
438
+ )
439
+
440
+ recognizer = sherpa.OfflineRecognizer(config)
441
+
442
+ return recognizer
443
+
444
+
445
  chinese_models = {
446
  "luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2": _get_wenetspeech_pre_trained_model, # noqa
447
  "yuekai/icefall-asr-aishell2-pruned-transducer-stateless5-A-2022-07-12": _get_aishell2_pretrained_model, # noqa
 
467
  "syzym/icefall-asr-xbmu-amdo31-pruned-transducer-stateless5-2022-11-29": _get_tibetan_pre_trained_model, # noqa
468
  }
469
 
470
+ arabic_models = {
471
+ "AmirHussein/icefall-asr-mgb2-conformer_ctc-2022-27-06": _get_arabic_pre_trained_model, # noqa
472
+ }
473
+
474
  all_models = {
475
  **chinese_models,
476
  **english_models,
477
  **chinese_english_mixed_models,
478
  **tibetan_models,
479
+ **arabic_models,
480
  }
481
 
482
  language_to_models = {
 
484
  "English": list(english_models.keys()),
485
  "Chinese+English": list(chinese_english_mixed_models.keys()),
486
  "Tibetan": list(tibetan_models.keys()),
487
+ "Arabic": list(arabic_models.keys()),
488
  }
test_wavs/arabic/94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0051454:0052244.wav ADDED
Binary file (253 kB). View file
 
test_wavs/arabic/94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0052244:0053004.wav ADDED
Binary file (243 kB). View file
 
test_wavs/arabic/94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0053813:0054281.wav ADDED
Binary file (150 kB). View file
 
test_wavs/arabic/trans.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ 94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0053813:0054281 بعد أن عجز وبدأ يصدر مشكلات شعبه ومشكلات مصر
2
+ 94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0051454:0052244 وهؤلاء أولياء الشيطان ها هو ذا أحدهم الآن ضيفا عليكم على قناة الجزيرة ولا يستحي في ذلك
3
+ 94D37D38-B203-4FC0-9F3A-538F5C174920_spk-0001_seg-0052244:0053004 عندما استغاث الليبيون بالعالم استغاثوا لرفع الظلم وليس لقهر إرادة الأمة ومصادرة الحياة الدستورية