Datasets:

Modalities:
Audio
Text
Formats:
parquet
ArXiv:
Libraries:
Datasets
pandas
License:
iwonachristop commited on
Commit
2f43db1
·
verified ·
1 Parent(s): 7ab72a4

Delete CAMEO.py

Browse files
Files changed (1) hide show
  1. CAMEO.py +0 -118
CAMEO.py DELETED
@@ -1,118 +0,0 @@
1
- import os
2
- import json
3
-
4
- from datasets import (
5
- Audio,
6
- BuilderConfig,
7
- DatasetInfo,
8
- Features,
9
- GeneratorBasedBuilder,
10
- SplitGenerator,
11
- Value,
12
- Version,
13
- )
14
-
15
- from datasets.download.download_manager import DownloadManager
16
-
17
-
18
- _DATASETS = [
19
- "CaFE", "CREMA-D", "EMNS", "Emozionalmente", "eNTERFACE",
20
- "JL-Corpus", "MESD", "nEMO", "Oreau", "PAVOQUE",
21
- "RAVDESS", "RESD", "SUBESCO",
22
- ]
23
-
24
- _CONFIGS = _DATASETS + ["all"]
25
-
26
- _SPLITS = ["test"]
27
-
28
-
29
- class CAMEOConfig(BuilderConfig):
30
- def __init__(self, name, **kwargs):
31
- super(CAMEOConfig, self).__init__(
32
- name=name,
33
- version=Version("1.0.0", ""),
34
- description="",
35
- **kwargs,
36
- )
37
-
38
-
39
- class CAMEODataset(GeneratorBasedBuilder):
40
- DEFAULT_CONFIG_NAME = "all"
41
- BUILDER_CONFIGS = [CAMEOConfig(name=config) for config in _CONFIGS]
42
-
43
- def _info(self):
44
- return DatasetInfo(
45
- description="",
46
- features=Features(
47
- {
48
- "file_id": Value("string"),
49
- "audio": Audio(sampling_rate=16_000),
50
- "emotion": Value("string"),
51
- "transcription": Value("string"),
52
- "speaker_id": Value("string"),
53
- "gender": Value("string"),
54
- "age": Value("string"),
55
- "dataset": Value("string"),
56
- "language": Value("string"),
57
- "license": Value("string"),
58
- }
59
- ),
60
- supervised_keys=None,
61
- homepage="",
62
- license="",
63
- citation="",
64
- )
65
-
66
- def _split_generators(self, dl_manager: DownloadManager) -> list[SplitGenerator]:
67
- if self.config.name == "all":
68
- audio_urls = {split: [f"data/{dataset}/test.tar.gz" for dataset in _DATASETS] for split in _SPLITS}
69
- meta_urls = {split: [f"data/{dataset}/test.jsonl" for dataset in _DATASETS] for split in _SPLITS}
70
-
71
- else:
72
- audio_urls = {split: [f"data/{self.config.name}/test.tar.gz"] for split in _SPLITS}
73
- meta_urls = {split: [f"data/{self.config.name}/test.jsonl"] for split in _SPLITS}
74
-
75
- audio_paths = dl_manager.download(audio_urls)
76
- audio_iters = {split: [dl_manager.iter_archive(path) for path in paths] for split, paths in audio_paths.items()}
77
-
78
- local_extracted_archive = dl_manager.extract(audio_paths) if not dl_manager.is_streaming else {
79
- split: [None] * len(paths) for split, paths in audio_paths.items()
80
- }
81
- path_to_clips = "CAMEO/data"
82
-
83
- return [
84
- SplitGenerator(
85
- name=split,
86
- gen_kwargs={
87
- "local_extracted_archive": local_extracted_archive.get(split),
88
- "audio_files": audio_iters.get(split),
89
- "metadata_path": dl_manager.download_and_extract(meta_urls.get(split)),
90
- "path_to_clips": os.path.join(path_to_clips, self.config.name, split),
91
- },
92
- ) for split in _SPLITS
93
- ]
94
-
95
- def _generate_examples(self, local_extracted_archive, audio_files, metadata_path, path_to_clips):
96
- data_fields = list(self._info().features.keys())
97
- metadata = {}
98
- id_ = 0
99
-
100
- for metadata_pth, audio_fs, local_archive in zip(metadata_path, audio_files, local_extracted_archive):
101
- with open(metadata_pth, "r", encoding="utf-8") as fp:
102
- for row in fp:
103
- row = json.loads(row.strip())
104
- row["audio"] = os.path.join(path_to_clips, row["file_id"])
105
-
106
- for field in data_fields:
107
- if field not in row:
108
- row[field] = ""
109
-
110
- metadata[row["audio"]] = row
111
-
112
- for path, f in audio_fs:
113
- result = dict(metadata[os.path.join(path_to_clips, path.split("/")[-1])])
114
- path = os.path.join(local_archive, path) if local_archive else path
115
- result["audio"] = {"path": path, "bytes": f.read()}
116
- yield id_, result
117
- id_ += 1
118
-