|
7 | 7 |
|
8 | 8 | from lhotse.array import Array, TemporalArray |
9 | 9 | from lhotse.audio import Recording, RecordingSet |
10 | | -from lhotse.cut import Cut, CutSet, MixedCut, PaddingCut |
| 10 | +from lhotse.cut import Cut, CutSet, MixedCut, MonoCut, PaddingCut |
11 | 11 | from lhotse.features import FeatureSet, Features |
12 | 12 | from lhotse.supervision import SupervisionSegment, SupervisionSet |
13 | 13 | from lhotse.utils import compute_num_frames, overlaps |
@@ -379,17 +379,20 @@ def validate_cut(c: Cut, read_data: bool = False) -> None: |
379 | 379 | c.num_samples == samples.shape[1] |
380 | 380 | ), f"MonoCut {c.id}: expected {c.num_samples} samples, got {samples.shape[1]}" |
381 | 381 |
|
382 | | - # Conditions related to supervisions |
383 | | - for s in c.supervisions: |
384 | | - validate_supervision(s) |
385 | | - assert s.recording_id == c.recording_id, ( |
386 | | - f"MonoCut {c.id}: supervision {s.id} has a mismatched recording_id " |
387 | | - f"(expected {c.recording_id}, supervision has {s.recording_id})" |
388 | | - ) |
389 | | - assert s.channel == c.channel, ( |
390 | | - f"MonoCut {c.id}: supervision {s.id} has a mismatched channel " |
391 | | - f"(expected {c.channel}, supervision has {s.channel})" |
392 | | - ) |
| 382 | + # Conditions related to supervisions. |
| 383 | + # We only validate those for MonoCut; PaddingCut doesn't have supervisions, |
| 384 | + # and MixedCut may consist of more than one recording/channel. |
| 385 | + if isinstance(c, MonoCut): |
| 386 | + for s in c.supervisions: |
| 387 | + validate_supervision(s) |
| 388 | + assert s.recording_id == c.recording_id, ( |
| 389 | + f"MonoCut {c.id}: supervision {s.id} has a mismatched recording_id " |
| 390 | + f"(expected {c.recording_id}, supervision has {s.recording_id})" |
| 391 | + ) |
| 392 | + assert s.channel == c.channel, ( |
| 393 | + f"MonoCut {c.id}: supervision {s.id} has a mismatched channel " |
| 394 | + f"(expected {c.channel}, supervision has {s.channel})" |
| 395 | + ) |
393 | 396 |
|
394 | 397 | # Conditions related to custom fields |
395 | 398 | if c.custom is not None: |
|
0 commit comments