Update NURC-SP_ENTOA_TTS.py
Browse files- NURC-SP_ENTOA_TTS.py +110 -55
NURC-SP_ENTOA_TTS.py
CHANGED
@@ -4,75 +4,110 @@ from datasets import BuilderConfig, GeneratorBasedBuilder, DatasetInfo, SplitGen
|
|
4 |
from pathlib import Path
|
5 |
import os
|
6 |
|
7 |
-
|
8 |
"dev": "prosodic/validation.csv",
|
9 |
"train": "prosodic/train.csv",
|
10 |
}
|
11 |
|
12 |
-
|
13 |
-
"dev": "
|
14 |
-
"train": "
|
15 |
}
|
16 |
|
17 |
-
|
18 |
"dev": "prosodic/audios.tar.gz",
|
19 |
"train": "prosodic/audios.tar.gz",
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
_PATH_TO_CLIPS = {
|
23 |
"dev": "",
|
24 |
"train": "",
|
25 |
}
|
26 |
|
27 |
class NurcSPConfig(BuilderConfig):
|
28 |
-
def __init__(self, prompts_type
|
29 |
super().__init__(**kwargs)
|
30 |
self.prompts_type = prompts_type
|
31 |
|
32 |
class NurcSPDataset(GeneratorBasedBuilder):
|
33 |
BUILDER_CONFIGS = [
|
34 |
-
NurcSPConfig(name="
|
35 |
-
NurcSPConfig(name="
|
36 |
]
|
37 |
|
38 |
def _info(self):
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
)
|
60 |
-
)
|
61 |
|
62 |
def _split_generators(self, dl_manager):
|
63 |
print("\n=== Configuration ===")
|
64 |
print(f"Using prompts_type: {self.config.prompts_type}")
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
print(f"Downloading prompts from: {prompts_urls}")
|
71 |
prompts_path = dl_manager.download(prompts_urls)
|
72 |
print(f"Downloaded prompts to: {prompts_path}")
|
73 |
|
74 |
-
print(f"Downloading archives from: {
|
75 |
-
archive = dl_manager.download(
|
76 |
print(f"Downloaded archives to: {archive}")
|
77 |
|
78 |
return [
|
@@ -110,27 +145,47 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
110 |
print("\n=== Reading CSV ===")
|
111 |
with open(prompts_path, "r") as f:
|
112 |
csv_reader = csv.DictReader(f)
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
print(f"\nFound {len(csv_paths)} entries in CSV")
|
135 |
print("\nFirst 3 CSV paths:")
|
136 |
for path in csv_paths[:3]:
|
|
|
4 |
from pathlib import Path
|
5 |
import os
|
6 |
|
7 |
+
_PROMPTS_PROSODIC_URLS = {
|
8 |
"dev": "prosodic/validation.csv",
|
9 |
"train": "prosodic/train.csv",
|
10 |
}
|
11 |
|
12 |
+
_PROMPTS_AUTOMATIC_URLS = {
|
13 |
+
"dev": "automatic/validation.csv",
|
14 |
+
"train": "automatic/train.csv",
|
15 |
}
|
16 |
|
17 |
+
_ARCHIVES_PROSODIC = {
|
18 |
"dev": "prosodic/audios.tar.gz",
|
19 |
"train": "prosodic/audios.tar.gz",
|
20 |
}
|
21 |
|
22 |
+
_ARCHIVES_AUTOMATIC = {
|
23 |
+
"dev": "automatic/audios.tar.gz",
|
24 |
+
"train": "automatic/audios.tar.gz",
|
25 |
+
}
|
26 |
+
|
27 |
_PATH_TO_CLIPS = {
|
28 |
"dev": "",
|
29 |
"train": "",
|
30 |
}
|
31 |
|
32 |
class NurcSPConfig(BuilderConfig):
|
33 |
+
def __init__(self, prompts_type, **kwargs):
|
34 |
super().__init__(**kwargs)
|
35 |
self.prompts_type = prompts_type
|
36 |
|
37 |
class NurcSPDataset(GeneratorBasedBuilder):
|
38 |
BUILDER_CONFIGS = [
|
39 |
+
NurcSPConfig(name="automatic", description="Automatic audio prompts", prompts_type="automatic"),
|
40 |
+
NurcSPConfig(name="prosodic", description="Prosodic audio prompts", prompts_type="prosodic"),
|
41 |
]
|
42 |
|
43 |
def _info(self):
|
44 |
+
if self.config.name == "prosodic":
|
45 |
+
return DatasetInfo(
|
46 |
+
features=datasets.Features(
|
47 |
+
{
|
48 |
+
"path": datasets.Value("string"),
|
49 |
+
"name": datasets.Value("string"),
|
50 |
+
"speaker": datasets.Value("string"),
|
51 |
+
"start_time": datasets.Value("string"),
|
52 |
+
"end_time": datasets.Value("string"),
|
53 |
+
"normalized_text": datasets.Value("string"),
|
54 |
+
"text": datasets.Value("string"),
|
55 |
+
"duration": datasets.Value("string"),
|
56 |
+
"type": datasets.Value("string"),
|
57 |
+
"year": datasets.Value("string"),
|
58 |
+
"gender": datasets.Value("string"),
|
59 |
+
"age_range": datasets.Value("string"),
|
60 |
+
"total_duration": datasets.Value("string"),
|
61 |
+
"quality": datasets.Value("string"),
|
62 |
+
"theme": datasets.Value("string"),
|
63 |
+
"audio": datasets.Audio(sampling_rate=16_000),
|
64 |
+
}
|
65 |
+
)
|
66 |
+
)
|
67 |
+
elif self.config.name == "automatic":
|
68 |
+
return DatasetInfo(
|
69 |
+
features=datasets.Features(
|
70 |
+
{
|
71 |
+
"audio_name": datasets.Value("string"),
|
72 |
+
"file_path": datasets.Value("string"),
|
73 |
+
"text": datasets.Value("string"),
|
74 |
+
"start_time": datasets.Value("string"),
|
75 |
+
"end_time": datasets.Value("string"),
|
76 |
+
"duration": datasets.Value("string"),
|
77 |
+
"quality": datasets.Value("string"),
|
78 |
+
"speech_genre": datasets.Value("string"),
|
79 |
+
"speech_style": datasets.Value("string"),
|
80 |
+
"variety": datasets.Value("string"),
|
81 |
+
"accent": datasets.Value("string"),
|
82 |
+
"sex": datasets.Value("string"),
|
83 |
+
"age_range": datasets.Value("string"),
|
84 |
+
"num_speakers": datasets.Value("string"),
|
85 |
+
"speaker_id": datasets.Value("string"),
|
86 |
+
"audio": datasets.Audio(sampling_rate=16_000),
|
87 |
+
}
|
88 |
+
)
|
89 |
)
|
|
|
90 |
|
91 |
def _split_generators(self, dl_manager):
|
92 |
print("\n=== Configuration ===")
|
93 |
print(f"Using prompts_type: {self.config.prompts_type}")
|
94 |
|
95 |
+
if self.config.prompts_type == "prosodic":
|
96 |
+
prompts_urls = _PROMPTS_PROSODIC_URLS
|
97 |
+
archive_link = _ARCHIVES_PROSODIC
|
98 |
+
elif self.config.prompts_type == "automatic":
|
99 |
+
prompts_urls = _PROMPTS_AUTOMATIC_URLS
|
100 |
+
archive_link = _ARCHIVES_AUTOMATIC
|
101 |
+
else:
|
102 |
+
print("Invalid config")
|
103 |
+
return
|
104 |
|
105 |
print(f"Downloading prompts from: {prompts_urls}")
|
106 |
prompts_path = dl_manager.download(prompts_urls)
|
107 |
print(f"Downloaded prompts to: {prompts_path}")
|
108 |
|
109 |
+
print(f"Downloading archives from: {archive_link}")
|
110 |
+
archive = dl_manager.download(archive_link)
|
111 |
print(f"Downloaded archives to: {archive}")
|
112 |
|
113 |
return [
|
|
|
145 |
print("\n=== Reading CSV ===")
|
146 |
with open(prompts_path, "r") as f:
|
147 |
csv_reader = csv.DictReader(f)
|
148 |
+
if self.config.prompts_type == "prosodic":
|
149 |
+
for row in csv_reader:
|
150 |
+
file_path = Path(row['path']).as_posix()
|
151 |
+
examples[file_path] = {
|
152 |
+
"path": row['path'],
|
153 |
+
"name": row['name'],
|
154 |
+
"speaker": row['speaker'],
|
155 |
+
"start_time": row['start_time'],
|
156 |
+
"end_time": row['end_time'],
|
157 |
+
"normalized_text": row['normalized_text'],
|
158 |
+
"text": row['text'],
|
159 |
+
"duration": row['duration'],
|
160 |
+
"type": row['type'],
|
161 |
+
"year": row['year'],
|
162 |
+
"gender": row['gender'],
|
163 |
+
"age_range": row['age_range'],
|
164 |
+
"total_duration": row['total_duration'],
|
165 |
+
"quality": row['quality'],
|
166 |
+
"theme": row['theme'],
|
167 |
+
}
|
168 |
+
csv_paths.append(file_path)
|
169 |
+
elif self.config.prompts_type == "automatic":
|
170 |
+
for row in csv_reader:
|
171 |
+
examples[row['file_path']] = {
|
172 |
+
"audio_name": row['audio_name'],
|
173 |
+
"file_path": row['file_path'],
|
174 |
+
"text": row['text'],
|
175 |
+
"start_time": row['start_time'],
|
176 |
+
"end_time": row['end_time'],
|
177 |
+
"duration": row['duration'],
|
178 |
+
"quality": row['quality'],
|
179 |
+
"speech_genre": row['speech_genre'],
|
180 |
+
"speech_style": row['speech_style'],
|
181 |
+
"variety": row['variety'],
|
182 |
+
"accent": row['accent'],
|
183 |
+
"sex": row['sex'],
|
184 |
+
"age_range": row['age_range'],
|
185 |
+
"num_speakers": row['num_speakers'],
|
186 |
+
"speaker_id": row['speaker_id'],
|
187 |
+
}
|
188 |
+
|
189 |
print(f"\nFound {len(csv_paths)} entries in CSV")
|
190 |
print("\nFirst 3 CSV paths:")
|
191 |
for path in csv_paths[:3]:
|