import streamlit as st import os def load_audio_file() -> str: """ Uploads an audio file provided by the user and saves it in the specified directory. Parameters: None Returns: str """ st.markdown('# **Díctamelo**') st.markdown('### *Transcripción de audio a texto*') audio_file = st.file_uploader("Drag your audio file", type=[ '.mp3', '.m4a', '.ogg', '.aac']) path_audio: str = os.path.join("documents", "audios") if audio_file is not None: if "audio_file_name" not in st.session_state.keys(): st.session_state.audio_file_name = audio_file.name # Ensure the directory exists os.makedirs(path_audio, exist_ok=True) # Construct the full path to the new file audio_full_path = os.path.join( path_audio, st.session_state.audio_file_name) # if "audio_full_path" not in st.session_state.key(): # st.session_state.audio_full_path = os.path.join( # path_audio, st.session_state.audio_file_name) with open(audio_full_path, 'wb') as new_file: new_file.write(audio_file.read()) return audio_full_path