RodrigoLimaRFL commited on
Commit
778b351
·
verified ·
1 Parent(s): 9750a11

Update NURC-SP_ENTOA_TTS.py

Browse files
Files changed (1) hide show
  1. NURC-SP_ENTOA_TTS.py +47 -31
NURC-SP_ENTOA_TTS.py CHANGED
@@ -3,6 +3,7 @@ import datasets
3
  from datasets import BuilderConfig, GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split
4
  import logging
5
  from pathlib import Path
 
6
 
7
  # Set up logging
8
  logging.basicConfig(level=logging.INFO)
@@ -24,8 +25,8 @@ _ARCHIVES = {
24
  }
25
 
26
  _PATH_TO_CLIPS = {
27
- "dev": "automatic/validation",
28
- "train": "automatic/train",
29
  }
30
 
31
  class NurcSPConfig(BuilderConfig):
@@ -98,20 +99,20 @@ class NurcSPDataset(GeneratorBasedBuilder):
98
  ]
99
 
100
  def _generate_examples(self, prompts_path, path_to_clips, audio_files):
101
- logger.info(f"Generating examples from prompts_path: {prompts_path}")
102
- logger.info(f"Looking for clips in: {path_to_clips}")
 
103
 
104
  examples = {}
105
  example_count = 0
 
106
 
107
- # Read CSV file and log some sample paths
108
- logger.info("Reading CSV file...")
109
  with open(prompts_path, "r") as f:
110
  csv_reader = csv.DictReader(f)
111
- for i, row in enumerate(csv_reader):
112
- file_path = row['file_path']
113
- # Normalize path separators
114
- file_path = Path(file_path).as_posix()
115
  examples[file_path] = {
116
  "audio_name": row['audio_name'],
117
  "file_path": file_path,
@@ -129,48 +130,63 @@ class NurcSPDataset(GeneratorBasedBuilder):
129
  "num_speakers": row['num_speakers'],
130
  "speaker_id": row['speaker_id'],
131
  }
 
132
  example_count += 1
133
- # Log first few paths for debugging
134
- if i < 5:
135
- logger.info(f"Sample CSV path {i}: {file_path}")
136
 
137
- logger.info(f"Found {example_count} examples in CSV")
 
 
 
 
 
138
 
139
  inside_clips_dir = False
140
  id_ = 0
141
  matched_files = 0
142
- archive_paths_seen = set()
143
-
144
- # Log the path_to_clips we're looking for
145
- logger.info(f"Looking for files in directory: {path_to_clips}")
146
 
 
147
  for path, f in audio_files:
148
- # Normalize path separators
149
  path = Path(path).as_posix()
150
- archive_paths_seen.add(path)
151
 
152
  if path.startswith(path_to_clips):
153
  inside_clips_dir = True
154
- logger.debug(f"Found file in clips directory: {path}")
155
  if path in examples:
156
  audio = {"path": path, "bytes": f.read()}
157
  matched_files += 1
158
  yield id_, {**examples[path], "audio": audio}
159
  id_ += 1
160
  else:
161
- # Log unmatched paths for first few files
162
- if len(archive_paths_seen) < 5:
163
- logger.warning(f"Archive path not found in CSV: {path}")
164
  elif inside_clips_dir:
165
  break
166
 
167
- # Log some sample archive paths for comparison
168
- logger.info("Sample paths from archive:")
169
- for path in list(archive_paths_seen)[:5]:
 
170
  logger.info(f"Archive path: {path}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
- logger.info(f"Total archive paths found: {len(archive_paths_seen)}")
173
- logger.info(f"Matched {matched_files} audio files with CSV entries")
174
  if matched_files == 0:
175
- logger.warning("No audio files were matched with CSV entries!")
176
- logger.warning("This might be due to path mismatches. Check if the paths in your CSV match the structure in your .tar.gz file.")
 
 
 
 
 
 
3
  from datasets import BuilderConfig, GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split
4
  import logging
5
  from pathlib import Path
6
+ import os
7
 
8
  # Set up logging
9
  logging.basicConfig(level=logging.INFO)
 
25
  }
