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

[Bug] The total number of supervisions decreased after trimming to supervision groups. #1416

Open
MartinKocour opened this issue Nov 11, 2024 · 2 comments

Comments

@MartinKocour
Copy link
Contributor

MartinKocour commented Nov 11, 2024

Hi, I am trying to trim the cuts to supervision groups by calling:

cuts = cuts.trim_to_supervision_groups(max_pause=2, num_jobs=num_jobs)

While I am getting this error:

AssertionError: The total number of supervisions decreased after trimming to supervision groups.
1104 != 1105
This is likely a bug. Please report it here: https://github.com/lhotse-speech/lhotse/issues/new, and provide the following information:
original cut: MonoCut(...)

(full error message at the end of this issue)

I suspect that the real reason behind this error is wrong conversion from seconds -> num_samples due to float precision on these lines:

Cut.truncate(offset, duration):
    new_start = max(
        add_durations(self.start, offset, sampling_rate=self.sampling_rate), 0
    )
    until = add_durations(
        offset,
        duration if duration is not None else self.duration,
        sampling_rate=self.sampling_rate,
    )
    new_duration = add_durations(until, -offset, sampling_rate=self.sampling_rate)

Which affects the selection of supervisions on these lines:

  if _supervisions_index is None:
      criterion = overlaps if keep_excessive_supervisions else overspans
      new_time_span = TimeSpan(start=0, end=new_duration)
      new_supervisions = (
          segment.with_offset(-offset) for segment in self.supervisions
      )
      supervisions = [
          segment
          for segment in new_supervisions
          if criterion(new_time_span, segment)
      ]

Full error message:

error.log

@pzelasko
Copy link
Collaborator

Makes sense... could you make a PR with the fix? Also, can you run lhotse.validate() on the input cut and see if it finds anything wrong with it?

@MartinKocour
Copy link
Contributor Author

Hi Piotr, I've just checked lhotse.validate returns None, which I assume is OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants