fix(stt): anchor Qwen3-ASR envelope stripping

This commit is contained in:
LauraGPT 2026-07-18 21:33:07 +00:00 committed by Teknium
parent 517b8debbd
commit d219392e5b
2 changed files with 25 additions and 1 deletions

View file

@ -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\n<audio_language>zh</audio_language>\n<asr_text>你好,世界",
)
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 <asr_text> while reading markup.",
)
assert result == "The user literally said <asr_text> while reading markup."
# Shell safety — shlex.split on auto-detected templates
# ============================================================================
class TestShellSafety:

View file

@ -2095,7 +2095,7 @@ def _extract_transcript_text(transcription: Any) -> str:
text = str(transcription).strip()
marker = "<asr_text>"
if marker in text:
if text.lstrip().lower().startswith("language") and marker in text:
text = text.split(marker, 1)[1].strip()
return text