26
 
27
  _PATH_TO_CLIPS = {
28
+ "dev": "validation",
29
+ "train": "train",
30
  }
31
 
32
  class NurcSPConfig(BuilderConfig):
 
99
  ]
100
 
101
  def _generate_examples(self, prompts_path, path_to_clips, audio_files):
102
+ logger.info("\n=== Path Analysis ===")
103
+ logger.info(f"CSV Path: {prompts_path}")
104
+ logger.info(f"Expected clips directory: {path_to_clips}")
105
 
106
  examples = {}
107
  example_count = 0
108
+ csv_paths = []
109
 
110
+ # Read CSV file and store paths
111
+ logger.info("\n=== Reading CSV ===")
112
  with open(prompts_path, "r") as f:
113
  csv_reader = csv.DictReader(f)
114
+ for row in csv_reader:
115
+ file_path = Path(row['file_path']).as_posix()
 
 
116
  examples[file_path] = {
117
  "audio_name": row['audio_name'],
118
  "file_path": file_path,
 
130
  "num_speakers": row['num_speakers'],
131
  "speaker_id": row['speaker_id'],
132
  }
133
+ csv_paths.append(file_path)
134
  example_count += 1
 
 
 
135
 
136
+ logger.info(f"Found {example_count} entries in CSV")
137
+
138
+ # Show first few CSV paths
139
+ logger.info("\n=== Sample CSV Paths ===")
140
+ for path in csv_paths[:3]:
141
+ logger.info(f"CSV path: {path}")
142
 
143
  inside_clips_dir = False
144
  id_ = 0
145
  matched_files = 0
146
+ archive_paths = []
 
 
 
147
 
148
+ logger.info("\n=== Processing Archive ===")
149
  for path, f in audio_files:
 
150
  path = Path(path).as_posix()
151
+ archive_paths.append(path)
152
 
153
  if path.startswith(path_to_clips):
154
  inside_clips_dir = True
 
155
  if path in examples:
156
  audio = {"path": path, "bytes": f.read()}
157
  matched_files += 1
158
  yield id_, {**examples[path], "audio": audio}
159
  id_ += 1
160
  else:
161
+ logger.debug(f"Unmatched archive path: {path}")
 
 
162
  elif inside_clips_dir:
163
  break
164
 
165
+ # Show path comparison
166
+ logger.info("\n=== Path Comparison ===")
167
+ logger.info("First few paths from archive:")
168
+ for path in archive_paths[:3]:
169
  logger.info(f"Archive path: {path}")
170
+
171
+ # Try to find a similar path in CSV
172
+ for csv_path in csv_paths:
173
+ if any(part in csv_path for part in path.split('/')):
174
+ logger.info(f"Similar CSV path: {csv_path}")
175
+ logger.info("Difference analysis:")
176
+ logger.info(f" Archive path parts: {path.split('/')}")
177
+ logger.info(f" CSV path parts: {csv_path.split('/')}")
178
+ break
179
+
180
+ logger.info("\n=== Summary ===")
181
+ logger.info(f"Total paths in CSV: {len(csv_paths)}")
182
+ logger.info(f"Total paths in archive: {len(archive_paths)}")
183
+ logger.info(f"Successfully matched files: {matched_files}")
184
 
 
 
185
  if matched_files == 0:
186
+ logger.warning("\n=== MATCHING FAILED ===")
187
+ logger.warning("No files were matched between CSV and archive.")
188
+ logger.warning("Common issues:")
189
+ logger.warning("1. CSV paths might need to include/exclude the base directory")
190
+ logger.warning("2. Path separators might be different (/ vs \\)")
191
+ logger.warning("3. Case sensitivity issues in paths")
192
+ logger.warning("4. Extra or missing directory levels")