Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,47 +18,29 @@ def save_uploaded_file(uploaded_file):
|
|
| 18 |
with open(file_path, "wb") as f:
|
| 19 |
f.write(uploaded_file.getbuffer())
|
| 20 |
|
| 21 |
-
return True
|
| 22 |
except Exception as e:
|
| 23 |
-
return False
|
| 24 |
|
| 25 |
def main():
|
| 26 |
st.set_page_config(page_title="What's That Tongue?", layout="centered")
|
| 27 |
st.title("What's That Tongue?")
|
| 28 |
|
| 29 |
-
# Create a container for file upload
|
| 30 |
uploaded_file = st.file_uploader(
|
| 31 |
"Upload your audio file",
|
| 32 |
-
type=["mp3", "wav", "txt"]
|
| 33 |
-
help="Supported formats: MP3, WAV, TXT"
|
| 34 |
)
|
| 35 |
|
| 36 |
if uploaded_file is not None:
|
| 37 |
-
|
| 38 |
-
st.
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
st.write(f"- Type: {uploaded_file.type}")
|
| 42 |
-
|
| 43 |
-
# Create upload button
|
| 44 |
-
if st.button("Start Upload", type="primary"):
|
| 45 |
-
# Show progress
|
| 46 |
-
progress_text = "Upload in progress. Please wait..."
|
| 47 |
-
progress_bar = st.progress(0)
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
# Show result
|
| 55 |
-
if success:
|
| 56 |
-
st.success(f"File successfully uploaded to: {result}")
|
| 57 |
-
# Optional: Show a preview or additional options
|
| 58 |
-
if uploaded_file.type.startswith('audio/'):
|
| 59 |
-
st.audio(result)
|
| 60 |
-
else:
|
| 61 |
-
st.error(f"Error uploading file: {result}")
|
| 62 |
|
| 63 |
if __name__ == "__main__":
|
| 64 |
main()
|
|
|
|
| 18 |
with open(file_path, "wb") as f:
|
| 19 |
f.write(uploaded_file.getbuffer())
|
| 20 |
|
| 21 |
+
return True
|
| 22 |
except Exception as e:
|
| 23 |
+
return False
|
| 24 |
|
| 25 |
def main():
|
| 26 |
st.set_page_config(page_title="What's That Tongue?", layout="centered")
|
| 27 |
st.title("What's That Tongue?")
|
| 28 |
|
|
|
|
| 29 |
uploaded_file = st.file_uploader(
|
| 30 |
"Upload your audio file",
|
| 31 |
+
type=["mp3", "wav", "txt"]
|
|
|
|
| 32 |
)
|
| 33 |
|
| 34 |
if uploaded_file is not None:
|
| 35 |
+
progress_bar = st.progress(0)
|
| 36 |
+
with st.spinner('Uploading...'):
|
| 37 |
+
success = save_uploaded_file(uploaded_file)
|
| 38 |
+
progress_bar.progress(100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
if success:
|
| 41 |
+
st.success('Upload completed!')
|
| 42 |
+
else:
|
| 43 |
+
st.error('Upload failed.')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
if __name__ == "__main__":
|
| 46 |
main()
|