Datasets:
addding previous code
Browse files- bn_emotion_speech_corpus.py +29 -64
bn_emotion_speech_corpus.py
CHANGED
@@ -1,90 +1,55 @@
|
|
1 |
-
import json
|
2 |
-
import os
|
3 |
-
|
4 |
import datasets
|
5 |
|
6 |
_CITATION = """\
|
|
|
7 |
"""
|
8 |
|
9 |
_DESCRIPTION = """\
|
10 |
-
The corpus contains roughly 360 hours of audio and transcripts in Kannada language. The transcripts have beed de-duplicated using exact match deduplication.
|
11 |
-
"""
|
12 |
|
|
|
13 |
_HOMEPAGE = ""
|
14 |
|
15 |
-
_LICENSE = "
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
"train": "train.jsonl",
|
20 |
-
}
|
21 |
-
_URLS = {
|
22 |
-
"train": "subesco.tar.gz",
|
23 |
-
|
24 |
-
}
|
25 |
|
26 |
-
class
|
27 |
-
"""
|
28 |
|
29 |
-
VERSION = datasets.Version("1.1.0")
|
30 |
def _info(self):
|
31 |
-
features = datasets.Features(
|
32 |
-
{
|
33 |
-
"path": datasets.Value("string"),
|
34 |
-
"audio": datasets.Audio(sampling_rate=16000),
|
35 |
-
"speaker_gender": datasets.Value("string"),
|
36 |
-
"speaker_number": datasets.Value("int32"),
|
37 |
-
"speaker_name": datasets.Value("string"),
|
38 |
-
"sentence_number": datasets.Value("int32"),
|
39 |
-
"emotional_state": datasets.Value("string"),
|
40 |
-
"take_number": datasets.Value("int32"),
|
41 |
-
}
|
42 |
-
)
|
43 |
return datasets.DatasetInfo(
|
44 |
description=_DESCRIPTION,
|
45 |
-
features=
|
|
|
|
|
|
|
|
|
|
|
46 |
supervised_keys=None,
|
47 |
homepage=_HOMEPAGE,
|
48 |
-
license=_LICENSE,
|
49 |
citation=_CITATION,
|
50 |
)
|
51 |
|
52 |
def _split_generators(self, dl_manager):
|
53 |
-
|
54 |
-
|
55 |
-
local_extracted_train_archive = dl_manager.extract(train_archive) if not dl_manager.is_streaming else None
|
56 |
-
train_dir = "train"
|
57 |
-
|
58 |
return [
|
59 |
datasets.SplitGenerator(
|
60 |
name=datasets.Split.TRAIN,
|
61 |
gen_kwargs={
|
62 |
-
"
|
63 |
-
|
64 |
-
|
65 |
-
"audio_files": dl_manager.iter_archive(train_archive),
|
66 |
-
},
|
67 |
-
),
|
68 |
]
|
69 |
-
|
70 |
-
def _generate_examples(self,
|
71 |
-
"""
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
inside_clips_dir = True
|
82 |
-
if path in examples:
|
83 |
-
result = examples[path]
|
84 |
-
path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
|
85 |
-
result["audio"] = {"path": path, "bytes": f.read()}
|
86 |
-
result["path"] = path
|
87 |
-
yield id_, result
|
88 |
-
id_ += 1
|
89 |
-
elif inside_clips_dir:
|
90 |
-
break
|
|
|
|
|
|
|
|
|
1 |
import datasets
|
2 |
|
3 |
_CITATION = """\
|
4 |
+
|
5 |
"""
|
6 |
|
7 |
_DESCRIPTION = """\
|
|
|
|
|
8 |
|
9 |
+
"""
|
10 |
_HOMEPAGE = ""
|
11 |
|
12 |
+
_LICENSE = ""
|
|
|
13 |
|
14 |
+
#_REPO = "https://huggingface.co/datasets/sustcsenlp/SUBESCO/resolve/main/corpus/speech/subesco.tar.gz"
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
class ImageSet(datasets.GeneratorBasedBuilder):
|
17 |
+
""""""
|
18 |
|
|
|
19 |
def _info(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
return datasets.DatasetInfo(
|
21 |
description=_DESCRIPTION,
|
22 |
+
features=datasets.Features(
|
23 |
+
{
|
24 |
+
'text': datasets.Value("string"),
|
25 |
+
"audio": datasets.Audio(sampling_rate=16000),
|
26 |
+
}
|
27 |
+
),
|
28 |
supervised_keys=None,
|
29 |
homepage=_HOMEPAGE,
|
|
|
30 |
citation=_CITATION,
|
31 |
)
|
32 |
|
33 |
def _split_generators(self, dl_manager):
|
34 |
+
audio_archive = dl_manager.download("https://huggingface.co/datasets/sustcsenlp/SUBESCO/resolve/main/corpus/speech/subesco.tar.gz")
|
35 |
+
audio_iters = dl_manager.iter_archive(audio_archive)
|
|
|
|
|
|
|
36 |
return [
|
37 |
datasets.SplitGenerator(
|
38 |
name=datasets.Split.TRAIN,
|
39 |
gen_kwargs={
|
40 |
+
"audios": audio_iters
|
41 |
+
}
|
42 |
+
),
|
|
|
|
|
|
|
43 |
]
|
44 |
+
|
45 |
+
def _generate_examples(self, audios):
|
46 |
+
"""This function returns the examples in the raw (text) form."""
|
47 |
+
idx = 0
|
48 |
+
for filepath, audio in audios:
|
49 |
+
description = filepath.split('/')[-1][:-4]
|
50 |
+
#description = description.replace('_', ' ')
|
51 |
+
yield idx, {
|
52 |
+
"audio": {"path": filepath, "bytes": audio.read()},
|
53 |
+
"text": description,
|
54 |
+
}
|
55 |
+
idx += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|