Improve speaker-review excerpts
This commit is contained in:
@@ -247,6 +247,18 @@ def write_speaker_review_artifacts(run_dir: Path) -> Path:
|
||||
return transcript_path
|
||||
|
||||
|
||||
def write_custom_speaker_review_artifacts(
|
||||
run_dir: Path, segments: list[dict[str, str | None]]
|
||||
) -> Path:
|
||||
"""Write custom diarized segments using the standard review context fixture."""
|
||||
transcript_path = write_speaker_review_artifacts(run_dir)
|
||||
transcript_path.write_text(
|
||||
json.dumps({"speaker_labels_anonymous": True, "segments": segments}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
return transcript_path
|
||||
|
||||
|
||||
def test_build_context_uses_actual_v1_shape(tmp_path: Path) -> None:
|
||||
service, gateway = make_service(tmp_path)
|
||||
|
||||
@@ -534,6 +546,89 @@ def test_speaker_review_lists_detected_labels_participants_and_excerpts(
|
||||
assert "SPEAKER_00" in source.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_speaker_review_prefers_content_rich_excerpts_over_acknowledgements_and_questions(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
service, gateway = make_service(tmp_path)
|
||||
acknowledgement = "Okay, that sounds good."
|
||||
question = "Could we continue now?"
|
||||
rich_excerpts = [
|
||||
"I will complete the Atlas deployment in Berlin on 14 September with the database team.",
|
||||
"I recommend moving the Orion product launch because the supplier test is incomplete.",
|
||||
"We decided that I will own the Kubernetes migration for the payments service.",
|
||||
"My experience with the Frankfurt factory rollout suggests a two-week validation period.",
|
||||
"I will present the security audit results to the Apollo project steering group.",
|
||||
"We should reserve twelve hours for the API integration and production monitoring.",
|
||||
]
|
||||
write_custom_speaker_review_artifacts(
|
||||
gateway.run_dir,
|
||||
[{"speaker_id": "SPEAKER_00", "text": text} for text in [acknowledgement, question, *rich_excerpts]],
|
||||
)
|
||||
|
||||
review = service.load_speaker_mapping_review(gateway.run_dir)
|
||||
|
||||
assert review is not None
|
||||
excerpts = review.speakers[0].excerpts
|
||||
assert len(excerpts) == 6
|
||||
assert acknowledgement not in excerpts
|
||||
assert question not in excerpts
|
||||
assert set(excerpts) == set(rich_excerpts)
|
||||
|
||||
|
||||
def test_speaker_review_avoids_near_duplicate_excerpts(tmp_path: Path) -> None:
|
||||
service, gateway = make_service(tmp_path)
|
||||
primary = "I will lead the Atlas API migration for the Berlin platform team next Monday."
|
||||
duplicate = "I will lead the Atlas API migration for the Berlin platform group next Monday."
|
||||
alternatives = [
|
||||
"I recommend documenting the supplier quality decision in the project register.",
|
||||
"My team will complete the production calibration before the factory trial.",
|
||||
"I will present the customer research findings at the Munich planning workshop.",
|
||||
"Our database monitoring threshold needs approval from the operations group.",
|
||||
"I will coordinate the Orion release checklist with the support organization.",
|
||||
]
|
||||
write_custom_speaker_review_artifacts(
|
||||
gateway.run_dir,
|
||||
[{"speaker_id": "SPEAKER_00", "text": text} for text in [primary, duplicate, *alternatives]],
|
||||
)
|
||||
|
||||
review = service.load_speaker_mapping_review(gateway.run_dir)
|
||||
|
||||
assert review is not None
|
||||
excerpts = review.speakers[0].excerpts
|
||||
assert primary in excerpts
|
||||
assert duplicate not in excerpts
|
||||
assert set(excerpts) == {primary, *alternatives}
|
||||
|
||||
|
||||
def test_speaker_review_spreads_selected_excerpts_across_meeting_positions(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
service, gateway = make_service(tmp_path)
|
||||
positions = {
|
||||
0: "I will lead the Atlas deployment review with the engineering team marker alpha.",
|
||||
1: "I will lead the Atlas deployment review with the engineering team marker bravo.",
|
||||
6: "I will lead the Atlas deployment review with the engineering team marker charlie.",
|
||||
7: "I will lead the Atlas deployment review with the engineering team marker delta.",
|
||||
12: "I will lead the Atlas deployment review with the engineering team marker echo.",
|
||||
13: "I will lead the Atlas deployment review with the engineering team marker foxtrot.",
|
||||
18: "I will lead the Atlas deployment review with the engineering team marker golf.",
|
||||
19: "I will lead the Atlas deployment review with the engineering team marker hotel.",
|
||||
}
|
||||
segments = [
|
||||
{
|
||||
"speaker_id": "SPEAKER_00" if index in positions else "SPEAKER_01",
|
||||
"text": positions.get(index, "Acknowledged."),
|
||||
}
|
||||
for index in range(20)
|
||||
]
|
||||
write_custom_speaker_review_artifacts(gateway.run_dir, segments)
|
||||
|
||||
review = service.load_speaker_mapping_review(gateway.run_dir)
|
||||
|
||||
assert review is not None
|
||||
assert review.speakers[0].excerpts == tuple(positions[index] for index in (0, 1, 6, 7, 12, 18))
|
||||
|
||||
|
||||
def test_protocol_only_regeneration_persists_mappings_without_rewriting_transcript(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user