programindz commited on
Commit
83778e9
Β·
verified Β·
1 Parent(s): 6178b66

Update app/asr.py

Browse files
Files changed (1) hide show
  1. app/asr.py +6 -6
app/asr.py CHANGED
@@ -24,9 +24,9 @@ def resample_audio(audio: np.ndarray, orig_sr: int, target_sr: int) -> np.ndarra
24
  def create_recognizer():
25
 
26
  tokens_path = 'app/model parts/tokens.txt'
27
- encoder_path = 'app/model parts/encoder-epoch-35-avg-7-chunk-32-left-256.fp16.onnx'
28
- decoder_path = 'app/model parts/decoder-epoch-35-avg-7-chunk-32-left-256.fp16.onnx'
29
- joiner_path = 'app/model parts/joiner-epoch-35-avg-7-chunk-32-left-256.fp16.onnx'
30
 
31
 
32
  # β€”β€”β€” Fallback to original greedy-search (no hotword biasing) β€”β€”β€”
@@ -38,7 +38,7 @@ def create_recognizer():
38
  provider="cpu",
39
  # device=0,
40
  num_threads=1,
41
- sample_rate=16000,
42
  feature_dim=80,
43
  decoding_method="modified_beam_search",
44
  # endpoint detection parameters
@@ -50,10 +50,10 @@ def stream_audio(raw_pcm_bytes, stream, recognizer, orig_sr):
50
  if audio.size == 0:
51
  return "", 0.0
52
 
53
- resampled = resample_audio(audio, orig_sr, 16000)
54
  rms = float(np.sqrt(np.mean(resampled ** 2)))
55
 
56
- stream.accept_waveform(16000, resampled)
57
  if recognizer.is_ready(stream):
58
  # print(stream)
59
  recognizer.decode_streams([stream])
 
24
  def create_recognizer():
25
 
26
  tokens_path = 'app/model parts/tokens.txt'
27
+ encoder_path = 'app/model parts/encoder-epoch-80-avg-5-chunk-32-left-256.fp16.onnx'
28
+ decoder_path = 'app/model parts/decoder-epoch-80-avg-5-chunk-32-left-256.fp16.onnx'
29
+ joiner_path = 'app/model parts/joiner-epoch-80-avg-5-chunk-32-left-256.fp16.onnx'
30
 
31
 
32
  # β€”β€”β€” Fallback to original greedy-search (no hotword biasing) β€”β€”β€”
 
38
  provider="cpu",
39
  # device=0,
40
  num_threads=1,
41
+ sample_rate=8000,
42
  feature_dim=80,
43
  decoding_method="modified_beam_search",
44
  # endpoint detection parameters
 
50
  if audio.size == 0:
51
  return "", 0.0
52
 
53
+ resampled = resample_audio(audio, orig_sr, 8000)
54
  rms = float(np.sqrt(np.mean(resampled ** 2)))
55
 
56
+ stream.accept_waveform(8000, resampled)
57
  if recognizer.is_ready(stream):
58
  # print(stream)
59
  recognizer.decode_streams([stream])