Datasets:
File size: 1,147 Bytes
e8a558c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#!/usr/bin/env python3
import json
def fix_root_paths():
"""Update metadata.jsonl to use root-level audio paths"""
input_file = "metadata.jsonl"
output_file = "metadata.jsonl"
records = []
# Read current metadata
with open(input_file, "r", encoding="utf-8") as f:
for line in f:
record = json.loads(line)
# Update path to remove data/ prefix
if record["file_name"].startswith("data/audio/"):
record["file_name"] = record["file_name"].replace("data/audio/", "audio/")
records.append(record)
# Write updated metadata
with open(output_file, "w", encoding="utf-8") as f:
for record in records:
f.write(json.dumps(record, ensure_ascii=False) + "\n")
print(f"Fixed {len(records)} audio paths in metadata.jsonl")
print("Updated paths to use root-level audio/ directory")
# Show first 3 records
print("\nFirst 3 records:")
for i, record in enumerate(records[:3], 1):
print(f"{i}. {json.dumps(record, ensure_ascii=False)}")
return records
if __name__ == "__main__":
fix_root_paths() |