Bases: MediaIO[tuple[NDArray, float]]
  Source code in vllm/multimodal/audio.py
 |  | class AudioMediaIO(MediaIO[tuple[npt.NDArray, float]]):
    def __init__(self, **kwargs) -> None:
        super().__init__()
        # `kwargs` contains custom arguments from
        # --media-io-kwargs for this modality.
        # They can be passed to the underlying
        # media loaders (e.g. custom implementations)
        # for flexible control.
        self.kwargs = kwargs
    def load_bytes(self, data: bytes) -> tuple[npt.NDArray, float]:
        return librosa.load(BytesIO(data), sr=None)
    def load_base64(
        self,
        media_type: str,
        data: str,
    ) -> tuple[npt.NDArray, float]:
        return self.load_bytes(base64.b64decode(data))
    def load_file(self, filepath: Path) -> tuple[npt.NDArray, float]:
        return librosa.load(filepath, sr=None)
    def encode_base64(self, media: tuple[npt.NDArray, int]) -> str:
        audio, sr = media
        with BytesIO() as buffer:
            soundfile.write(buffer, audio, sr, format="WAV")
            data = buffer.getvalue()
        return base64.b64encode(data).decode("utf-8")
 | 
      __init__(**kwargs) -> None
  Source code in vllm/multimodal/audio.py
 |  | def __init__(self, **kwargs) -> None:
    super().__init__()
    # `kwargs` contains custom arguments from
    # --media-io-kwargs for this modality.
    # They can be passed to the underlying
    # media loaders (e.g. custom implementations)
    # for flexible control.
    self.kwargs = kwargs
 | 
           Source code in vllm/multimodal/audio.py
 |  | def encode_base64(self, media: tuple[npt.NDArray, int]) -> str:
    audio, sr = media
    with BytesIO() as buffer:
        soundfile.write(buffer, audio, sr, format="WAV")
        data = buffer.getvalue()
    return base64.b64encode(data).decode("utf-8")
 | 
           Source code in vllm/multimodal/audio.py
 |  | def load_base64(
    self,
    media_type: str,
    data: str,
) -> tuple[npt.NDArray, float]:
    return self.load_bytes(base64.b64decode(data))
 | 
           Source code in vllm/multimodal/audio.py
 |  | def load_bytes(self, data: bytes) -> tuple[npt.NDArray, float]:
    return librosa.load(BytesIO(data), sr=None)
 | 
           Source code in vllm/multimodal/audio.py
 |  | def load_file(self, filepath: Path) -> tuple[npt.NDArray, float]:
    return librosa.load(filepath, sr=None)
 |