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

# Audio

> Create audio upload and playback components in Gradio

The Audio component allows users to upload, record, or play audio files.

## Basic usage

```python theme={null}
import gradio as gr

def reverse_audio(audio):
    sr, data = audio
    return (sr, data[::-1])

gr.Interface(
    fn=reverse_audio,
    inputs=gr.Audio(),
    outputs=gr.Audio()
).launch()
```

## Constructor

<ParamField path="value" type="str | Path | tuple[int, np.ndarray] | Callable | None" default="None">
  Default audio as filepath, URL, or (sample\_rate, numpy array) tuple
</ParamField>

<ParamField path="sources" type="list[Literal['upload', 'microphone']] | None" default="None">
  Input sources:

  * `"upload"` - File upload
  * `"microphone"` - Microphone recording

  Defaults to both if not streaming
</ParamField>

<ParamField path="type" type="Literal['numpy', 'filepath']" default="'numpy'">
  Format passed to function:

  * `"numpy"` - Tuple of (sample\_rate, data)
  * `"filepath"` - String path to temporary file
</ParamField>

<ParamField path="format" type="Literal['wav', 'mp3'] | None" default="None">
  Audio file format. If None, no conversion is done
</ParamField>

<ParamField path="streaming" type="bool" default="False">
  If True, automatically streams from microphone in live interfaces
</ParamField>

<ParamField path="autoplay" type="bool" default="False">
  Whether to automatically play audio when displayed as output
</ParamField>

<ParamField path="loop" type="bool" default="False">
  Whether audio loops when it reaches the end
</ParamField>

<ParamField path="editable" type="bool" default="True">
  Whether users can edit the audio waveform
</ParamField>

## Events

* **change** - Triggered when audio changes
* **upload** - Triggered when audio is uploaded
* **clear** - Triggered when audio is cleared
* **play** - Triggered when playback starts
* **pause** - Triggered when playback pauses
* **stop** - Triggered when playback stops
* **stream** - Triggered during streaming
* **start\_recording** - Triggered when recording starts
* **pause\_recording** - Triggered when recording pauses
* **stop\_recording** - Triggered when recording stops

## Examples

### Microphone only

```python theme={null}
import gradio as gr

gr.Audio(
    sources=["microphone"],
    label="Record your voice"
)
```

### MP3 format

```python theme={null}
import gradio as gr

gr.Audio(
    format="mp3",
    label="Audio in MP3 format"
)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.