Update NURC-SP_ENTOA_TTS.py
Browse files- 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": "
|
28 |
-
"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(
|
102 |
-
logger.info(f"
|
|
|
103 |
|
104 |
examples = {}
|
105 |
example_count = 0
|
|
|
106 |
|
107 |
-
# Read CSV file and
|
108 |
-
logger.info("Reading CSV
|
109 |
with open(prompts_path, "r") as f:
|
110 |
csv_reader = csv.DictReader(f)
|
111 |
-
for
|
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}
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
inside_clips_dir = False
|
140 |
id_ = 0
|
141 |
matched_files = 0
|
142 |
-
|
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 |
-
|
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 |
-
|
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 |
-
#
|
168 |
-
logger.info("
|
169 |
-
|
|
|
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("
|
176 |
-
logger.warning("
|
|
|
|
|
|
|
|
|
|
|
|
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")
|