Spaces:
Running
Running
sanitize hotword list
Browse files- 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 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
|
|
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(
|