Luigi commited on
Commit
6c8af7a
·
1 Parent(s): 202cb59

sanitize hotword list

Browse files
Files changed (1) hide show
  1. app/asr_worker.py +7 -5
app/asr_worker.py CHANGED
@@ -211,11 +211,13 @@ def create_recognizer(
211
  mode="w", delete=False, suffix=".txt", dir=str(CACHE_DIR)
212
  )
213
  for w in hotwords:
214
- tf.write(f"{w}\n")
215
- tf.flush()
216
- tf.close()
217
- hotwords_file_path = tf.name
218
- print(f"[DEBUG asr_worker] Written {len(hotwords)} hotwords to {hotwords_file_path} with score {hotwords_score}")
 
 
219
 
220
  # Create beam-search recognizer with biasing :contentReference[oaicite:0]{index=0}
221
  return sherpa_onnx.OnlineRecognizer.from_transducer(
 
211
  mode="w", delete=False, suffix=".txt", dir=str(CACHE_DIR)
212
  )
213
  for w in hotwords:
214
+ # Remove backslashes and angle-bracket tokens
215
+ clean = w.replace("\\", "").replace("<unk>", "").strip()
216
+ if clean: # only write non-empty lines
217
+ tf.write(f"{clean}\n")
218
+ tf.flush()
219
+ tf.close()
220
+ print(f"[DEBUG asr_worker] Written {len(hotwords)} hotwords to {hotwords_file_path} with score {hotwords_score}")
221
 
222
  # Create beam-search recognizer with biasing :contentReference[oaicite:0]{index=0}
223
  return sherpa_onnx.OnlineRecognizer.from_transducer(