mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-29 18:46:59 +00:00
fix(stt): anchor qwen asr envelope stripping
This commit is contained in:
parent
d219392e5b
commit
7d2b8a3cad
2 changed files with 17 additions and 3 deletions
|
|
@ -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
|
||||
# ============================================================================
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue