HoneyTian commited on
Commit
fc794b7
1 Parent(s): 38311e1
Files changed (1) hide show
  1. examples/wenet/toolbox_infer.py +13 -13
examples/wenet/toolbox_infer.py CHANGED
@@ -42,7 +42,7 @@ def main():
42
  args = get_args()
43
 
44
  # audio convert
45
- signal, sample_rate = librosa.load(args.in_filename, sr=16000)
46
  signal *= 32768.0
47
  signal = np.array(signal, dtype=np.int16)
48
 
@@ -95,19 +95,19 @@ def main():
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))
106
-
107
- # text = decode.decode_by_recognizer(recognizer=recognizer,
108
- # filename=temp_file.as_posix(),
109
- # )
110
  # print("text: {}".format(text))
 
 
 
 
 
111
  return
112
 
113
 
 
42
  args = get_args()
43
 
44
  # audio convert
45
+ signal, sample_rate = librosa.load(args.in_filename, sr=args.sample_rate)
46
  signal *= 32768.0
47
  signal = np.array(signal, dtype=np.int16)
48
 
 
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))
106
+
107
+ text = decode.decode_by_recognizer(recognizer=recognizer,
108
+ filename=temp_file.as_posix(),
109
+ )
110
+ print("text: {}".format(text))
111
  return
112
 
113