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

Basic usage

Constructor

str | Path | tuple[int, np.ndarray] | Callable | None
default:"None"
Default audio as filepath, URL, or (sample_rate, numpy array) tuple
list[Literal['upload', 'microphone']] | None
default:"None"
Input sources:
  • "upload" - File upload
  • "microphone" - Microphone recording
Defaults to both if not streaming
Literal['numpy', 'filepath']
default:"'numpy'"
Format passed to function:
  • "numpy" - Tuple of (sample_rate, data)
  • "filepath" - String path to temporary file
Literal['wav', 'mp3'] | None
default:"None"
Audio file format. If None, no conversion is done
bool
default:"False"
If True, automatically streams from microphone in live interfaces
bool
default:"False"
Whether to automatically play audio when displayed as output
bool
default:"False"
Whether audio loops when it reaches the end
bool
default:"True"
Whether users can edit the audio waveform

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

MP3 format