HoneyTian commited on
Commit
8dc832e
·
1 Parent(s): 4281a4a
examples/wenet/toolbox_infer.py CHANGED
@@ -38,31 +38,6 @@ def get_args():
38
  return args
39
 
40
 
41
- def load_sherpa_offline_recognizer(nn_model_file: str,
42
- tokens_file: str,
43
- sample_rate: int = 16000,
44
- num_active_paths: int = 2,
45
- decoding_method: str = "greedy_search",
46
- num_mel_bins: int = 80,
47
- frame_dither: int = 0,
48
- ):
49
- feat_config = sherpa.FeatureConfig(normalize_samples=False)
50
- feat_config.fbank_opts.frame_opts.samp_freq = sample_rate
51
- feat_config.fbank_opts.mel_opts.num_bins = 80
52
- feat_config.fbank_opts.frame_opts.dither = 0
53
-
54
- config = sherpa.OfflineRecognizerConfig(
55
- nn_model=nn_model_file,
56
- tokens=tokens_file,
57
- use_gpu=False,
58
- feat_config=feat_config,
59
- decoding_method="greedy_search",
60
- num_active_paths=2,
61
- )
62
- recognizer = sherpa.OfflineRecognizer(config)
63
- return recognizer
64
-
65
-
66
  def main():
67
  args = get_args()
68
 
 
38
  return args
39
 
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  def main():
42
  args = get_args()
43
 
toolbox/k2_sherpa/models.py CHANGED
@@ -56,7 +56,7 @@ def download_model(repo_id: str,
56
  return nn_model_file, tokens_file
57
 
58
 
59
- def load_sherpa_offline_recognizer(nn_model_file: str,
60
  tokens_file: str,
61
  sample_rate: int = 16000,
62
  num_active_paths: int = 2,
@@ -66,8 +66,8 @@ def load_sherpa_offline_recognizer(nn_model_file: str,
66
  ):
67
  feat_config = sherpa.FeatureConfig(normalize_samples=False)
68
  feat_config.fbank_opts.frame_opts.samp_freq = sample_rate
69
- feat_config.fbank_opts.mel_opts.num_bins = 80
70
- feat_config.fbank_opts.frame_opts.dither = 0
71
 
72
  config = sherpa.OfflineRecognizerConfig(
73
  nn_model=nn_model_file,
@@ -81,7 +81,7 @@ def load_sherpa_offline_recognizer(nn_model_file: str,
81
  return recognizer
82
 
83
 
84
- def load_sherpa_offline_recognizer22(nn_model_file: str,
85
  tokens_file: str,
86
  sample_rate: int = 16000,
87
  num_active_paths: int = 2,
@@ -89,7 +89,7 @@ def load_sherpa_offline_recognizer22(nn_model_file: str,
89
  num_mel_bins: int = 80,
90
  frame_dither: int = 0,
91
  ):
92
- feat_config = sherpa.FeatureConfig()
93
  feat_config.fbank_opts.frame_opts.samp_freq = sample_rate
94
  feat_config.fbank_opts.mel_opts.num_bins = num_mel_bins
95
  feat_config.fbank_opts.frame_opts.dither = frame_dither
 
56
  return nn_model_file, tokens_file
57
 
58
 
59
+ def load_sherpa_offline_recognizer22(nn_model_file: str,
60
  tokens_file: str,
61
  sample_rate: int = 16000,
62
  num_active_paths: int = 2,
 
66
  ):
67
  feat_config = sherpa.FeatureConfig(normalize_samples=False)
68
  feat_config.fbank_opts.frame_opts.samp_freq = sample_rate
69
+ feat_config.fbank_opts.mel_opts.num_bins = num_mel_bins
70
+ feat_config.fbank_opts.frame_opts.dither = frame_dither
71
 
72
  config = sherpa.OfflineRecognizerConfig(
73
  nn_model=nn_model_file,
 
81
  return recognizer
82
 
83
 
84
+ def load_sherpa_offline_recognizer(nn_model_file: str,
85
  tokens_file: str,
86
  sample_rate: int = 16000,
87
  num_active_paths: int = 2,
 
89
  num_mel_bins: int = 80,
90
  frame_dither: int = 0,
91
  ):
92
+ feat_config = sherpa.FeatureConfig(normalize_samples=False)
93
  feat_config.fbank_opts.frame_opts.samp_freq = sample_rate
94
  feat_config.fbank_opts.mel_opts.num_bins = num_mel_bins
95
  feat_config.fbank_opts.frame_opts.dither = frame_dither