Update CORAA-NURC-SP-Audio-Corpus.py
Browse files- CORAA-NURC-SP-Audio-Corpus.py +27 -23
CORAA-NURC-SP-Audio-Corpus.py
CHANGED
|
@@ -27,9 +27,20 @@ _PATH_TO_CLIPS = {
|
|
| 27 |
}
|
| 28 |
|
| 29 |
|
| 30 |
-
class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
def _info(self):
|
| 32 |
-
return
|
| 33 |
features=datasets.Features(
|
| 34 |
{
|
| 35 |
"audio_name": datasets.Value("string"),
|
|
@@ -52,40 +63,34 @@ class NurcSPDataset(datasets.GeneratorBasedBuilder):
|
|
| 52 |
)
|
| 53 |
)
|
| 54 |
|
| 55 |
-
def _split_generators(self, dl_manager
|
| 56 |
-
prompts_urls = _PROMPTS_URLS # Default to original prompts URLs
|
| 57 |
-
|
| 58 |
-
if config
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
prompts_urls = _PROMPTS_URLS
|
| 62 |
-
elif prompts_type == 'filtered':
|
| 63 |
-
prompts_urls = _PROMPTS_FILTERED_URLS
|
| 64 |
-
else:
|
| 65 |
-
raise ValueError(f"Invalid prompts type '{prompts_type}'. Please choose 'original' or 'filtered'.")
|
| 66 |
-
|
| 67 |
prompts_path = dl_manager.download(prompts_urls)
|
| 68 |
archive = dl_manager.download(_ARCHIVES)
|
| 69 |
-
|
| 70 |
return [
|
| 71 |
-
|
| 72 |
-
name=
|
| 73 |
gen_kwargs={
|
| 74 |
"prompts_path": prompts_path["dev"],
|
| 75 |
"path_to_clips": _PATH_TO_CLIPS["dev"],
|
| 76 |
"audio_files": dl_manager.iter_archive(archive["dev"]),
|
| 77 |
}
|
| 78 |
),
|
| 79 |
-
|
| 80 |
-
name=
|
| 81 |
gen_kwargs={
|
| 82 |
"prompts_path": prompts_path["test"],
|
| 83 |
"path_to_clips": _PATH_TO_CLIPS["test"],
|
| 84 |
"audio_files": dl_manager.iter_archive(archive["test"]),
|
| 85 |
}
|
| 86 |
),
|
| 87 |
-
|
| 88 |
-
name=
|
| 89 |
gen_kwargs={
|
| 90 |
"prompts_path": prompts_path["train"],
|
| 91 |
"path_to_clips": _PATH_TO_CLIPS["train"],
|
|
@@ -94,7 +99,6 @@ class NurcSPDataset(datasets.GeneratorBasedBuilder):
|
|
| 94 |
),
|
| 95 |
]
|
| 96 |
|
| 97 |
-
|
| 98 |
def _generate_examples(self, prompts_path, path_to_clips, audio_files):
|
| 99 |
examples = {}
|
| 100 |
with open(prompts_path, "r") as f:
|
|
@@ -142,4 +146,4 @@ class NurcSPDataset(datasets.GeneratorBasedBuilder):
|
|
| 142 |
yield id_, {**examples[path], "audio": audio}
|
| 143 |
id_ += 1
|
| 144 |
elif inside_clips_dir:
|
| 145 |
-
break
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
|
| 30 |
+
class NurcSPConfig(BuilderConfig):
|
| 31 |
+
def __init__(self, prompts_type="original", **kwargs):
|
| 32 |
+
super().__init__(**kwargs)
|
| 33 |
+
self.prompts_type = prompts_type
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class NurcSPDataset(GeneratorBasedBuilder):
|
| 37 |
+
BUILDER_CONFIGS = [
|
| 38 |
+
NurcSPConfig(name="original", description="Original audio prompts", prompts_type="original"),
|
| 39 |
+
NurcSPConfig(name="filtered", description="Filtered audio prompts", prompts_type="filtered"),
|
| 40 |
+
]
|
| 41 |
+
|
| 42 |
def _info(self):
|
| 43 |
+
return DatasetInfo(
|
| 44 |
features=datasets.Features(
|
| 45 |
{
|
| 46 |
"audio_name": datasets.Value("string"),
|
|
|
|
| 63 |
)
|
| 64 |
)
|
| 65 |
|
| 66 |
+
def _split_generators(self, dl_manager):
|
| 67 |
+
prompts_urls = _PROMPTS_URLS # Default to original prompts URLs
|
| 68 |
+
|
| 69 |
+
if self.config.prompts_type == "filtered":
|
| 70 |
+
prompts_urls = _PROMPTS_FILTERED_URLS
|
| 71 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
prompts_path = dl_manager.download(prompts_urls)
|
| 73 |
archive = dl_manager.download(_ARCHIVES)
|
| 74 |
+
|
| 75 |
return [
|
| 76 |
+
SplitGenerator(
|
| 77 |
+
name=Split.VALIDATION,
|
| 78 |
gen_kwargs={
|
| 79 |
"prompts_path": prompts_path["dev"],
|
| 80 |
"path_to_clips": _PATH_TO_CLIPS["dev"],
|
| 81 |
"audio_files": dl_manager.iter_archive(archive["dev"]),
|
| 82 |
}
|
| 83 |
),
|
| 84 |
+
SplitGenerator(
|
| 85 |
+
name=Split.TEST,
|
| 86 |
gen_kwargs={
|
| 87 |
"prompts_path": prompts_path["test"],
|
| 88 |
"path_to_clips": _PATH_TO_CLIPS["test"],
|
| 89 |
"audio_files": dl_manager.iter_archive(archive["test"]),
|
| 90 |
}
|
| 91 |
),
|
| 92 |
+
SplitGenerator(
|
| 93 |
+
name=Split.TRAIN,
|
| 94 |
gen_kwargs={
|
| 95 |
"prompts_path": prompts_path["train"],
|
| 96 |
"path_to_clips": _PATH_TO_CLIPS["train"],
|
|
|
|
| 99 |
),
|
| 100 |
]
|
| 101 |
|
|
|
|
| 102 |
def _generate_examples(self, prompts_path, path_to_clips, audio_files):
|
| 103 |
examples = {}
|
| 104 |
with open(prompts_path, "r") as f:
|
|
|
|
| 146 |
yield id_, {**examples[path], "audio": audio}
|
| 147 |
id_ += 1
|
| 148 |
elif inside_clips_dir:
|
| 149 |
+
break
|