code: def stream(
      path: Union[str, int, sf.SoundFile, BinaryIO],
      *,
      block_length: int,
      frame_length: int,
      hop_length: int,
      mono: bool = True,
      offset: float = 0.0,
      duration: Optional[float] = None,
      fill_value: Optional[float] = None,
      dtype: DTypeLike = np.float32,
  ) -> Generator[np.ndarray, None, None]:
      """Stream audio in fixed-length buffers.
  
      This is primarily useful for processing large files that won't
      fit entirely in memory at once.
  
      Instead of loading the entire audio signal into memory (as
      in `load`, this function produces *blocks* of audio spanning
      a fixed number of frames at a specified frame length and hop
      length.
  
      While this function strives for similar behavior to `load`,
      there are a few caveats that users should be aware of:
  
          1. This function does not return audio buffers directly.
             It returns a generator, which you can iterate over
             to produce blocks of audio.  A *block*, in this context,
             refers to a buffer of audio which spans a given number of
             (potentially overlapping) frames.
          2. Automatic sample-rate conversion is not supported.
             Audio will be streamed in its native sample rate,
             so no default values are provided for ``frame_length``
             and ``hop_length``.  It is recommended that you first
             get the sampling rate for the file in question, using
             `get_samplerate`, and set these parameters accordingly.
          3. Many analyses require access to the entire signal
             to behave correctly, such as `resample`, `cqt`, or
             `beat_track`, so these methods will not be appropriate
             for streamed data.
          4. The ``block_length`` parameter specifies how many frames
             of audio will be produced per block.  Larger values will
             consume more memory, but will be more efficient to process
             down-stream.  The best value will ultimately depend on your
             application and other system constraints.
          5. By default, most librosa analyses (e.g., short-time Fourier
             transform) assume centered frames, which requires padding the
             signal at the beginning and end.  This will not work correctly
             when the signal is carved into blocks, because it would introduce
             padding in the middle of the signal.  To disable this feature,
             use ``center=False`` in all frame-based analyses.
  
      See the examples below for proper usage of this function.
  
      Parameters
      ----------
      path : string, int, sf.SoundFile, or file-like object
          path to the input file to stream.
  
          Any codec supported by `soundfile` is permitted here.
  
          An existing `soundfile.SoundFile` object may also be provided.
  
      block_length : int > 0
          The number of frames to include in each block.
  
          Note that at the end of the file, there may not be enough
          data to fill an entire block, resulting in a shorter block
          by default.  To pad the signal out so that blocks are always
          full length, set ``fill_value`` (see below).
  
      frame_length : int > 0
          The number of samples per frame.
  
      hop_length : int > 0
          The number of samples to advance between frames.
  
          Note that by when ``hop_length < frame_length``, neighboring frames
          will overlap.  Similarly, the last frame of one *block* will overlap
          with the first frame of the next *block*.
  
      mono : bool
          Convert the signal to mono during streaming
  
      offset : float
          Start reading after this time (in seconds)
  
      duration : float
          Only load up to this much audio (in seconds)
  
      fill_value : float [optional]
          If padding the signal to produce constant-length blocks,
          this value will be used at the end of the signal.
  
          In most cases, ``fill_value=0`` (silence) is expected, but
          you may specify any value here.
  
      dtype : numeric type
          data type of audio buffers to be produced
  
      Yields
      ------
      y : np.ndarray
          An audio buffer of (at most)
          ``(block_length-1) * hop_length + frame_length`` samples.
  
      See Also
      --------
      load
      get_samplerate
      soundfile.blocks
  
      Examples
      --------
      Apply a short-term Fourier transform to blocks of 256 frames
      at a time.  Note that streaming operation requires left-aligned
      frames, so we must set ``center=False`` to avoid padding artifacts.
  
      >>> filename = librosa.ex('brahms')
      >>> sr = librosa.get_samplerate(filename)
      >>> stream = librosa.stream(filename,
      ...                       block_length=256,
      ...                       frame_length=4096,
      ...                       hop_length=1024)
      >>> for y_block in stream:
      ...     D_block = librosa.stft(y_block, center=False)
  
      Or compute a mel spectrogram over a stream, using a shorter frame
      and non-overlapping windows
  
      >>> filename = librosa.ex('brahms')
      >>> sr = librosa.get_samplerate(filename)
      >>> stream = librosa.stream(filename,
      ...                         block_length=256,
      ...                         frame_length=2048,
      ...                         hop_length=2048)
      >>> for y_block in stream:
      ...     m_block = librosa.feature.melspectrogram(y=y_block, sr=sr,
      ...                                              n_fft=2048,
      ...                                              hop_length=2048,
      ...                                              center=False)
      """
      if not util.is_positive_int(block_length):
          raise ParameterError(
              f"block_length={block_length} must be a positive integer"
          )
      if not util.is_positive_int(frame_length):
          raise ParameterError(
              f"frame_length={frame_length} must be a positive integer"
          )
      if not util.is_positive_int(hop_length):
          raise ParameterError(
              f"hop_length={hop_length} must be a positive integer"
          )
  
      if isinstance(path, sf.SoundFile):
          sfo = path
      else:
          sfo = sf.SoundFile(path)
  
      # Get the sample rate from the file info
      sr = sfo.samplerate
  
      # Construct the stream
      if offset:
          start = int(offset * sr)
      else:
          start = 0
  
      if duration:
          frames = int(duration * sr)
      else:
          frames = -1
  
      # Seek the soundfile object to the starting frame
      sfo.seek(start)
  
      blocks = sfo.blocks(
          blocksize=frame_length + (block_length - 1) * hop_length,
          overlap=frame_length - hop_length,
          frames=frames,
          dtype=dtype,
          always_2d=False,
          fill_value=fill_value,
      )
  
      for block in blocks:
          if mono:
              yield to_mono(block.T)
          else:
              yield block.T
  
imports: from __future__ import annotations
  import os
  import pathlib
  import warnings
  import soundfile
  import audioread
  import numpy
  import scipy.signal
  import soxr
  import lazy_loader
  from numba import jit, stencil, guvectorize
  from .fft import get_fftlib
  from .convert import frames_to_samples, time_to_samples
  from .._cache import cache
  from ..None import util
  from ..util.exceptions import ParameterError
  from ..util.decorators import deprecated
  from ..util.deprecation import Deprecated, rename_kw
  from .._typing import _FloatLike_co, _IntLike_co, _SequenceLike
  from typing import Any, BinaryIO, Callable, Generator, Optional, Tuple, Union, List
  from numpy.typing import DTypeLike, ArrayLike
label_desc: Use image node_id 4 for calling a global function with example usage: stream(path) without return types