Datasets:
Download example.py from NCSOFT/Designed-Vocalizations-Dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/datasets/NCSOFT/Designed-Vocalizations-Dataset/resolve/main/example.py
- Command line
-
hf download hf://datasets/NCSOFT/Designed-Vocalizations-Dataset/example.py
-
curl -L -o example.py https://huggingface.co/datasets/NCSOFT/Designed-Vocalizations-Dataset/resolve/main/example.py
2.46 kB
| """ | |
| Example usage for the Designed Vocalizations Dataset. | |
| pip install "datasets<4" | |
| python example.py | |
| Two configs — `raw` (source recordings) and `designed` (effect-processed clips) — | |
| each with a `train` and `test` split. | |
| TRAIN non-parallel: the raw and designed train pools are not aligned. | |
| TEST parallel: evaluate the (source -> reference) pairs listed in | |
| metadata/test_pairs.csv, each with a seen/unseen condition. | |
| """ | |
| import csv | |
| from itertools import islice | |
| from datasets import load_dataset | |
| from huggingface_hub import hf_hub_download | |
| REPO = "NCSOFT/Designed-Vocalizations-Dataset" | |
| # ------------------------------------------------------------------- TRAIN | |
| # Non-parallel: two independent pools, no pairing between them. | |
| raw_train = load_dataset(REPO, "raw", split="train") # 5,654 sources | |
| print(f"train: {len(raw_train)} raw sources") | |
| # streamed just to keep this example light (drop streaming=True to load fully) | |
| designed_train = load_dataset(REPO, "designed", split="train", streaming=True) | |
| clip = next(iter(designed_train)) | |
| wav, sr = clip["audio"]["array"], clip["audio"]["sampling_rate"] # numpy waveform, 44100 Hz | |
| print(f" designed (streamed): {clip['file_path']} | preset {clip['preset']}") | |
| # -------------------------------------------------------------------- TEST | |
| # Parallel: pair each source with its reference. Stream so only the test shards | |
| # are fetched (test shares a config with the large designed/train split). | |
| sources = load_dataset(REPO, "raw", split="test", streaming=True) # 120 inputs | |
| references = load_dataset(REPO, "designed", split="test", streaming=True) # 5,640 refs | |
| # the 120 sources are small — collect them for lookup by file_path | |
| source_by_path = {clip["file_path"]: clip for clip in sources} | |
| # seen/unseen condition per reference (from metadata/test_pairs.csv) | |
| pairs_csv = hf_hub_download(REPO, "metadata/test_pairs.csv", repo_type="dataset") | |
| seen_split = {row["reference"]: row["seen_split"] | |
| for row in csv.DictReader(open(pairs_csv, encoding="utf-8"))} | |
| for reference in islice(references, 3): | |
| source = source_by_path[reference["source"]] # `source` column = paired input | |
| src_wav = source["audio"]["array"] | |
| ref_wav = reference["audio"]["array"] | |
| print(f" [{seen_split[reference['file_path']]}] " | |
| f"{reference['source']} -> {reference['file_path']}") | |
| # ... compute your voice-conversion metric between src_wav and ref_wav ... | |