deezer/spleeter · error · ValueError

F is too large and must be set to at most frame_length/2+1.

Error message

F is too large and must be set to at most frame_length/2+1. Decrease F or increase frame_length to fix.

What it means

`SpleeterDataset.check_parameters_compatibility` validates STFT hyperparameters at construction time. The frequency-bin count F must satisfy `frame_length/2 + 1 >= F`; otherwise a `ValueError` is raised, since the STFT of `frame_length` cannot produce more frequency bins than that.

Source

Thrown at spleeter/dataset.py:299

        self._F = audio_params["F"]
        self._sample_rate = audio_params["sample_rate"]
        self._frame_length = audio_params["frame_length"]
        self._frame_step = audio_params["frame_step"]
        self._mix_name = audio_params["mix_name"]
        self._n_channels = audio_params["n_channels"]
        self._instruments = [self._mix_name] + audio_params["instrument_list"]
        self._instrument_builders: Optional[List] = None
        self._chunk_duration = chunk_duration
        self._audio_adapter = audio_adapter
        self._audio_params = audio_params
        self._audio_path = audio_path
        self._random_seed = random_seed

        self.check_parameters_compatibility()

    def check_parameters_compatibility(self):
        if self._frame_length / 2 + 1 < self._F:
            raise ValueError(
                "F is too large and must be set to at most frame_length/2+1. "
                "Decrease F or increase frame_length to fix."
            )

        if (
            self._chunk_duration * self._sample_rate - self._frame_length
        ) / self._frame_step < self._T:
            raise ValueError(
                "T is too large considering STFT parameters and chunk duratoin. "
                "Make sure spectrogram time dimension of chunks is larger than T "
                "(for instance reducing T or frame_step or increasing chunk duration)."
            )

    def expand_path(self, sample: Dict) -> Dict:
        """Expands audio paths for the given sample."""
        return dict(
            sample,
            **{

View on GitHub (pinned to c8854001ac)

Solutions

  1. Lower F to at most `frame_length // 2 + 1`
  2. Or increase `frame_length` so that `frame_length // 2 + 1 >= F`
  3. Re-run training after making F and frame_length consistent

Example fix

// before
SpleeterDataset(frame_length=512, F=1025, ...)
// after
SpleeterDataset(frame_length=2048, F=1025, ...)  # 2048/2+1 = 1025 >= F
Defensive patterns

Strategy: validation

Validate before calling

def validate_stft_f(frame_length: int, F: int):
    if frame_length / 2 + 1 < F:
        raise ValueError(f'F must be <= frame_length/2+1 (got F={F}, frame_length={frame_length})')
validate_stft_f(frame_length=2048, F=1025)

Try / catch

try:
    dataset = SpleeterDataset(frame_length=frame_length, F=F, ...)
except ValueError as e:
    if 'F is too large' in str(e):
        F = frame_length // 2 + 1
        dataset = SpleeterDataset(frame_length=frame_length, F=F, ...)
    else:
        raise

Prevention

When it happens

Trigger: Constructing `SpleeterDataset(...)` (via its `__init__`) with an `F` parameter greater than `frame_length // 2 + 1` — e.g. F=1025 with frame_length=512.

Common situations: Tuning spectrogram/model parameters by hand in a training config copied between models with different frame sizes, mixing parameter sets from different experiments.

Related errors


AI-assisted analysis of deezer/spleeter@c8854001ac (2026-08-28). Data as JSON: /api/errors/fb5c9df2bc7240a2. Report an issue: GitHub.