st.audio() in Streamlit
In Streamlit, the audio method is used to play audio files directly inside your app. It supports local files, URLs, and raw audio bytes, making it useful for media apps, speech AI, and machine learning projects.
Basic Syntax
st.audio(data, format="audio/wav", start_time=0)
The function has the following parameters:
- data: File path, URL, bytes, or file-like object
- format: Audio format (wav, mp3, ogg)
- start_time: Start playback from a specific second
Example: Play a local audio file.
Python
import streamlit as st
st.title("Audio Player")
# Play audio file
st.audio("audio.mp3") - Works with .mp3, .wav, and .ogg formats.