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

Function to merge short sentences into a long sentence #1293

Open
yuguochencuc opened this issue Feb 29, 2024 · 3 comments
Open

Function to merge short sentences into a long sentence #1293

yuguochencuc opened this issue Feb 29, 2024 · 3 comments

Comments

@yuguochencuc
Copy link

Hello, I would like to ask if there is a function in lhotse that supports the operation of splicing multiple uniform speakers or id-like sentence in a CutSet into one long sentence? I have extracted jsonl.gz and I want to merge the sentences of some speakers with similar ids into one long sentence.

@pzelasko
Copy link
Collaborator

You can do that by composing some groupby's and append, e.g.

from lhotse.cut.set import CutSet, append_cuts

cuts = CutSet.from_file(...)
speakers = cuts.speakers

long_cuts_per_speaker = {s: append_cuts(cuts.filter(lambda c: c.supervisions[0].speaker == s)) for s in speakers}  # there are more efficient ways of doing this

Of course you can also add silence in between with cut.pad(cut.duration + pause_duration).append(another_cut), mix noises in with .mix(noise_cut), etc.

@yuguochencuc
Copy link
Author

yuguochencuc commented Feb 29, 2024 via email

@pzelasko
Copy link
Collaborator

Yes, you can also search for CutConcatenate transform that now has support for max_duration argument.

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