> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/marimo-team/marimo/llms.txt
> Use this file to discover all available pages before exploring further.

# audio

Render an audio file as HTML.

## Usage

```python theme={null}
mo.audio(
    src="https://upload.wikimedia.org/wikipedia/commons/8/8c/Ivan_Ili%C4%87-Chopin_-_Prelude_no._1_in_C_major.ogg"
)
```

```python theme={null}
mo.audio(src="path/to/local/file.wav")
```

## Signature

```python theme={null}
mo.audio(
    src: Union[str, io.BytesIO, NDArray[Any]],
    rate: Optional[int] = None,
    normalize: bool = True
) -> Html
```

## Parameters

<ParamField path="src" type="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]`).
</ParamField>

<ParamField path="rate" type="Optional[int]" default="None">
  Sampling rate (required only for NumPy arrays).
</ParamField>

<ParamField path="normalize" type="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.
</ParamField>

## Returns

<ParamField path="Html">
  An audio player as an `Html` object.
</ParamField>

## 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
