def METHOD_NAME(
    target_dir: str,
    cache_dir: str,
    dataset_root: str,
    get_path_only: bool = False,
):
    target_dir: Path = Path(target_dir)
    train_csv = target_dir / "train.csv"
    valid_csv = target_dir / "valid.csv"
    test_csv = target_dir / "test.csv"
    if get_path_only:
        return train_csv, valid_csv, [test_csv]
    resample_hear_corpus(dataset_root, target_sr=16000)
    dataset_root = Path(dataset_root)
    wav_root: Path = dataset_root / "16000"
    def json_to_csv(json_path: str, csv_path: str, split: str):
        with open(json_path) as fp:
            metadata = json.load(fp)
        data = defaultdict(list)
        for utt in metadata:
            wav_path: Path = (wav_root / split / utt).resolve()
            assert wav_path.is_file()
            info = torchaudio.info(wav_path)
            baseinfo = {
                "record_id": utt,
                "wav_path": str(wav_path),
                "duration": info.num_frames / info.sample_rate,
            }
            for segment in metadata[utt]:
                fullinfo = deepcopy(baseinfo)
                fullinfo[
                    "utt_id"
                ] = f"{baseinfo['record_id']}-{int(segment['start'])}-{int(segment['end'])}"
                fullinfo["labels"] = segment["label"]
                fullinfo["start_sec"] = segment["start"] / 1000
                fullinfo["end_sec"] = segment["end"] / 1000
                for key, value in fullinfo.items():
                    data[key].append(value)
        pd.DataFrame(data=data).to_csv(csv_path, index=False)
    json_to_csv(dataset_root / "train.json", train_csv, "train")
    json_to_csv(dataset_root / "valid.json", valid_csv, "valid")
    json_to_csv(dataset_root / "test.json", test_csv, "test")
    return train_csv, valid_csv, [test_csv]