Function signature[source] | |
---|---|
st.audio(data, format="audio/wav", start_time=0, *, sample_rate=None, end_time=None, loop=False, autoplay=False, width="stretch") | |
Parameters | |
data (str, Path, bytes, BytesIO, numpy.ndarray, or file) | The audio to play. This can be one of the following:
If data is a NumPy array, it must either be a 1D array of the waveform or a 2D array of shape (C, S) where C is the number of channels and S is the number of samples. See the default channel order at http://msdn.microsoft.com/en-us/library/windows/hardware/dn653308(v=vs.85).aspx |
format (str) | The MIME type for the audio file. This defaults to "audio/wav". For more information about MIME types, see https://www.iana.org/assignments/media-types/media-types.xhtml. |
start_time (int, float, timedelta, str, or None) | The time from which the element should start playing. This can be one of the following:
|
sample_rate (int or None) | The sample rate of the audio data in samples per second. This is only required if data is a NumPy array. |
end_time (int, float, timedelta, str, or None) | The time at which the element should stop playing. This can be one of the following:
|
loop (bool) | Whether the audio should loop playback. |
autoplay (bool) | Whether the audio file should start playing automatically. This is False by default. Browsers will not autoplay audio files if the user has not interacted with the page by clicking somewhere. |
width ("stretch" or int) | The width of the audio player element. This can be one of the following:
|
Examples
To display an audio player for a local file, specify the file's string path and format.
You can also pass bytes or numpy.ndarray objects to st.audio.
Still have questions?
Our forums are full of helpful information and Streamlit experts.