Update NURC-SP_ENTOA_TTS.py
Browse files- NURC-SP_ENTOA_TTS.py +44 -52
NURC-SP_ENTOA_TTS.py
CHANGED
@@ -1,14 +1,9 @@
|
|
1 |
import csv
|
2 |
import datasets
|
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)
|
10 |
-
logger = logging.getLogger(__name__)
|
11 |
-
|
12 |
_PROMPTS_URLS = {
|
13 |
"dev": "automatic/validation.csv",
|
14 |
"train": "automatic/train.csv",
|
@@ -65,19 +60,20 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
65 |
)
|
66 |
|
67 |
def _split_generators(self, dl_manager):
|
68 |
-
|
|
|
69 |
|
70 |
prompts_urls = _PROMPTS_URLS
|
71 |
if self.config.prompts_type == "filtered":
|
72 |
prompts_urls = _PROMPTS_FILTERED_URLS
|
73 |
|
74 |
-
|
75 |
prompts_path = dl_manager.download(prompts_urls)
|
76 |
-
|
77 |
|
78 |
-
|
79 |
archive = dl_manager.download(_ARCHIVES)
|
80 |
-
|
81 |
|
82 |
return [
|
83 |
SplitGenerator(
|
@@ -86,6 +82,7 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
86 |
"prompts_path": prompts_path["dev"],
|
87 |
"path_to_clips": _PATH_TO_CLIPS["dev"],
|
88 |
"audio_files": dl_manager.iter_archive(archive["dev"]),
|
|
|
89 |
}
|
90 |
),
|
91 |
SplitGenerator(
|
@@ -94,21 +91,23 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
94 |
"prompts_path": prompts_path["train"],
|
95 |
"path_to_clips": _PATH_TO_CLIPS["train"],
|
96 |
"audio_files": dl_manager.iter_archive(archive["train"]),
|
|
|
97 |
}
|
98 |
),
|
99 |
]
|
100 |
|
101 |
-
def _generate_examples(self, prompts_path, path_to_clips, audio_files):
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
105 |
|
106 |
examples = {}
|
107 |
-
example_count = 0
|
108 |
csv_paths = []
|
109 |
|
110 |
-
# Read CSV file
|
111 |
-
|
112 |
with open(prompts_path, "r") as f:
|
113 |
csv_reader = csv.DictReader(f)
|
114 |
for row in csv_reader:
|
@@ -131,21 +130,19 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
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 |
-
|
139 |
-
|
140 |
for path in csv_paths[:3]:
|
141 |
-
|
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)
|
@@ -157,36 +154,31 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
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 |
-
|
166 |
-
|
167 |
-
logger.info("First few paths from archive:")
|
168 |
for path in archive_paths[:3]:
|
169 |
-
|
170 |
|
171 |
-
# Try to find
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
|
185 |
if matched_files == 0:
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
|
|
1 |
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_URLS = {
|
8 |
"dev": "automatic/validation.csv",
|
9 |
"train": "automatic/train.csv",
|
|
|
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 |
prompts_urls = _PROMPTS_URLS
|
67 |
if self.config.prompts_type == "filtered":
|
68 |
prompts_urls = _PROMPTS_FILTERED_URLS
|
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: {_ARCHIVES}")
|
75 |
archive = dl_manager.download(_ARCHIVES)
|
76 |
+
print(f"Downloaded archives to: {archive}")
|
77 |
|
78 |
return [
|
79 |
SplitGenerator(
|
|
|
82 |
"prompts_path": prompts_path["dev"],
|
83 |
"path_to_clips": _PATH_TO_CLIPS["dev"],
|
84 |
"audio_files": dl_manager.iter_archive(archive["dev"]),
|
85 |
+
"split_name": "validation"
|
86 |
}
|
87 |
),
|
88 |
SplitGenerator(
|
|
|
91 |
"prompts_path": prompts_path["train"],
|
92 |
"path_to_clips": _PATH_TO_CLIPS["train"],
|
93 |
"audio_files": dl_manager.iter_archive(archive["train"]),
|
94 |
+
"split_name": "train"
|
95 |
}
|
96 |
),
|
97 |
]
|
98 |
|
99 |
+
def _generate_examples(self, prompts_path, path_to_clips, audio_files, split_name):
|
100 |
+
print(f"\n{'='*50}")
|
101 |
+
print(f"Processing {split_name} split")
|
102 |
+
print(f"{'='*50}")
|
103 |
+
print(f"\nCSV Path: {prompts_path}")
|
104 |
+
print(f"Expected clips directory: {path_to_clips}")
|
105 |
|
106 |
examples = {}
|
|
|
107 |
csv_paths = []
|
108 |
|
109 |
+
# Read CSV file
|
110 |
+
print("\n=== Reading CSV ===")
|
111 |
with open(prompts_path, "r") as f:
|
112 |
csv_reader = csv.DictReader(f)
|
113 |
for row in csv_reader:
|
|
|
130 |
"speaker_id": row['speaker_id'],
|
131 |
}
|
132 |
csv_paths.append(file_path)
|
|
|
|
|
|
|
133 |
|
134 |
+
print(f"\nFound {len(csv_paths)} entries in CSV")
|
135 |
+
print("\nFirst 3 CSV paths:")
|
136 |
for path in csv_paths[:3]:
|
137 |
+
print(f" CSV path: {path}")
|
138 |
|
139 |
+
# Process archive
|
140 |
+
print("\n=== Processing Archive ===")
|
141 |
inside_clips_dir = False
|
142 |
id_ = 0
|
143 |
matched_files = 0
|
144 |
archive_paths = []
|
145 |
|
|
|
146 |
for path, f in audio_files:
|
147 |
path = Path(path).as_posix()
|
148 |
archive_paths.append(path)
|
|
|
154 |
matched_files += 1
|
155 |
yield id_, {**examples[path], "audio": audio}
|
156 |
id_ += 1
|
|
|
|
|
|
|
|
|
157 |
|
158 |
+
print("\n=== Path Analysis ===")
|
159 |
+
print("\nFirst 3 archive paths:")
|
|
|
160 |
for path in archive_paths[:3]:
|
161 |
+
print(f" Archive path: {path}")
|
162 |
|
163 |
+
# Try to find potential matches
|
164 |
+
print("\nPotential matches in CSV:")
|
165 |
+
for csv_path in csv_paths[:3]:
|
166 |
+
print(f"\nComparing:")
|
167 |
+
print(f" Archive: {path}")
|
168 |
+
print(f" CSV: {csv_path}")
|
169 |
+
print(f" Archive parts: {path.split('/')}")
|
170 |
+
print(f" CSV parts: {csv_path.split('/')}")
|
171 |
+
|
172 |
+
print(f"\n=== Summary for {split_name} split ===")
|
173 |
+
print(f"Total paths in CSV: {len(csv_paths)}")
|
174 |
+
print(f"Total paths found in archive: {len(archive_paths)}")
|
175 |
+
print(f"Successfully matched files: {matched_files}")
|
176 |
|
177 |
if matched_files == 0:
|
178 |
+
print("\n!!! MATCHING FAILED !!!")
|
179 |
+
print("No files were matched between CSV and archive")
|
180 |
+
print("\nTroubleshooting:")
|
181 |
+
print("1. Check if CSV paths start with the clip directory name")
|
182 |
+
print("2. Check for case sensitivity issues")
|
183 |
+
print("3. Check for extra/missing directory levels")
|
184 |
+
print("4. Check path separator consistency")
|