Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingleafe committed Oct 11, 2023
1 parent c22ad3b commit a1e6cc0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/cut/test_cut_truncate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random
from math import isclose

import numpy as np
import pytest

from lhotse import RecordingSet
Expand Down Expand Up @@ -146,7 +147,7 @@ def gapped_mixed_cut():
id="gapped-mixed-cut",
tracks=[
MixTrack(cut=dummy_cut(0, duration=10.0)),
MixTrack(cut=dummy_cut(1, duration=10.0), offset=15.0),
MixTrack(cut=dummy_cut(1, duration=10.0).pad(12.0).pad(15.0), offset=15.0),
],
)

Expand Down Expand Up @@ -226,12 +227,16 @@ def test_truncate_mixed_cut_with_small_offset_and_duration(simple_mixed_cut):
assert truncated_cut.duration == 13.0


def test_truncate_mixed_cut_inside_gap(gapped_mixed_cut):
truncated_cut = gapped_mixed_cut.truncate(offset=11.0, duration=3.0)
@pytest.mark.parametrize("offset", [11.0, 26.0])
def test_truncate_mixed_cut_gap_or_padding(gapped_mixed_cut, offset):
print(gapped_mixed_cut.duration)
truncated_cut = gapped_mixed_cut.truncate(offset=offset, duration=3.0)
assert isinstance(truncated_cut, PaddingCut)
assert truncated_cut.start == 0.0
assert truncated_cut.duration == 3.0
assert truncated_cut.end == 3.0
audio = truncated_cut.load_audio()
assert audio is not None


def test_truncate_cut_set_offset_start(cut_set):
Expand Down

0 comments on commit a1e6cc0

Please sign in to comment.