new metadata
Browse files- CORAA-MUPE-ASR.py +132 -117
CORAA-MUPE-ASR.py
CHANGED
@@ -1,117 +1,132 @@
|
|
1 |
-
import csv
|
2 |
-
import datasets
|
3 |
-
|
4 |
-
_PROMPTS_URLS = {
|
5 |
-
"train": "train.csv",
|
6 |
-
"validation": "validation.csv",
|
7 |
-
"test": "test.csv",
|
8 |
-
}
|
9 |
-
|
10 |
-
_ARCHIVES = {
|
11 |
-
"train": "train.tar.gz",
|
12 |
-
"validation": "validation.tar.gz",
|
13 |
-
"test": "test.tar.gz",
|
14 |
-
}
|
15 |
-
|
16 |
-
_PATH_TO_CLIPS = {
|
17 |
-
"train": "train",
|
18 |
-
"validation": "validation",
|
19 |
-
"test": "test",
|
20 |
-
}
|
21 |
-
|
22 |
-
class MUPEASRDataset(datasets.GeneratorBasedBuilder):
|
23 |
-
def _info(self):
|
24 |
-
return datasets.DatasetInfo(
|
25 |
-
features=datasets.Features(
|
26 |
-
{
|
27 |
-
"audio_id": datasets.Value("int64"),
|
28 |
-
"audio_name": datasets.Value("string"),
|
29 |
-
"file_path": datasets.Value("string"),
|
30 |
-
"speaker_type": datasets.Value("string"),
|
31 |
-
"speaker_code": datasets.Value("string"),
|
32 |
-
"speaker_gender": datasets.Value("string"),
|
33 |
-
"
|
34 |
-
"
|
35 |
-
"
|
36 |
-
"
|
37 |
-
"
|
38 |
-
"
|
39 |
-
"
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
"
|
105 |
-
"
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
import datasets
|
3 |
+
|
4 |
+
_PROMPTS_URLS = {
|
5 |
+
"train": "train.csv",
|
6 |
+
"validation": "validation.csv",
|
7 |
+
"test": "test.csv",
|
8 |
+
}
|
9 |
+
|
10 |
+
_ARCHIVES = {
|
11 |
+
"train": "train.tar.gz",
|
12 |
+
"validation": "validation.tar.gz",
|
13 |
+
"test": "test.tar.gz",
|
14 |
+
}
|
15 |
+
|
16 |
+
_PATH_TO_CLIPS = {
|
17 |
+
"train": "train",
|
18 |
+
"validation": "validation",
|
19 |
+
"test": "test",
|
20 |
+
}
|
21 |
+
|
22 |
+
class MUPEASRDataset(datasets.GeneratorBasedBuilder):
|
23 |
+
def _info(self):
|
24 |
+
return datasets.DatasetInfo(
|
25 |
+
features=datasets.Features(
|
26 |
+
{
|
27 |
+
"audio_id": datasets.Value("int64"),
|
28 |
+
"audio_name": datasets.Value("string"),
|
29 |
+
"file_path": datasets.Value("string"),
|
30 |
+
"speaker_type": datasets.Value("string"),
|
31 |
+
"speaker_code": datasets.Value("string"),
|
32 |
+
"speaker_gender": datasets.Value("string"),
|
33 |
+
"education": datasets.Value("string"),
|
34 |
+
"birth_state": datasets.Value("string"),
|
35 |
+
"birth_country": datasets.Value("string"),
|
36 |
+
"age": datasets.Value("int64"),
|
37 |
+
"birth_year": datasets.Value("int64"),
|
38 |
+
"audio_quality": datasets.Value("string"),
|
39 |
+
"start_time": datasets.Value("float32"),
|
40 |
+
"end_time": datasets.Value("float32"),
|
41 |
+
"duration": datasets.Value("float32"),
|
42 |
+
"normalized_text": datasets.Value("string"),
|
43 |
+
"original_text": datasets.Value("string"),
|
44 |
+
"audio": datasets.Audio(sampling_rate=16_000),
|
45 |
+
}
|
46 |
+
)
|
47 |
+
)
|
48 |
+
|
49 |
+
def _split_generators(self, dl_manager):
|
50 |
+
prompts_path = dl_manager.download(_PROMPTS_URLS)
|
51 |
+
archive = dl_manager.download(_ARCHIVES)
|
52 |
+
|
53 |
+
return [
|
54 |
+
datasets.SplitGenerator(
|
55 |
+
name = datasets.Split.VALIDATION,
|
56 |
+
gen_kwargs = {
|
57 |
+
"prompts_path": prompts_path["validation"],
|
58 |
+
"path_to_clips": _PATH_TO_CLIPS["validation"],
|
59 |
+
"audio_files": dl_manager.iter_archive(archive["validation"]),
|
60 |
+
}
|
61 |
+
),
|
62 |
+
datasets.SplitGenerator(
|
63 |
+
name = datasets.Split.TEST,
|
64 |
+
gen_kwargs = {
|
65 |
+
"prompts_path": prompts_path["test"],
|
66 |
+
"path_to_clips": _PATH_TO_CLIPS["test"],
|
67 |
+
"audio_files": dl_manager.iter_archive(archive["test"]),
|
68 |
+
}
|
69 |
+
),
|
70 |
+
datasets.SplitGenerator(
|
71 |
+
name = datasets.Split.TRAIN,
|
72 |
+
gen_kwargs = {
|
73 |
+
"prompts_path": prompts_path["train"],
|
74 |
+
"path_to_clips": _PATH_TO_CLIPS["train"],
|
75 |
+
"audio_files": dl_manager.iter_archive(archive["train"]),
|
76 |
+
}
|
77 |
+
),
|
78 |
+
]
|
79 |
+
|
80 |
+
def _generate_examples(self, prompts_path, path_to_clips, audio_files):
|
81 |
+
examples = {}
|
82 |
+
with open(prompts_path, "r") as f:
|
83 |
+
csv_reader = csv.DictReader(f)
|
84 |
+
for row in csv_reader:
|
85 |
+
audio_id = row['audio_id']
|
86 |
+
audio_name = row['audio_name']
|
87 |
+
file_path = row['file_path']
|
88 |
+
speaker_type = row['speaker_type']
|
89 |
+
speaker_code = row['speaker_code']
|
90 |
+
speaker_gender = row['speaker_gender']
|
91 |
+
education = row['education']
|
92 |
+
birth_state = row['birth_state']
|
93 |
+
birth_country = row['birth_country']
|
94 |
+
age = row['age']
|
95 |
+
birth_year = row['birth_year']
|
96 |
+
audio_quality = row['audio_quality']
|
97 |
+
start_time = row['start_time']
|
98 |
+
end_time = row['end_time']
|
99 |
+
duration = row['duration']
|
100 |
+
normalized_text = row['normalized_text']
|
101 |
+
original_text = row['original_text']
|
102 |
+
|
103 |
+
examples[file_path] = {
|
104 |
+
"audio_id" : audio_id,
|
105 |
+
"audio_name" : audio_name,
|
106 |
+
"file_path" : file_path,
|
107 |
+
"speaker_type" : speaker_type,
|
108 |
+
"speaker_code" : speaker_code,
|
109 |
+
"speaker_gender" : speaker_gender,
|
110 |
+
"education" : education,
|
111 |
+
"birth_state" : birth_state,
|
112 |
+
"birth_country" : birth_country,
|
113 |
+
"age" : age,
|
114 |
+
"birth_year" : birth_year,
|
115 |
+
"audio_quality" : audio_quality,
|
116 |
+
"start_time" : start_time,
|
117 |
+
"end_time" : end_time,
|
118 |
+
"duration" : duration,
|
119 |
+
"normalized_text" : normalized_text,
|
120 |
+
"original_text" : original_text,
|
121 |
+
}
|
122 |
+
inside_clips_dir = False
|
123 |
+
id_ = 0
|
124 |
+
for path, f in audio_files:
|
125 |
+
if path.startswith(path_to_clips):
|
126 |
+
inside_clips_dir = True
|
127 |
+
if path in examples:
|
128 |
+
audio = {"path": path, "bytes": f.read()}
|
129 |
+
yield id_, {**examples[path], "audio": audio}
|
130 |
+
id_ += 1
|
131 |
+
elif inside_clips_dir:
|
132 |
+
break
|