MurderousCoder commited on
Commit
2b907bf
·
verified ·
1 Parent(s): 4f93fcb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -29
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, file_path
22
  except Exception as e:
23
- return False, str(e)
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
- # Show file details
38
- st.write("File Details:")
39
- st.write(f"- Name: {uploaded_file.name}")
40
- st.write(f"- Size: {uploaded_file.size / 1024:.2f} KB")
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
- # Process upload
50
- with st.spinner(progress_text):
51
- success, result = save_uploaded_file(uploaded_file)
52
- progress_bar.progress(100)
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()