Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing alignments #914

Merged
merged 4 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lhotse/supervision.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,12 @@ def with_alignment_from_ctm(
num_overspanned += len(alignment)
segments.append(fastcopy(seg, alignment={type: alignment}))
else:
segments.append([s for s in self.find(recording_id=reco_id)])
segments.extend(
[
fastcopy(s, alignment={type: []})
for s in self.find(recording_id=reco_id)
]
)
logging.info(
f"{num_overspanned} alignments added out of {num_total} total. If there are several"
" missing, there could be a mismatch problem."
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/supervision.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@
"recording_id": "recording-1",
"start": 0.5,
"duration": 0.4
},
{
"id": "segment-3",
"recording_id": "recording-2",
"start": 0.1,
"duration": 0.2
},
{
"id": "segment-4",
"recording_id": "recording-2",
"start": 0.3,
"duration": 0.2
}
]
4 changes: 4 additions & 0 deletions test/test_supervision_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def test_supervision_set_with_alignment_from_ctm(
):
segment = external_supervision_set["segment-1"]
assert external_alignment == segment.alignment
assert external_supervision_set["segment-2"].alignment == {"word": []}
assert external_supervision_set["segment-3"].alignment == {"word": []}
for seg in external_supervision_set:
assert type(seg) == SupervisionSegment


def test_supervision_set_write_alignment_to_ctm(external_supervision_set, tmp_path):
Expand Down