Commit
·
0e959bb
1
Parent(s):
a81bb4d
exclude broken files
Browse files
evi.py
CHANGED
@@ -67,6 +67,10 @@ _RECORDS_URL = {
|
|
67 |
lang: os.path.join(_BASE_URL, f"records.{lang.split('-')[0]}.csv") for lang in _LANGS
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
70 |
_AUDIO_DATA_URL = "https://poly-public-data.s3.eu-west-2.amazonaws.com/evi-paper/audios.zip" # noqa
|
71 |
|
72 |
_VERSION = datasets.Version("0.0.1", "")
|
@@ -126,10 +130,13 @@ class Evi(datasets.GeneratorBasedBuilder):
|
|
126 |
lang2text_urls = {
|
127 |
lang: _TEXTS_URL[lang] for lang in langs
|
128 |
}
|
|
|
129 |
records_paths = dl_manager.download_and_extract(lang2records_urls)
|
130 |
text_paths = dl_manager.download_and_extract(lang2text_urls)
|
131 |
audio_data_path = dl_manager.download_and_extract(_AUDIO_DATA_URL)
|
132 |
|
|
|
|
|
133 |
return [
|
134 |
datasets.SplitGenerator(
|
135 |
name=datasets.Split.TEST,
|
@@ -137,11 +144,18 @@ class Evi(datasets.GeneratorBasedBuilder):
|
|
137 |
"audio_data_path": audio_data_path,
|
138 |
"text_paths": text_paths,
|
139 |
"records_paths": records_paths,
|
|
|
140 |
},
|
141 |
)
|
142 |
]
|
143 |
|
144 |
-
def _generate_examples(self, audio_data_path, text_paths, records_paths):
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
for lang, text_path in text_paths.items():
|
146 |
|
147 |
records_path = records_paths[lang]
|
@@ -169,8 +183,11 @@ class Evi(datasets.GeneratorBasedBuilder):
|
|
169 |
f'{turn_id}.wav'
|
170 |
)
|
171 |
full_path = os.path.join(audio_data_path, file_path)
|
|
|
|
|
|
|
172 |
if not os.path.isfile(full_path):
|
173 |
-
warnings.warn(f"{full_path} not found.")
|
174 |
continue
|
175 |
|
176 |
target_profile_id = dictrow["scenario_id"]
|
|
|
67 |
lang: os.path.join(_BASE_URL, f"records.{lang.split('-')[0]}.csv") for lang in _LANGS
|
68 |
}
|
69 |
|
70 |
+
_BROKEN_URL = {
|
71 |
+
"en": os.path.join(_BASE_URL, "broken_en.txt")
|
72 |
+
}
|
73 |
+
|
74 |
_AUDIO_DATA_URL = "https://poly-public-data.s3.eu-west-2.amazonaws.com/evi-paper/audios.zip" # noqa
|
75 |
|
76 |
_VERSION = datasets.Version("0.0.1", "")
|
|
|
130 |
lang2text_urls = {
|
131 |
lang: _TEXTS_URL[lang] for lang in langs
|
132 |
}
|
133 |
+
|
134 |
records_paths = dl_manager.download_and_extract(lang2records_urls)
|
135 |
text_paths = dl_manager.download_and_extract(lang2text_urls)
|
136 |
audio_data_path = dl_manager.download_and_extract(_AUDIO_DATA_URL)
|
137 |
|
138 |
+
broken_path = dl_manager.download_and_extract(_BROKEN_URL["en"]) if "en" in langs else None
|
139 |
+
|
140 |
return [
|
141 |
datasets.SplitGenerator(
|
142 |
name=datasets.Split.TEST,
|
|
|
144 |
"audio_data_path": audio_data_path,
|
145 |
"text_paths": text_paths,
|
146 |
"records_paths": records_paths,
|
147 |
+
"broken_path": broken_path
|
148 |
},
|
149 |
)
|
150 |
]
|
151 |
|
152 |
+
def _generate_examples(self, audio_data_path, text_paths, records_paths, broken_path=None):
|
153 |
+
if broken_path:
|
154 |
+
with open(broken_path, encoding="utf-8") as f:
|
155 |
+
broken_samples = set([line.strip() for line in f])
|
156 |
+
else:
|
157 |
+
broken_samples = None
|
158 |
+
|
159 |
for lang, text_path in text_paths.items():
|
160 |
|
161 |
records_path = records_paths[lang]
|
|
|
183 |
f'{turn_id}.wav'
|
184 |
)
|
185 |
full_path = os.path.join(audio_data_path, file_path)
|
186 |
+
if broken_samples and file_path in broken_samples:
|
187 |
+
warnings.warn(f"{full_path} is broken, skipping it.")
|
188 |
+
continue
|
189 |
if not os.path.isfile(full_path):
|
190 |
+
warnings.warn(f"{full_path} not found, skipping it.")
|
191 |
continue
|
192 |
|
193 |
target_profile_id = dictrow["scenario_id"]
|