Last active
June 16, 2021 18:43
-
-
Save ngbala6/749e6e93272eb9a84a990b442a07d612 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import streamlit as st | |
| st.title("Hello Captain") | |
| file_to_be_uploaded = st.file_uploader("Choose a file", type=['MP3', 'WAV]) | |
| RAWDATAPATH = "path to save the file" | |
| def save_uploadedfile(uploadedfile): | |
| global RAWDATAPATH | |
| with open(os.path.join(RAWDATAPATH, uploadedfile.name), "wb") as f: | |
| f.write(uploadedfile.getbuffer()) | |
| with st.spinner(text="Uploading . . ."): | |
| time.sleep(3) | |
| bala = os.path.join(RAWDATAPATH, uploadedfile.name) | |
| print(bala) | |
| return bala | |
| if st.button("Upload"): | |
| if file_to_be_uploaded is not None: | |
| input_files = save_uploadedfile(file_to_be_uploaded) | |
| st.write(f"File is uploaded in {input_files} path") | |
| # Audio Files Listening | |
| audio_file = open(input_files, 'rb') | |
| audio_bytes = audio_file.read() | |
| st.audio(audio_bytes, format='audio/wav', start_time=0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment