From 7d2b8a3cade08ddf2cb20a689b66ee26407d8c5e Mon Sep 17 00:00:00 2001 From: LauraGPT <18321252+LauraGPT@users.noreply.github.com> Date: Sun, 19 Jul 2026 05:48:41 +0000 Subject: [PATCH] fix(stt): anchor qwen asr envelope stripping --- tests/tools/test_transcription_tools.py | 9 +++++++++ tools/transcription_tools.py | 11 ++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py index 9cfe47a50c83..63b9ad696405 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 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 when discussing markup.", + ) + + assert result == "Language teachers may say when discussing markup." + # Shell safety — shlex.split on auto-detected templates # ============================================================================ diff --git a/tools/transcription_tools.py b/tools/transcription_tools.py index 725020ed3699..f359d454a66d 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 = "" - 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*[^<]*)?\s*\s*(?P.*)", + text, + flags=re.IGNORECASE | re.DOTALL, + ) + if match: + text = match.group("text").strip() return text