csukuangfj commited on
Commit
816c3d4
1 Parent(s): 445fdb8

add German

Browse files
examples.py CHANGED
@@ -219,4 +219,18 @@ examples = [
219
  4,
220
  "./test_wavs/arabic/c.wav",
221
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  ]
 
219
  4,
220
  "./test_wavs/arabic/c.wav",
221
  ],
222
+ [
223
+ "German",
224
+ "csukuangfj/wav2vec2.0-torchaudio",
225
+ "greedy_search",
226
+ 4,
227
+ "./test_wavs/german/20120315-0900-PLENARY-14-de_20120315.wav",
228
+ ],
229
+ [
230
+ "German",
231
+ "csukuangfj/wav2vec2.0-torchaudio",
232
+ "greedy_search",
233
+ 4,
234
+ "./test_wavs/german/20170517-0900-PLENARY-16-de_20170517.wav",
235
+ ],
236
  ]
model.py CHANGED
@@ -55,6 +55,10 @@ def get_pretrained_model(
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
 
@@ -483,6 +487,41 @@ def _get_arabic_pre_trained_model(
483
  return recognizer
484
 
485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  chinese_models = {
487
  "luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2": _get_wenetspeech_pre_trained_model, # noqa
488
  "yuekai/icefall-asr-aishell2-pruned-transducer-stateless5-A-2022-07-12": _get_aishell2_pretrained_model, # noqa
@@ -514,12 +553,17 @@ arabic_models = {
514
  "AmirHussein/icefall-asr-mgb2-conformer_ctc-2022-27-06": _get_arabic_pre_trained_model, # noqa
515
  }
516
 
 
 
 
 
517
  all_models = {
518
  **chinese_models,
519
  **english_models,
520
  **chinese_english_mixed_models,
521
  **tibetan_models,
522
  **arabic_models,
 
523
  }
524
 
525
  language_to_models = {
@@ -528,4 +572,5 @@ language_to_models = {
528
  "Chinese+English": list(chinese_english_mixed_models.keys()),
529
  "Tibetan": list(tibetan_models.keys()),
530
  "Arabic": list(arabic_models.keys()),
 
531
  }
 
55
  return arabic_models[repo_id](
56
  repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
57
  )
58
+ elif repo_id in german_models:
59
+ return german_models[repo_id](
60
+ repo_id, decoding_method=decoding_method, num_active_paths=num_active_paths
61
+ )
62
  else:
63
  raise ValueError(f"Unsupported repo_id: {repo_id}")
64
 
 
487
  return recognizer
488
 
489
 
490
+ @lru_cache(maxsize=10)
491
+ def _get_german_pre_trained_model(
492
+ repo_id: str,
493
+ decoding_method: str,
494
+ num_active_paths: int,
495
+ ):
496
+ assert repo_id in [
497
+ "csukuangfj/wav2vec2.0-torchaudio",
498
+ ], repo_id
499
+
500
+ nn_model = _get_nn_model_filename(
501
+ repo_id=repo_id,
502
+ filename="voxpopuli_asr_base_10k_de.pt",
503
+ subfolder="./",
504
+ )
505
+
506
+ tokens = _get_token_filename(
507
+ repo_id=repo_id,
508
+ filename="tokens-de.txt",
509
+ subfolder="./",
510
+ )
511
+
512
+ config = sherpa.OfflineRecognizerConfig(
513
+ nn_model=nn_model,
514
+ tokens=tokens,
515
+ use_gpu=False,
516
+ decoding_method=decoding_method,
517
+ num_active_paths=num_active_paths,
518
+ )
519
+
520
+ recognizer = sherpa.OfflineRecognizer(config)
521
+
522
+ return recognizer
523
+
524
+
525
  chinese_models = {
526
  "luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2": _get_wenetspeech_pre_trained_model, # noqa
527
  "yuekai/icefall-asr-aishell2-pruned-transducer-stateless5-A-2022-07-12": _get_aishell2_pretrained_model, # noqa
 
553
  "AmirHussein/icefall-asr-mgb2-conformer_ctc-2022-27-06": _get_arabic_pre_trained_model, # noqa
554
  }
555
 
556
+ german_models = {
557
+ "csukuangfj/wav2vec2.0-torchaudio": _get_german_pre_trained_model,
558
+ }
559
+
560
  all_models = {
561
  **chinese_models,
562
  **english_models,
563
  **chinese_english_mixed_models,
564
  **tibetan_models,
565
  **arabic_models,
566
+ **german_models,
567
  }
568
 
569
  language_to_models = {
 
572
  "Chinese+English": list(chinese_english_mixed_models.keys()),
573
  "Tibetan": list(tibetan_models.keys()),
574
  "Arabic": list(arabic_models.keys()),
575
+ "German": list(german_models.keys()),
576
  }
test_wavs/german/20120315-0900-PLENARY-14-de_20120315.wav ADDED
Binary file (381 kB). View file
 
test_wavs/german/20170517-0900-PLENARY-16-de_20170517.wav ADDED
Binary file (282 kB). View file