Пример #1
0
def maybe_pad(cuts: CutSet) -> CutSet:
    """Check if all cuts' durations are equal and pad them to match the longest cut otherwise."""
    if len(set(c.duration for c in cuts)) == 1:
        # All cuts are of equal duration: nothing to do
        return cuts
    # Non-equal durations: silence padding
    return cuts.pad()
Пример #2
0
def maybe_pad(cuts: CutSet,
              duration: int = None,
              num_frames: int = None,
              num_samples: int = None) -> CutSet:
    """Check if all cuts' durations are equal and pad them to match the longest cut otherwise."""
    if len(set(c.duration for c in cuts)) == 1:
        # All cuts are of equal duration: nothing to do
        return cuts
    # Non-equal durations: silence padding
    return cuts.pad(duration=duration,
                    num_frames=num_frames,
                    num_samples=num_samples)