Skip to main content
Render an audio file as HTML.

Usage

Signature

Parameters

Union[str, io.BytesIO, NDArray[Any]]
required
A path or URL to an audio file, bytes, or a file-like object opened in binary mode, 1D numpy array → Mono waveform, 2D numpy array → Multi-channel waveform (Shape: [NCHAN, NSAMPLES]).
Optional[int]
default:"None"
Sampling rate (required only for NumPy arrays).
bool
default:"True"
Whether to rescale NumPy array audio to its max range (True by default). If False, values must be in [-1, 1], or an error is raised. Does not apply to non-array audio sources.

Returns

An audio player as an Html object.

Supported Input Types

The src parameter accepts:
  • str: Path or URL to an audio file
  • bytes: Audio data as bytes
  • io.BytesIO: File-like object in binary mode
  • io.BufferedReader: Buffered file reader
  • numpy.ndarray: 1D array for mono or 2D array for multi-channel audio
For numpy arrays:
  • 1D array: Mono waveform
  • 2D array: Multi-channel waveform with shape [NCHAN, NSAMPLES]
  • You must specify the rate parameter when using numpy arrays