當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python Streamlit st.audio用法及代碼示例

顯示音頻播放器。

函數簽名

st.audio(data, format="audio/wav", start_time=0)
參數說明

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

io.open()。原始音頻數據、文件名或指向要加載的文件的 URL。 Numpy 數組和原始數據格式必須包含所有必要的文件頭以匹配指定的文件格式。

start_time (int)

該元素應該開始播放的時間。

format (str)

音頻文件的 MIME 類型。默認為'audio/wav'。有關詳細信息,請參閱https://tools.ietf.org/html/rfc4281

示例

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

st.audio(audio_bytes, format='audio/ogg')

相關用法


注:本文由純淨天空篩選整理自streamlit.io大神的英文原創作品 st.audio。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。