Skip to content

Commit

Permalink
Fix duplication issues in CutSet.mix() (#1268)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzelasko committed Jan 23, 2024
1 parent 0089643 commit 69ab31d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lhotse/cut/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -3391,6 +3391,7 @@ def __iter__(self):
# or pass it through unchanged.
if rng.uniform(0.0, 1.0) > self.mix_prob:
yield cut
continue
to_mix = next(mix_in_cuts)
# Determine the SNR - either it's specified or we need to sample one.
cut_snr = (
Expand Down
17 changes: 17 additions & 0 deletions test/cut/test_cut_mixing.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,20 @@ def test_cut_set_mix_is_lazy():
mixed = cuts.mix(cuts, snr=10, mix_prob=1.0, seed=0)

assert mixed.is_lazy


def test_cut_set_mix_size_is_not_growing():
cuts = DummyManifest(CutSet, begin_id=0, end_id=100)
noise_cuts = DummyManifest(CutSet, begin_id=10, end_id=20)

mixed_cuts = cuts.mix(
cuts=noise_cuts,
duration=None,
snr=10,
mix_prob=0.1,
preserve_id=None,
seed=42,
random_mix_offset=True,
).to_eager()

assert len(mixed_cuts) == len(cuts)

0 comments on commit 69ab31d

Please sign in to comment.