Skip to content

fix(dataset): UnboundLocalError in CustomDatasetPath (preprocessed_mel) - #1338

Closed
rudycelekli wants to merge 1 commit into
SWivid:mainfrom
rudycelekli:fix/customdatasetpath-unbound-mel
Closed

rudycelekli wants to merge 1 commit into
SWivid:mainfrom
rudycelekli:fix/customdatasetpath-unbound-mel

Conversation

@rudycelekli

Copy link
Copy Markdown

Problem

load_dataset(..., dataset_type="CustomDatasetPath") — a documented option (docstring: "CustomDatasetPath if you just want to pass the full path to a preprocessed dataset") — raises UnboundLocalError immediately:

elif dataset_type == "CustomDatasetPath":
    try:
        train_dataset = load_from_disk(f"{dataset_name}/raw")
    except:
        train_dataset = Dataset_.from_file(f"{dataset_name}/raw.arrow")
    ...
    train_dataset = CustomDataset(
        train_dataset, durations=durations, preprocessed_mel=preprocessed_mel, **mel_spec_kwargs
    )   # UnboundLocalError: preprocessed_mel

preprocessed_mel is only assigned inside the "CustomDataset" branch (as False/True depending on audio_type). In the CustomDatasetPath branch it's never set, so the whole option is dead — UnboundLocalError: cannot access local variable 'preprocessed_mel'.

Fix

This branch loads raw audio, so set preprocessed_mel = False before constructing CustomDataset.

load_dataset(dataset_type="CustomDatasetPath") -- a documented option for passing a
full path to a preprocessed dataset -- passed preprocessed_mel=preprocessed_mel to
CustomDataset, but that name is only assigned in the "CustomDataset" branch. So the
CustomDatasetPath path raised UnboundLocalError and was unusable. It loads raw audio,
so set preprocessed_mel = False.
@SWivid SWivid closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants