{"record":{"id":"04d39ec7f3205f7a","repo":"huggingface/transformers","slug":"min-value-must-be-greater-than-zero","errorCode":null,"errorMessage":"min_value must be greater than zero","messagePattern":"min_value must be greater than zero","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/audio_utils.py","lineNumber":1267,"sourceCode":"        spectrogram (`np.ndarray`):\n            The input power (mel) spectrogram. Note that a power spectrogram has the amplitudes squared!\n        reference (`float`, *optional*, defaults to 1.0):\n            Sets the input spectrogram value that corresponds to 0 dB. For example, use `np.max(spectrogram)` to set\n            the loudest part to 0 dB. Must be greater than zero.\n        min_value (`float`, *optional*, defaults to `1e-10`):\n            The spectrogram will be clipped to this minimum value before conversion to decibels, to avoid taking\n            `log(0)`. The default of `1e-10` corresponds to a minimum of -100 dB. Must be greater than zero.\n        db_range (`float`, *optional*):\n            Sets the maximum dynamic range in decibels. For example, if `db_range = 80`, the difference between the\n            peak value and the smallest value will never be more than 80 dB. Must be greater than zero.\n\n    Returns:\n        `np.ndarray`: the spectrogram in decibels\n    \"\"\"\n    if reference <= 0.0:\n        raise ValueError(\"reference must be greater than zero\")\n    if min_value <= 0.0:\n        raise ValueError(\"min_value must be greater than zero\")\n\n    reference = max(min_value, reference)\n\n    spectrogram = np.clip(spectrogram, a_min=min_value, a_max=None)\n    spectrogram = 10.0 * (np.log10(spectrogram) - np.log10(reference))\n\n    if db_range is not None:\n        if db_range <= 0.0:\n            raise ValueError(\"db_range must be greater than zero\")\n        spectrogram = np.clip(spectrogram, a_min=spectrogram.max() - db_range, a_max=None)\n\n    return spectrogram\n\n\ndef power_to_db_batch(\n    spectrogram: np.ndarray,\n    reference: float = 1.0,\n    min_value: float = 1e-10,","sourceCodeStart":1249,"sourceCodeEnd":1285,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/audio_utils.py#L1249-L1285","documentation":"Raised at the top of transformers.audio_utils.power_to_db when min_value <= 0.0. min_value is used as the clip floor before log10 (np.clip(spectrogram, a_min=min_value)) to avoid log(0); a non-positive floor would leave zeros/negatives in the array and produce -inf/NaN dB values, so it is rejected.","triggerScenarios":"Calling power_to_db(spec, min_value=0.0) or a negative value; happens when someone 'disables' the floor by setting 0, or when min_value is loaded from a config that stored 0/-1 as a placeholder.","commonSituations":"Trying to get an unclipped dB trace by setting min_value=0; copying settings between power_to_db (default 1e-10) and amplitude_to_db (default 1e-5) and zeroing the wrong field; configs generated with placeholder zeros.","solutions":["Keep min_value strictly positive; the default 1e-10 corresponds to a -100 dB floor","To make the floor negligible, use a tiny positive value like 1e-12 instead of 0","Validate serialized configs at load time and rewrite non-positive min_value to the default"],"exampleFix":"// before\ndb = power_to_db(spec, min_value=0.0)\n// after\ndb = power_to_db(spec, min_value=1e-12)","handlingStrategy":"validation","validationCode":"min_value = min_value if min_value and min_value > 0 else 1e-10\ndb = power_to_db(spec, min_value=min_value)","typeGuard":"def is_positive_floor(min_value) -> bool:\n    return isinstance(min_value, (int, float)) and min_value > 0.0","tryCatchPattern":"try:\n    db = power_to_db(spec, min_value=min_value)\nexcept ValueError as e:\n    if \"min_value must be greater than zero\" in str(e):\n        db = power_to_db(spec)  # default floor 1e-10\n    else:\n        raise","preventionTips":["Keep the floor positive; to deepen it use 1e-12 rather than 0","Remember domain defaults: power variants 1e-10, amplitude variants 1e-5","Schema-validate feature-extractor configs before use"],"tags":["audio","validation","decibels","numerical"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}