code: def mel(
      *,
      sr: float,
      n_fft: int,
      n_mels: int = 128,
      fmin: float = 0.0,
      fmax: Optional[float] = None,
      htk: bool = False,
      norm: Optional[Union[Literal["slaney"], float]] = "slaney",
      dtype: DTypeLike = np.float32,
  ) -> np.ndarray:
      """Create a Mel filter-bank.
  
      This produces a linear transformation matrix to project
      FFT bins onto Mel-frequency bins.
  
      Parameters
      ----------
      sr : number > 0 [scalar]
          sampling rate of the incoming signal
  
      n_fft : int > 0 [scalar]
          number of FFT components
  
      n_mels : int > 0 [scalar]
          number of Mel bands to generate
  
      fmin : float >= 0 [scalar]
          lowest frequency (in Hz)
  
      fmax : float >= 0 [scalar]
          highest frequency (in Hz).
          If `None`, use ``fmax = sr / 2.0``
  
      htk : bool [scalar]
          use HTK formula instead of Slaney
  
      norm : {None, 'slaney', or number} [scalar]
          If 'slaney', divide the triangular mel weights by the width of the mel band
          (area normalization).
  
          If numeric, use `librosa.util.normalize` to normalize each filter by to unit l_p norm.
          See `librosa.util.normalize` for a full description of supported norm values
          (including `+-np.inf`).
  
          Otherwise, leave all the triangles aiming for a peak value of 1.0
  
      dtype : np.dtype
          The data type of the output basis.
          By default, uses 32-bit (single-precision) floating point.
  
      Returns
      -------
      M : np.ndarray [shape=(n_mels, 1 + n_fft/2)]
          Mel transform matrix
  
      See Also
      --------
      librosa.util.normalize
  
      Notes
      -----
      This function caches at level 10.
  
      Examples
      --------
      >>> melfb = librosa.filters.mel(sr=22050, n_fft=2048)
      >>> melfb
      array([[ 0.   ,  0.016, ...,  0.   ,  0.   ],
             [ 0.   ,  0.   , ...,  0.   ,  0.   ],
             ...,
             [ 0.   ,  0.   , ...,  0.   ,  0.   ],
             [ 0.   ,  0.   , ...,  0.   ,  0.   ]])
  
      Clip the maximum frequency to 8KHz
  
      >>> librosa.filters.mel(sr=22050, n_fft=2048, fmax=8000)
      array([[ 0.  ,  0.02, ...,  0.  ,  0.  ],
             [ 0.  ,  0.  , ...,  0.  ,  0.  ],
             ...,
             [ 0.  ,  0.  , ...,  0.  ,  0.  ],
             [ 0.  ,  0.  , ...,  0.  ,  0.  ]])
  
      >>> import matplotlib.pyplot as plt
      >>> fig, ax = plt.subplots()
      >>> img = librosa.display.specshow(melfb, x_axis='linear', ax=ax)
      >>> ax.set(ylabel='Mel filter', title='Mel filter bank')
      >>> fig.colorbar(img, ax=ax)
      """
      if fmax is None:
          fmax = float(sr) / 2
  
      # Initialize the weights
      n_mels = int(n_mels)
      weights = np.zeros((n_mels, int(1 + n_fft // 2)), dtype=dtype)
  
      # Center freqs of each FFT bin
      fftfreqs = fft_frequencies(sr=sr, n_fft=n_fft)
  
      # 'Center freqs' of mel bands - uniformly spaced between limits
      mel_f = mel_frequencies(n_mels + 2, fmin=fmin, fmax=fmax, htk=htk)
  
      fdiff = np.diff(mel_f)
      ramps = np.subtract.outer(mel_f, fftfreqs)
  
      for i in range(n_mels):
          # lower and upper slopes for all bins
          lower = -ramps[i] / fdiff[i]
          upper = ramps[i + 2] / fdiff[i + 1]
  
          # .. then intersect them with each other and zero
          weights[i] = np.maximum(0, np.minimum(lower, upper))
  
      if isinstance(norm, str):
          if norm == "slaney":
              # Slaney-style mel is scaled to be approx constant energy per channel
              enorm = 2.0 / (mel_f[2 : n_mels + 2] - mel_f[:n_mels])
              weights *= enorm[:, np.newaxis]
          else:
              raise ParameterError(f"Unsupported norm={norm}")
      else:
          weights = util.normalize(weights, norm=norm, axis=-1)
  
      # Only check weights if f_mel[0] is positive
      if not np.all((mel_f[:-2] == 0) | (weights.max(axis=1) > 0)):
          # This means we have an empty channel somewhere
          warnings.warn(
              "Empty filters detected in mel frequency basis. "
              "Some channels will produce empty responses. "
              "Try increasing your sampling rate (and fmax) or "
              "reducing n_mels.",
              stacklevel=2,
          )
  
      return weights
  
imports: import warnings
  import numpy
  import scipy
  import scipy.signal
  import scipy.ndimage
  from numba import jit
  from ._cache import cache
  from .None import util
  from .util.exceptions import ParameterError
  from .util.decorators import deprecated
  from .core.convert import note_to_hz, hz_to_midi, midi_to_hz, hz_to_octs
  from .core.convert import fft_frequencies, mel_frequencies
  from numpy.typing import ArrayLike, DTypeLike
  from typing import Any, List, Optional, Tuple, Union
  from typing_extensions import Literal
  from ._typing import _WindowSpec, _FloatLike_co
label_desc: Use image node_id 1 for calling a global function with example usage: mel() and returns: weights