mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
fix(stt): anchor Qwen3-ASR envelope stripping
This commit is contained in:
parent
517b8debbd
commit
d219392e5b
2 changed files with 25 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue