HoneyTian commited on
Commit
38311e1
1 Parent(s): 93be054
examples/wenet/infer.py CHANGED
@@ -58,7 +58,6 @@ def main():
58
  decoding_method="greedy_search",
59
  num_active_paths=2,
60
  )
61
-
62
  recognizer = sherpa.OfflineRecognizer(config)
63
 
64
  signal, sample_rate = librosa.load(args.filename, sr=args.sample_rate)
 
58
  decoding_method="greedy_search",
59
  num_active_paths=2,
60
  )
 
61
  recognizer = sherpa.OfflineRecognizer(config)
62
 
63
  signal, sample_rate = librosa.load(args.filename, sr=args.sample_rate)
examples/wenet/toolbox_infer.py CHANGED
@@ -69,24 +69,37 @@ def main():
69
  nn_model_file = local_model_dir / m_dict["nn_model_file"]
70
  tokens_file = local_model_dir / m_dict["tokens_file"]
71
 
72
- recognizer = models.load_recognizer(
73
- repo_id=m_dict["repo_id"],
74
- nn_model_file=nn_model_file.as_posix(),
75
- tokens_file=tokens_file.as_posix(),
76
- sub_folder=m_dict["sub_folder"],
77
- local_model_dir=local_model_dir,
78
- recognizer_type=m_dict["recognizer_type"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  decoding_method="greedy_search",
80
  num_active_paths=2,
81
  )
 
82
 
83
  s = recognizer.create_stream()
84
-
85
  s.accept_wave_file(
86
  temp_file.as_posix()
87
  )
88
  recognizer.decode_stream(s)
89
-
90
  text = s.result.text.strip()
91
  text = text.lower()
92
  print("text: {}".format(text))
 
69
  nn_model_file = local_model_dir / m_dict["nn_model_file"]
70
  tokens_file = local_model_dir / m_dict["tokens_file"]
71
 
72
+ # recognizer = models.load_recognizer(
73
+ # repo_id=m_dict["repo_id"],
74
+ # nn_model_file=nn_model_file.as_posix(),
75
+ # tokens_file=tokens_file.as_posix(),
76
+ # sub_folder=m_dict["sub_folder"],
77
+ # local_model_dir=local_model_dir,
78
+ # recognizer_type=m_dict["recognizer_type"],
79
+ # decoding_method="greedy_search",
80
+ # num_active_paths=2,
81
+ # )
82
+
83
+ feat_config = sherpa.FeatureConfig(normalize_samples=False)
84
+ feat_config.fbank_opts.frame_opts.samp_freq = args.sample_rate
85
+ feat_config.fbank_opts.mel_opts.num_bins = 80
86
+ feat_config.fbank_opts.frame_opts.dither = 0
87
+
88
+ config = sherpa.OfflineRecognizerConfig(
89
+ nn_model=nn_model_file.as_posix(),
90
+ tokens=tokens_file.as_posix(),
91
+ use_gpu=False,
92
+ feat_config=feat_config,
93
  decoding_method="greedy_search",
94
  num_active_paths=2,
95
  )
96
+ recognizer = sherpa.OfflineRecognizer(config)
97
 
98
  s = recognizer.create_stream()
 
99
  s.accept_wave_file(
100
  temp_file.as_posix()
101
  )
102
  recognizer.decode_stream(s)
 
103
  text = s.result.text.strip()
104
  text = text.lower()
105
  print("text: {}".format(text))