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

Add trim_to_alignments() method #926

Merged
merged 13 commits into from
Dec 15, 2022
Merged

Conversation

desh2608
Copy link
Collaborator

Based on discussion in #923

@lubacien
Copy link
Contributor

All tests are passing on my side (although I have to use torch.set_num_threads(1) to pass the test test_compute_and_store_features_lazy(nj) with nj=2, this is not related).
I also tested it from command line on my data and it works as expected.

merged_alignments = [(alignments[0], [0])]
for i, item in enumerate(alignments[1:]):
prev_item, prev_indices = merged_alignments[-1]
if item.start - prev_item.end <= max_pause:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A catch here is that if there are alignment items which are continuous (i.e. prev_end == cur_start) then they will necessarily get merged. So in order to trim such that we get #cuts = num. of alignment items, a negative value of max_pause will need to be passed.

@desh2608
Copy link
Collaborator Author

All tests are passing on my side (although I have to use torch.set_num_threads(1) to pass the test test_compute_and_store_features_lazy(nj) with nj=2, this is not related). I also tested it from command line on my data and it works as expected.

Thanks for testing this. I will verify it on my end and then ask @pzelasko to merge if he doesn't see any immediate issues.

@desh2608
Copy link
Collaborator Author

I think I have convinced myself that this works as expected.

@pzelasko could you please check when you have some time?

@desh2608 desh2608 linked an issue Dec 14, 2022 that may be closed by this pull request
lhotse/cut/base.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@pzelasko pzelasko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good to me, just left one comment.

@pzelasko pzelasko added this to the v1.12 milestone Dec 14, 2022
@desh2608
Copy link
Collaborator Author

Thanks! Looks good to me, just left one comment.

Done.

@pzelasko pzelasko merged commit e83afd3 into lhotse-speech:master Dec 15, 2022
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

Successfully merging this pull request may close these issues.

Using forced alignment for segmentation
3 participants