| import os |
| import csv |
| import re |
|
|
| REC_ROOT = "audio/recorded" |
| CLEAN_ROOT = "audio/clean" |
| ASR_DIR = "annotations/asr_label" |
| VAD_DIR = "annotations/speaker_activity" |
|
|
| rows = [] |
|
|
| for location in sorted(os.listdir(REC_ROOT)): |
| loc_dir = os.path.join(REC_ROOT, location) |
| if not os.path.isdir(loc_dir): |
| continue |
|
|
| for wav in sorted(os.listdir(loc_dir)): |
| if not wav.endswith(".wav"): |
| continue |
|
|
| |
| |
|
|
| |
| m = re.match(r"^(doa_[^_]+)_(session-.*)\.wav$", wav) |
| if not m: |
| continue |
|
|
| session_key = m.group(2) |
| recorded_path = f"{REC_ROOT}/{location}/{wav}" |
|
|
| |
| for spk_id in ["spk0", "spk1", "spk2"]: |
| clean_filename = f"{session_key}_{spk_id}_clean.wav" |
| clean_path = f"{CLEAN_ROOT}/{clean_filename}" |
|
|
| if not os.path.exists(clean_path): |
| continue |
|
|
| asr_filename = f"{session_key}_{spk_id}_label.txt" |
| asr_path = f"{ASR_DIR}/{asr_filename}" |
|
|
| vad_filename = f"{session_key}_{spk_id}_clean.txt" |
| vad_path = f"{VAD_DIR}/{vad_filename}" |
|
|
| if not os.path.exists(asr_path): |
| continue |
|
|
| sample_id = f"{location}_{session_key}_{spk_id}" |
|
|
| rows.append([ |
| sample_id, |
| location, |
| session_key, |
| spk_id, |
| recorded_path, |
| clean_path, |
| asr_path, |
| vad_path |
| ]) |
|
|
| with open("test.csv", "w", newline="") as f: |
| writer = csv.writer(f) |
| writer.writerow([ |
| "id", |
| "location", |
| "session_key", |
| "speaker_id", |
| "recorded_path", |
| "clean_path", |
| "asr_label_path", |
| "speaker_activity_path" |
| ]) |
| writer.writerows(rows) |
|
|
| print("Generated test.csv with", len(rows), "rows") |
|
|