Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AudioFolder packaged loader (#4530)
* add audiofolder loader (almost identical to imagefolder except for inferring labels is not default) * add instruction on how to obtain list of audio extensions * add a generic loader * patch autofolder for streaming manually * align autofolder with the latest imagefolder implementation * update tests * add test for duplicate label col * add tests for autofolder (+copied from imagefolder) * add missed audio_file fixture * add documentation * remove boilerplate, make base feature builder's class arg instead of a config's one * remove self.config.label_name, use hardcoded 'label' * patch parents that inherit from DatasetBuilder, revert get_imports * rename autofolder -> folder_builder * make base column name an abstract attr of FolderBuilder instead of config's parameter * Update src/datasets/streaming.py Co-authored-by: Mario 艩a拧ko <mario@huggingface.co> * rename FolderBuilder -> FolderBasedBuilder * set drop_labels to None by default for AudioFolder * update documentation * check if builder extending for streaming is not in datasets.builder module Co-authored-by: Mario 艩a拧ko <mario@huggingface.co> Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
- Loading branch information
1 parent
16f6cd7
commit 6ea46d8
Showing
17 changed files
with
1,479 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
### Contributions | ||
|
||
Thanks to [@polinaeterna](https://github.com/polinaeterna), [@nateraw](https://github.com/nateraw), [@lhoestq](https://github.com/lhoestq) and [@mariosasko](https://github.com/mariosasko) for adding this dataset. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from typing import List | ||
|
||
import datasets | ||
|
||
from ..folder_based_builder import folder_based_builder | ||
|
||
|
||
logger = datasets.utils.logging.get_logger(__name__) | ||
|
||
|
||
class AudioFolderConfig(folder_based_builder.FolderBasedBuilderConfig): | ||
"""Builder Config for AudioFolder.""" | ||
|
||
drop_labels: bool = None | ||
drop_metadata: bool = None | ||
|
||
|
||
class AudioFolder(folder_based_builder.FolderBasedBuilder): | ||
BASE_FEATURE = datasets.Audio() | ||
BASE_COLUMN_NAME = "audio" | ||
BUILDER_CONFIG_CLASS = AudioFolderConfig | ||
EXTENSIONS: List[str] # definition at the bottom of the script | ||
|
||
|
||
# Obtained with: | ||
# ``` | ||
# import soundfile as sf | ||
# | ||
# AUDIO_EXTENSIONS = [f".{format.lower()}" for format in sf.available_formats().keys()] | ||
# | ||
# # .mp3 is currently decoded via `torchaudio`, .opus decoding is supported if version of `libsndfile` >= 1.0.30: | ||
# AUDIO_EXTENSIONS.extend([".mp3", ".opus"]) | ||
# ``` | ||
# We intentionally do not run this code on launch because: | ||
# (1) Soundfile is an optional dependency, so importing it in global namespace is not allowed | ||
# (2) To ensure the list of supported extensions is deterministic | ||
AUDIO_EXTENSIONS = [ | ||
".aiff", | ||
".au", | ||
".avr", | ||
".caf", | ||
".flac", | ||
".htk", | ||
".svx", | ||
".mat4", | ||
".mat5", | ||
".mpc2k", | ||
".ogg", | ||
".paf", | ||
".pvf", | ||
".raw", | ||
".rf64", | ||
".sd2", | ||
".sds", | ||
".ircam", | ||
".voc", | ||
".w64", | ||
".wav", | ||
".nist", | ||
".wavex", | ||
".wve", | ||
".xi", | ||
".mp3", | ||
".opus", | ||
] | ||
AudioFolder.EXTENSIONS = AUDIO_EXTENSIONS |
Empty file.
Oops, something went wrong.
6ea46d8
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.
Show benchmarks
PyArrow==6.0.0
Show updated benchmarks!
Benchmark: benchmark_array_xd.json
Benchmark: benchmark_getitem_100B.json
Benchmark: benchmark_indices_mapping.json
Benchmark: benchmark_iterating.json
Benchmark: benchmark_map_filter.json
Show updated benchmarks!
Benchmark: benchmark_array_xd.json
Benchmark: benchmark_getitem_100B.json
Benchmark: benchmark_indices_mapping.json
Benchmark: benchmark_iterating.json
Benchmark: benchmark_map_filter.json