File size: 722 Bytes
7a596f2
d41d006
 
7a596f2
d41d006
7a596f2
d41d006
 
7a596f2
d41d006
 
 
 
 
7a596f2
d41d006
7a596f2
d41d006
 
 
 
7a596f2
d41d006
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import streamlit as st
import tempfile
import os

st.title("🎵 Audio Upload App")

# File uploader accepts audio files
audio_file = st.file_uploader("Upload an audio file", type=["wav", "mp3", "ogg", "m4a"])

if audio_file is not None:
    # Save the uploaded file to a temporary file
    with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
        tmp_file.write(audio_file.read())
        tmp_file_path = tmp_file.name

    st.audio(tmp_file_path, format='audio/wav')

    # Optional: Display file details
    st.write("Filename:", audio_file.name)
    st.write("File type:", audio_file.type)
    st.write("File size:", audio_file.size, "bytes")

    # Clean up the temporary file
    os.remove(tmp_file_path)