feat: add post-diarization speaker mapping workflow
This commit is contained in:
@@ -142,6 +142,65 @@ class MvpApiTests(unittest.TestCase):
|
||||
],
|
||||
)
|
||||
self.assertTrue(all(event.progress is None for event in events))
|
||||
self.assertEqual(protocol_generator.call_args.kwargs["num_ctx"], 32_768)
|
||||
self.assertEqual(
|
||||
protocol_generator.call_args.kwargs["safe_input_token_budget"],
|
||||
29_000,
|
||||
)
|
||||
|
||||
def test_protocol_only_regeneration_reuses_diarized_artifacts(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
run_dir = root / "existing-run"
|
||||
diarization_dir = run_dir / "diarization"
|
||||
diarization_dir.mkdir(parents=True)
|
||||
source = diarization_dir / "transcript_diarized.json"
|
||||
source.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"text": "SPEAKER_00: Existing statement.\n",
|
||||
"segments": [
|
||||
{
|
||||
"start": 0.0,
|
||||
"end": 1.0,
|
||||
"speaker_id": "SPEAKER_00",
|
||||
"text": "Existing statement.",
|
||||
}
|
||||
],
|
||||
"speaker_labels_anonymous": True,
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
source_before = source.read_bytes()
|
||||
mapped_context = context_data()
|
||||
mapped_context["speaker_mappings"] = {"SPEAKER_00": "person-1"}
|
||||
with (
|
||||
patch.object(mvp_api, "prepare_audio") as preparation,
|
||||
patch.object(mvp_api, "transcribe_audio") as transcription,
|
||||
patch.object(mvp_api, "diarize_audio") as diarization,
|
||||
patch.object(
|
||||
mvp_api, "generate_direct_protocol", side_effect=fake_protocol
|
||||
) as protocol,
|
||||
):
|
||||
result = mvp_api.regenerate_mvp_protocol(
|
||||
run_dir,
|
||||
meeting_context=mapped_context,
|
||||
model="qwen3.8:27b",
|
||||
protocol_num_ctx=32_768,
|
||||
protocol_safe_input_token_budget=29_000,
|
||||
)
|
||||
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
self.assertEqual(result.protocol_path, run_dir / "protocol.md")
|
||||
preparation.assert_not_called()
|
||||
transcription.assert_not_called()
|
||||
diarization.assert_not_called()
|
||||
self.assertEqual(protocol.call_args.args[0], source)
|
||||
self.assertEqual(protocol.call_args.kwargs["num_ctx"], 32_768)
|
||||
self.assertEqual(source.read_bytes(), source_before)
|
||||
persisted = load_meeting_context(run_dir / "context/meeting_context.yaml")
|
||||
self.assertEqual(persisted.speaker_mappings, {"SPEAKER_00": "person-1"})
|
||||
|
||||
def test_failure_emits_terminal_failure_event(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
|
||||
Reference in New Issue
Block a user