Datasets:
Update NURC-SP_ENTOA_TTS.py
Browse files- NURC-SP_ENTOA_TTS.py +32 -6
NURC-SP_ENTOA_TTS.py
CHANGED
|
@@ -2,6 +2,7 @@ import csv
|
|
| 2 |
import datasets
|
| 3 |
from datasets import BuilderConfig, GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split
|
| 4 |
import logging
|
|
|
|
| 5 |
|
| 6 |
# Set up logging
|
| 7 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -103,13 +104,17 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
| 103 |
examples = {}
|
| 104 |
example_count = 0
|
| 105 |
|
| 106 |
-
# Read CSV file
|
|
|
|
| 107 |
with open(prompts_path, "r") as f:
|
| 108 |
csv_reader = csv.DictReader(f)
|
| 109 |
-
for row in csv_reader:
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
"audio_name": row['audio_name'],
|
| 112 |
-
"file_path":
|
| 113 |
"text": row['text'],
|
| 114 |
"start_time": row['start_time'],
|
| 115 |
"end_time": row['end_time'],
|
|
@@ -125,15 +130,25 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
| 125 |
"speaker_id": row['speaker_id'],
|
| 126 |
}
|
| 127 |
example_count += 1
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
logger.info(f"Found {example_count} examples in CSV")
|
| 130 |
|
| 131 |
inside_clips_dir = False
|
| 132 |
id_ = 0
|
| 133 |
matched_files = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
for path, f in audio_files:
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
| 137 |
if path.startswith(path_to_clips):
|
| 138 |
inside_clips_dir = True
|
| 139 |
logger.debug(f"Found file in clips directory: {path}")
|
|
@@ -142,9 +157,20 @@ class NurcSPDataset(GeneratorBasedBuilder):
|
|
| 142 |
matched_files += 1
|
| 143 |
yield id_, {**examples[path], "audio": audio}
|
| 144 |
id_ += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
elif inside_clips_dir:
|
| 146 |
break
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
logger.info(f"Matched {matched_files} audio files with CSV entries")
|
| 149 |
if matched_files == 0:
|
| 150 |
-
logger.warning("No audio files were matched with CSV entries!")
|
|
|
|
|
|
| 2 |
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)
|
|
|
|
| 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,
|
| 118 |
"text": row['text'],
|
| 119 |
"start_time": row['start_time'],
|
| 120 |
"end_time": row['end_time'],
|
|
|
|
| 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}")
|
|
|
|
| 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.")
|