import json from audita.chunking import chunk_transcript from audita.prompts import build_glossary_correction_messages from audita.schemas import parse_glossary_yaml, parse_transcript_json def test_prompt_requires_acoustically_plausible_transcription_errors(): transcript = parse_transcript_json( """ [ {"speaker": "Eric", "start": 0.0, "end": 1.0, "text": "The gestures are nearby."} ] """ ) glossary = parse_glossary_yaml( """ glossary: - name: "Jesters" category: faction summary: "The Jesters are a local faction." - name: "Lyra" category: npc summary: "Lyra is a hostile NPC." """ ) section = chunk_transcript(transcript, max_section_tokens=16000)[0] messages = build_glossary_correction_messages(section, glossary) prompt_text = "\n".join(message["content"] for message in messages) assert "acoustically plausible" in prompt_text assert "phonetically or acoustically similar" in prompt_text assert '"gestures" to "Jesters"' in prompt_text assert '"Lyra" to "Jesters"' in prompt_text assert "should be omitted" in prompt_text assert "exact text span that needs replacement" in prompt_text assert "replacement text for that span" in prompt_text assert "Do not return corrections where original_text and corrected_text are identical" in prompt_text def test_prompt_uses_simplified_segment_payload(): transcript = parse_transcript_json( """ [ {"speaker": "Eric", "start": 0.0, "end": 1.0, "text": "The gestures are nearby."} ] """ ) glossary = parse_glossary_yaml( """ glossary: - name: "Jesters" category: faction summary: "The Jesters are a local faction." """ ) section = chunk_transcript(transcript, max_section_tokens=16000)[0] messages = build_glossary_correction_messages(section, glossary) transcript_json = messages[1]["content"].split("Transcript section:\n", maxsplit=1)[1] prompt_segments = json.loads(transcript_json) assert prompt_segments == [{"segment_id": 0, "original_text": "The gestures are nearby."}] assert "speaker" not in prompt_segments[0] assert "start" not in prompt_segments[0] assert "end" not in prompt_segments[0]