Datasets:
Size:
10K - 100K
License:
feat(loader): added script for loading dataset, added setup.py
Browse files- baneks_speech.py +91 -0
- setup.py +9 -0
baneks_speech.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from glob import glob
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
+
import datasets
|
6 |
+
from datasets import Features, Value, Audio
|
7 |
+
|
8 |
+
from music_tag import load_file
|
9 |
+
|
10 |
+
|
11 |
+
_DESCRIPTION = """
|
12 |
+
This dataset contains speech generated for anecdotes from the [baneks dataset](https://huggingface.co/datasets/zeio/baneks)
|
13 |
+
"""
|
14 |
+
|
15 |
+
_HOMEPAGE = "https://huggingface.co/datasets/zeio/baneks-speech"
|
16 |
+
|
17 |
+
_LICENSE = "Apache License Version 2.0"
|
18 |
+
|
19 |
+
_URL = "https://huggingface.co/datasets/zeio/baneks-speech/resolve/main/speech/{first:06d}-{last:06d}.tar.xz"
|
20 |
+
|
21 |
+
|
22 |
+
_N_TOTAL = 46_554
|
23 |
+
_N_BATCH = 1_000
|
24 |
+
|
25 |
+
|
26 |
+
class BaneksSpeech(datasets.GeneratorBasedBuilder):
|
27 |
+
"""Speech generated for anecdotes from the baneks dataset"""
|
28 |
+
|
29 |
+
VERSION = datasets.Version("10.10.2023")
|
30 |
+
|
31 |
+
def _info(self):
|
32 |
+
return datasets.DatasetInfo(
|
33 |
+
description = _DESCRIPTION,
|
34 |
+
features = Features(
|
35 |
+
{
|
36 |
+
"text": Value("string"),
|
37 |
+
"audio": Audio(sampling_rate = 22_050),
|
38 |
+
"artist": Value("string"),
|
39 |
+
"id": Value("int32"),
|
40 |
+
"source": Value("string")
|
41 |
+
}
|
42 |
+
),
|
43 |
+
homepage = _HOMEPAGE,
|
44 |
+
license = _LICENSE
|
45 |
+
)
|
46 |
+
|
47 |
+
def _split_generators(self, dl_manager):
|
48 |
+
offset = 0
|
49 |
+
|
50 |
+
paths = []
|
51 |
+
|
52 |
+
while offset < _N_TOTAL:
|
53 |
+
url = _URL.format(first = offset + 1, last = min(offset := offset + _N_BATCH, _N_TOTAL))
|
54 |
+
|
55 |
+
paths.append(dl_manager.download_and_extract(url))
|
56 |
+
|
57 |
+
break
|
58 |
+
|
59 |
+
return [
|
60 |
+
datasets.SplitGenerator(
|
61 |
+
name=datasets.Split.TRAIN,
|
62 |
+
gen_kwargs={
|
63 |
+
"paths": paths
|
64 |
+
}
|
65 |
+
)
|
66 |
+
]
|
67 |
+
|
68 |
+
def _generate_examples(self, paths: list[str]):
|
69 |
+
for path in paths:
|
70 |
+
for file in sorted(glob(os.path.join(path, "*"))):
|
71 |
+
components = Path(file).stem.split('.', maxsplit = 1)
|
72 |
+
|
73 |
+
assert len(components) == 2, f'Incorrect file name: {file}'
|
74 |
+
|
75 |
+
id_ = int(components[0])
|
76 |
+
source = components[1]
|
77 |
+
|
78 |
+
meta = load_file(file)
|
79 |
+
|
80 |
+
# artist = meta['artist']
|
81 |
+
# text = meta['lyrics']
|
82 |
+
|
83 |
+
# print(id_, source, artist, text)
|
84 |
+
|
85 |
+
yield f'{id_:08d}-{source}', {
|
86 |
+
'text': meta['lyrics'],
|
87 |
+
'audio': file,
|
88 |
+
'artist': meta['artist'],
|
89 |
+
'id': id_,
|
90 |
+
'source': source
|
91 |
+
}
|
setup.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from setuptools import setup
|
2 |
+
|
3 |
+
setup(
|
4 |
+
name = "baneks-speech",
|
5 |
+
version = "10.10.2023",
|
6 |
+
install_requires = [
|
7 |
+
"music-tag==0.4.3"
|
8 |
+
]
|
9 |
+
)
|