yangwang825
commited on
Update audiocaps.py
Browse files- audiocaps.py +16 -4
audiocaps.py
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
import os
|
7 |
import gzip
|
8 |
import shutil
|
|
|
9 |
import pathlib
|
10 |
import logging
|
11 |
import datasets
|
@@ -73,18 +74,29 @@ class AudioCaps(datasets.GeneratorBasedBuilder):
|
|
73 |
extensions = ['.wav']
|
74 |
|
75 |
# Development sets
|
76 |
-
|
77 |
-
|
78 |
-
DEV_URL = f'https://huggingface.co/datasets/confit/audiocaps/resolve/main/data/{_filename}'
|
79 |
_dev_save_path = os.path.join(
|
80 |
HF_DATASETS_CACHE, 'confit___audiocaps/audiocaps', VERSION
|
81 |
)
|
82 |
download_file(
|
83 |
source=DEV_URL,
|
84 |
-
dest=os.path.join(_dev_save_path,
|
85 |
unpack=True,
|
86 |
dest_unpack=os.path.join(_dev_save_path, 'extracted', 'train'),
|
87 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
train_archive_path = os.path.join(_dev_save_path, 'extracted', 'train')
|
89 |
_, _walker = fast_scandir(train_archive_path, extensions, recursive=True)
|
90 |
train_audio_paths.extend(_walker)
|
|
|
6 |
import os
|
7 |
import gzip
|
8 |
import shutil
|
9 |
+
import joblib
|
10 |
import pathlib
|
11 |
import logging
|
12 |
import datasets
|
|
|
74 |
extensions = ['.wav']
|
75 |
|
76 |
# Development sets
|
77 |
+
def _download_and_extract(filename):
|
78 |
+
DEV_URL = f'https://huggingface.co/datasets/confit/audiocaps/resolve/main/data/{filename}'
|
|
|
79 |
_dev_save_path = os.path.join(
|
80 |
HF_DATASETS_CACHE, 'confit___audiocaps/audiocaps', VERSION
|
81 |
)
|
82 |
download_file(
|
83 |
source=DEV_URL,
|
84 |
+
dest=os.path.join(_dev_save_path, filename),
|
85 |
unpack=True,
|
86 |
dest_unpack=os.path.join(_dev_save_path, 'extracted', 'train'),
|
87 |
)
|
88 |
+
|
89 |
+
joblib.Parallel(n_jobs=8, verbose=10)(
|
90 |
+
joblib.delayed(_download_and_extract)(
|
91 |
+
filename=_filename
|
92 |
+
) for _filename in tqdm([f'train{i}.zip' for i in range(1, 12+1)])
|
93 |
+
)
|
94 |
+
train_audio_paths = []
|
95 |
+
for _filename in [f'train{i}.zip' for i in range(1, 12+1)]:
|
96 |
+
DEV_URL = f'https://huggingface.co/datasets/confit/audiocaps/resolve/main/data/{_filename}'
|
97 |
+
_dev_save_path = os.path.join(
|
98 |
+
HF_DATASETS_CACHE, 'confit___audiocaps/audiocaps', VERSION
|
99 |
+
)
|
100 |
train_archive_path = os.path.join(_dev_save_path, 'extracted', 'train')
|
101 |
_, _walker = fast_scandir(train_archive_path, extensions, recursive=True)
|
102 |
train_audio_paths.extend(_walker)
|