Display an audio player.
Function signature

st.audio(data, format="audio/wav", start_time=0)

Parameters

data (str, bytes, BytesIO, numpy.ndarray, or file opened with)

io.open(). Raw audio data, filename, or a URL pointing to the file to load. Numpy arrays and raw data formats must include all necessary file headers to match specified file format.

start_time (int)

The time from which this element should start playing.

format (str)

The mime type for the audio file. Defaults to 'audio/wav'. See https://tools.ietf.org/html/rfc4281 for more info.

Example

audio_file = open('myaudio.ogg', 'rb')
audio_bytes = audio_file.read()

st.audio(audio_bytes, format='audio/ogg')
(view standalone Streamlit app)

Was this page helpful?

editSuggest edits
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.