RodrigoLimaRFL commited on
Commit
5e3b83b
·
verified ·
1 Parent(s): 62ece39

Update NURC-SP_ENTOA_TTS.py

Browse files
Files changed (1) hide show
  1. NURC-SP_ENTOA_TTS.py +7 -69
NURC-SP_ENTOA_TTS.py CHANGED
@@ -2,7 +2,6 @@ import csv
2
  import datasets
3
  from datasets import BuilderConfig, GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split
4
  from pathlib import Path
5
- import os
6
 
7
  _PROMPTS_PROSODIC_URLS = {
8
  "dev": "prosodic/validation.csv",
@@ -89,9 +88,6 @@ class NurcSPDataset(GeneratorBasedBuilder):
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
@@ -99,16 +95,10 @@ class NurcSPDataset(GeneratorBasedBuilder):
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 [
114
  SplitGenerator(
@@ -132,17 +122,9 @@ class NurcSPDataset(GeneratorBasedBuilder):
132
  ]
133
 
134
  def _generate_examples(self, prompts_path, path_to_clips, audio_files, split_name):
135
- print(f"\n{'='*50}")
136
- print(f"Processing {split_name} split")
137
- print(f"{'='*50}")
138
- print(f"\nCSV Path: {prompts_path}")
139
- print(f"Expected clips directory: {path_to_clips}")
140
-
141
  examples = {}
142
  csv_paths = []
143
-
144
- # Read CSV file
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":
@@ -187,55 +169,11 @@ class NurcSPDataset(GeneratorBasedBuilder):
187
  "speaker_id": row['speaker_id'],
188
  }
189
  csv_paths.append(file_path)
190
-
191
- print(f"\nFound {len(csv_paths)} entries in CSV")
192
- print("\nFirst 3 CSV paths:")
193
- for path in csv_paths[:3]:
194
- print(f" CSV path: {path}")
195
-
196
- # Process archive
197
- print("\n=== Processing Archive ===")
198
- inside_clips_dir = False
199
  id_ = 0
200
- matched_files = 0
201
- archive_paths = []
202
-
203
  for path, f in audio_files:
204
  path = Path(path).as_posix()
205
- archive_paths.append(path)
206
-
207
- if path.startswith(path_to_clips):
208
- inside_clips_dir = True
209
- if path in examples:
210
- audio = {"path": path, "bytes": f.read()}
211
- matched_files += 1
212
- yield id_, {**examples[path], "audio": audio}
213
- id_ += 1
214
-
215
- print("\n=== Path Analysis ===")
216
- print("\nFirst 3 archive paths:")
217
- for path in archive_paths[:3]:
218
- print(f" Archive path: {path}")
219
-
220
- # Try to find potential matches
221
- print("\nPotential matches in CSV:")
222
- for csv_path in csv_paths[:3]:
223
- print(f"\nComparing:")
224
- print(f" Archive: {path}")
225
- print(f" CSV: {csv_path}")
226
- print(f" Archive parts: {path.split('/')}")
227
- print(f" CSV parts: {csv_path.split('/')}")
228
-
229
- print(f"\n=== Summary for {split_name} split ===")
230
- print(f"Total paths in CSV: {len(csv_paths)}")
231
- print(f"Total paths found in archive: {len(archive_paths)}")
232
- print(f"Successfully matched files: {matched_files}")
233
-
234
- if matched_files == 0:
235
- print("\n!!! MATCHING FAILED !!!")
236
- print("No files were matched between CSV and archive")
237
- print("\nTroubleshooting:")
238
- print("1. Check if CSV paths start with the clip directory name")
239
- print("2. Check for case sensitivity issues")
240
- print("3. Check for extra/missing directory levels")
241
- print("4. Check path separator consistency")
 
2
  import datasets
3
  from datasets import BuilderConfig, GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split
4
  from pathlib import Path
 
5
 
6
  _PROMPTS_PROSODIC_URLS = {
7
  "dev": "prosodic/validation.csv",
 
88
  )
89
 
90
  def _split_generators(self, dl_manager):
 
 
 
91
  if self.config.prompts_type == "prosodic":
92
  prompts_urls = _PROMPTS_PROSODIC_URLS
93
  archive_link = _ARCHIVES_PROSODIC
 
95
  prompts_urls = _PROMPTS_AUTOMATIC_URLS
96
  archive_link = _ARCHIVES_AUTOMATIC
97
  else:
 
98
  return
99
+
 
100
  prompts_path = dl_manager.download(prompts_urls)
 
 
 
101
  archive = dl_manager.download(archive_link)
 
102
 
103
  return [
104
  SplitGenerator(
 
122
  ]
123
 
124
  def _generate_examples(self, prompts_path, path_to_clips, audio_files, split_name):
 
 
 
 
 
 
125
  examples = {}
126
  csv_paths = []
127
+
 
 
128
  with open(prompts_path, "r") as f:
129
  csv_reader = csv.DictReader(f)
130
  if self.config.prompts_type == "prosodic":
 
169
  "speaker_id": row['speaker_id'],
170
  }
171
  csv_paths.append(file_path)
172
+
 
 
 
 
 
 
 
 
173
  id_ = 0
 
 
 
174
  for path, f in audio_files:
175
  path = Path(path).as_posix()
176
+ if path.startswith(path_to_clips) and path in examples:
177
+ audio = {"path": path, "bytes": f.read()}
178
+ yield id_, {**examples[path], "audio": audio}
179
+ id_ += 1