#!/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()