{"record":{"id":"01d135a2ba696a2e","repo":"huggingface/transformers","slug":"unknown-window-function-name","errorCode":null,"errorMessage":"Unknown window function '{name}'","messagePattern":"Unknown window function '(.+?)'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/audio_utils.py","lineNumber":789,"sourceCode":"            than the frame length, so that it will be zero-padded.\n        center (`bool`, *optional*, defaults to `True`):\n            Whether to center the window inside the FFT buffer. Only used when `frame_length` is provided.\n\n    Returns:\n        `np.ndarray` of shape `(window_length,)` or `(frame_length,)` containing the window.\n    \"\"\"\n    length = window_length + 1 if periodic else window_length\n\n    if name == \"boxcar\":\n        window = np.ones(length)\n    elif name in [\"hamming\", \"hamming_window\"]:\n        window = np.hamming(length)\n    elif name in [\"hann\", \"hann_window\"]:\n        window = np.hanning(length)\n    elif name == \"povey\":\n        window = np.power(np.hanning(length), 0.85)\n    else:\n        raise ValueError(f\"Unknown window function '{name}'\")\n\n    if periodic:\n        window = window[:-1]\n\n    if frame_length is None:\n        return window\n\n    if window_length > frame_length:\n        raise ValueError(\n            f\"Length of the window ({window_length}) may not be larger than frame_length ({frame_length})\"\n        )\n\n    padded_window = np.zeros(frame_length)\n    offset = (frame_length - window_length) // 2 if center else 0\n    padded_window[offset : offset + window_length] = window\n    return padded_window\n\n","sourceCodeStart":771,"sourceCodeEnd":807,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/audio_utils.py#L771-L807","documentation":"Thrown by `window_function` when `name` is not one of the supported window types: \"boxcar\", \"hamming\" (or \"hamming_window\"), \"hann\" (or \"hann_window\"), or \"povey\". The function builds the window with the matching numpy routine; an unknown name has no implementation and the explicit raise prevents falling through to an undefined window.","triggerScenarios":"Calling `window_function(length, name=...)` with values like \"blackman\", \"kaldi\" (not a window name), \"Hann\" (capitalized), or a torchaudio/torch window enum. Also hit indirectly when a feature extractor passes a window name from its config, e.g. Whisper-style \"hann\" works but Kaldi-VAD or custom names fail.","commonSituations":"Porting Kaldi/torchaudio recipes that use windows transformers does not implement (e.g. \"blackman\"); config files with capitalized or suffixed names like \"hann_window\" (the latter is accepted) vs \"hann_povey\" (not); typos.","solutions":["Use one of: \"boxcar\", \"hamming\", \"hamming_window\", \"hann\", \"hann_window\", \"povey\"","If you need another window (e.g. blackman), compute it directly with numpy (np.blackman) and pass the array as `window` to `spectrogram`","Check the feature extractor config that supplies the window name for typos/casing"],"exampleFix":"// before\nwindow = window_function(400, name=\"blackman\")  # ValueError\n\n// after\nwindow = np.blackman(400)  # pass array directly to spectrogram()\n# or use a supported name:\nwindow = window_function(400, name=\"hann\")","handlingStrategy":"validation","validationCode":"SUPPORTED_WINDOWS = {\"boxcar\", \"hamming\", \"hamming_window\", \"hann\", \"hann_window\", \"povey\"}\nif name not in SUPPORTED_WINDOWS:\n    raise ValueError(f\"Unsupported window {name!r}; supported: {sorted(SUPPORTED_WINDOWS)}\")\nwindow = window_function(400, name=name)","typeGuard":"def is_supported_window(name: str) -> bool:\n    return isinstance(name, str) and name in {\"boxcar\", \"hamming\", \"hamming_window\", \"hann\", \"hann_window\", \"povey\"}","tryCatchPattern":"try:\n    window = window_function(length, name=name)\nexcept ValueError as e:\n    if \"Unknown window function\" in str(e):\n        import numpy as np\n        window = getattr(np, name, None)  # fallback: numpy window directly\n        if window is None:\n            raise\n    else:\n        raise","preventionTips":["Check the supported window list in the docstring before adding a config key","For exotic windows compute them with numpy and pass the array straight to spectrogram","Beware casing: names are lowercase"],"tags":["audio","stft","argument-validation"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}