Datasets:
| #!/usr/bin/env python3 | |
| import json | |
| from pathlib import Path | |
| def fix_metadata_format(): | |
| """Fix metadata.jsonl to use file_name column for HF audio datasets""" | |
| input_file = "data/metadata.jsonl" | |
| output_file = "data/metadata.jsonl" | |
| records = [] | |
| # Read current metadata | |
| with open(input_file, "r", encoding="utf-8") as f: | |
| for line in f: | |
| old_record = json.loads(line) | |
| # Create new record with file_name column | |
| record = { | |
| "file_name": old_record["audio"], # audio path becomes file_name | |
| "word": old_record["word"], | |
| "ipa": old_record["ipa"] | |
| } | |
| 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)} records in metadata.jsonl") | |
| print("Updated format to use file_name column for HF audio datasets") | |
| # 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_metadata_format() |