-
Notifications
You must be signed in to change notification settings - Fork 231
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
Implement conversion from CutSet to HuggingFace dataset #1398
Implement conversion from CutSet to HuggingFace dataset #1398
Conversation
So far, conversion from CutSet containing MonoCut and single-source audio to HuggingFace dataset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
lhotse/cut/set.py
Outdated
def has_one_audio_source(self) -> bool: | ||
return all(len(cut.recording.sources) == 1 for cut in self) | ||
|
||
def _convert_cuts_info_to_hf(self) -> Tuple[Dict[str, Any], Dict[str, Any]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this file is pretty large and the functionality introduced is fairly well isolated, I suggest to change every method into a function (except the main HF export API) and move them into a separate file lhotse/hf.py
. Keep the HF datasets
imports local like they are. The body of to_huggingface_dataset(self)
should import and call def export_cuts_to_hf(cuts)
from that file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lhotse/cut/set.py
Outdated
Converts cut supervisions into a dictionary compatible with HuggingFace datasets format. | ||
|
||
:param has_speaker: Whether the supervisions have speaker information. | ||
:param has_language: Whether the supervisions have language information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these be auto-deducted?
b4a5756
to
6247d99
Compare
6247d99
to
aa981c7
Compare
lhotse/cut/set.py
Outdated
Converts a CutSet to a HuggingFace Dataset. Currently, only MonoCut with one recording source is supported. | ||
Other cut types will be supported in the future. | ||
|
||
More detailed description is in lhotse/hf.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment: can you copy (duplicate) the documentation from export_to_hf
here? It will be more user friendly for people using interactive suggestions (notebooks, IDEs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. It's done.
Thanks!!! |
…h#1398) * Implement conversion from CutSet to HuggingFace dataset So far, conversion from CutSet containing MonoCut and single-source audio to HuggingFace dataset. * Refactor * Add docs to set.py --------- Co-authored-by: Piotr Żelasko <[email protected]>
This PR implements a simple conversion from a CutSet containing MonoCuts and single-source Recording to a HuggingFace dataset.
CutSet.to_huggingface_dataset: None -> DataSet
converts the cutset into one of two formats, depending on whether all the cuts contain only one supervision or multiple of them. The formats are described in the method's docstring.