HoneyTian commited on
Commit
88a6c78
1 Parent(s): fc794b7
examples/wenet/toolbox_infer.py CHANGED
@@ -42,25 +42,25 @@ def main():
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
-
49
- temp_file = temp_directory / "temp.wav"
50
- wavfile.write(
51
- temp_file.as_posix(),
52
- rate=args.sample_rate,
53
- data=signal
54
- )
55
 
56
  # audio convert
57
- # in_filename = Path(args.in_filename)
58
- # out_filename = Path(tempfile.gettempdir()) / "asr" / in_filename.name
59
- # out_filename.parent.mkdir(parents=True, exist_ok=True)
60
- #
61
- # audio_convert(in_filename=in_filename.as_posix(),
62
- # out_filename=out_filename.as_posix(),
63
- # )
64
 
65
  # load recognizer
66
  m_dict = models.model_map["Chinese"][0]
@@ -105,7 +105,7 @@ def main():
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
 
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
+ #
49
+ # temp_file = temp_directory / "temp.wav"
50
+ # wavfile.write(
51
+ # temp_file.as_posix(),
52
+ # rate=args.sample_rate,
53
+ # data=signal
54
+ # )
55
 
56
  # audio convert
57
+ in_filename = Path(args.in_filename)
58
+ out_filename = Path(tempfile.gettempdir()) / "asr" / in_filename.name
59
+ out_filename.parent.mkdir(parents=True, exist_ok=True)
60
+
61
+ audio_convert(in_filename=in_filename.as_posix(),
62
+ out_filename=out_filename.as_posix(),
63
+ )
64
 
65
  # load recognizer
66
  m_dict = models.model_map["Chinese"][0]
 
105
  # print("text: {}".format(text))
106
 
107
  text = decode.decode_by_recognizer(recognizer=recognizer,
108
+ filename=out_filename.as_posix(),
109
  )
110
  print("text: {}".format(text))
111
  return
toolbox/k2_sherpa/decode.py CHANGED
@@ -40,7 +40,6 @@ def decode_offline_recognizer(recognizer: sherpa.OfflineRecognizer,
40
  recognizer.decode_stream(s)
41
 
42
  text = s.result.text.strip()
43
- print("text: {}".format(text))
44
  return text.lower()
45
 
46
 
 
40
  recognizer.decode_stream(s)
41
 
42
  text = s.result.text.strip()
 
43
  return text.lower()
44
 
45