huggingface/transformers · error · ValueError
min_value must be greater than zero
Error message
min_value must be greater than zero
What it means
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.
Source
Thrown at src/transformers/audio_utils.py:1267
spectrogram (`np.ndarray`):
The input power (mel) spectrogram. Note that a power spectrogram has the amplitudes squared!
reference (`float`, *optional*, defaults to 1.0):
Sets the input spectrogram value that corresponds to 0 dB. For example, use `np.max(spectrogram)` to set
the loudest part to 0 dB. Must be greater than zero.
min_value (`float`, *optional*, defaults to `1e-10`):
The spectrogram will be clipped to this minimum value before conversion to decibels, to avoid taking
`log(0)`. The default of `1e-10` corresponds to a minimum of -100 dB. Must be greater than zero.
db_range (`float`, *optional*):
Sets the maximum dynamic range in decibels. For example, if `db_range = 80`, the difference between the
peak value and the smallest value will never be more than 80 dB. Must be greater than zero.
Returns:
`np.ndarray`: the spectrogram in decibels
"""
if reference <= 0.0:
raise ValueError("reference must be greater than zero")
if min_value <= 0.0:
raise ValueError("min_value must be greater than zero")
reference = max(min_value, reference)
spectrogram = np.clip(spectrogram, a_min=min_value, a_max=None)
spectrogram = 10.0 * (np.log10(spectrogram) - np.log10(reference))
if db_range is not None:
if db_range <= 0.0:
raise ValueError("db_range must be greater than zero")
spectrogram = np.clip(spectrogram, a_min=spectrogram.max() - db_range, a_max=None)
return spectrogram
def power_to_db_batch(
spectrogram: np.ndarray,
reference: float = 1.0,
min_value: float = 1e-10,View on GitHub (pinned to a597f97485)
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
Example fix
// before db = power_to_db(spec, min_value=0.0) // after db = power_to_db(spec, min_value=1e-12)
Defensive patterns
Strategy: validation
Validate before calling
min_value = min_value if min_value and min_value > 0 else 1e-10 db = power_to_db(spec, min_value=min_value)
Type guard
def is_positive_floor(min_value) -> bool:
return isinstance(min_value, (int, float)) and min_value > 0.0 Try / catch
try:
db = power_to_db(spec, min_value=min_value)
except ValueError as e:
if "min_value must be greater than zero" in str(e):
db = power_to_db(spec) # default floor 1e-10
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- reference must be greater than zero
- db_range must be greater than zero
- Unexpected fields in the request: {unexpected}
- PUSH_TO_HUB_TOKEN is not set, cannot push results to the Hub
- Invalid input type. Must be a single audio or a list of audi
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/04d39ec7f3205f7a.
Report an issue: GitHub.