diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py index c0186513a0e..9cfe47a50c8 100644 --- a/tests/tools/test_transcription_tools.py +++ b/tests/tools/test_transcription_tools.py @@ -1850,6 +1850,30 @@ class TestTranscribeAudioElevenLabsDispatch: assert mock_elevenlabs.call_args[0][1] == "scribe_v2" +# ============================================================================ +# _extract_transcript_text +# ============================================================================ + +class TestExtractTranscriptText: + def test_strips_qwen3_asr_language_envelope(self): + from tools.transcription_tools import _extract_transcript_text + + result = _extract_transcript_text( + "language zh\nzh\n你好,世界", + ) + + assert result == "你好,世界" + + def test_keeps_non_envelope_marker_literal(self): + from tools.transcription_tools import _extract_transcript_text + + result = _extract_transcript_text( + "The user literally said while reading markup.", + ) + + assert result == "The user literally said while reading markup." + + # Shell safety — shlex.split on auto-detected templates # ============================================================================ class TestShellSafety: diff --git a/tools/transcription_tools.py b/tools/transcription_tools.py index 0b14e34bbcf..725020ed369 100644 --- a/tools/transcription_tools.py +++ b/tools/transcription_tools.py @@ -2095,7 +2095,7 @@ def _extract_transcript_text(transcription: Any) -> str: text = str(transcription).strip() marker = "" - if marker in text: + if text.lstrip().lower().startswith("language") and marker in text: text = text.split(marker, 1)[1].strip() return text