Skip to content

The agent that grows with you

fix(stt): anchor qwen asr envelope stripping

LauraGPT7d2b8a3cade0
diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py
index 9cfe47a50c8..63b9ad69640 100644
--- a/tests/tools/test_transcription_tools.py
+++ b/tests/tools/test_transcription_tools.py
@@ -1873,6 +1873,15 @@ class TestExtractTranscriptText:
assert result == "The user literally said <asr_text> while reading markup."
+ def test_keeps_language_sentence_with_marker_literal(self):
+ from tools.transcription_tools import _extract_transcript_text
+
+ result = _extract_transcript_text(
+ "Language teachers may say <asr_text> when discussing markup.",
+ )
+
+ assert result == "Language teachers may say <asr_text> when discussing markup."
+
# Shell safety — shlex.split on auto-detected templates
# ============================================================================
diff --git a/tools/transcription_tools.py b/tools/transcription_tools.py
index 725020ed369..f359d454a66 100644
--- a/tools/transcription_tools.py
+++ b/tools/transcription_tools.py
@@ -30,6 +30,7 @@ Usage::
import logging
import os
import platform
+import re
import shlex
import shutil
import subprocess
@@ -2094,8 +2095,12 @@ def _extract_transcript_text(transcription: Any) -> str:
if text is None:
text = str(transcription).strip()
- marker = "<asr_text>"
- if text.lstrip().lower().startswith("language") and marker in text:
- text = text.split(marker, 1)[1].strip()
+ match = re.match(
+ r"\s*language\s+[\w.-]+(?:\s*<audio_language>[^<]*</audio_language>)?\s*<asr_text>\s*(?P<text>.*)",
+ text,
+ flags=re.IGNORECASE | re.DOTALL,
+ )
+ if match:
+ text = match.group("text").strip()
return text