Franco Zanardi commited on
Commit
ba9737f
·
1 Parent(s): be2ef8d

force full rebuilding & disabling 'start' button when it's processing audio

Browse files
Files changed (2) hide show
  1. requirements.txt +1 -1
  2. src/ui/step1_upload.py +9 -1
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
  streamlit
2
- git+https://github.com/francozanardi/pycaps.git@main
3
  openai
 
1
  streamlit
2
+ git+https://github.com/francozanardi/pycaps.git
3
  openai
src/ui/step1_upload.py CHANGED
@@ -19,6 +19,9 @@ def render_step1():
19
  if st.button("Refresh Status"):
20
  st.rerun()
21
  return
 
 
 
22
 
23
  uploaded_file = st.file_uploader(
24
  f"Select a video file (max {MAX_VIDEO_SIZE // (1024*1024)}MB)",
@@ -33,13 +36,17 @@ def render_step1():
33
  st.error(f"File is too large ({uploaded_file.size / (1024*1024):.1f}MB). Max is {MAX_VIDEO_SIZE // (1024*1024)}MB.")
34
  return
35
 
36
- if st.button("Start", type="primary"):
37
  lock_file = acquire_lock_slot()
38
  if not lock_file:
39
  st.error("Sorry, all slots were taken just now. Please try again.")
40
  st.rerun()
41
 
42
  st.session_state.lock_file_path = lock_file
 
 
 
 
43
  try:
44
  with tempfile.TemporaryDirectory() as temp_dir:
45
  video_path = Path(temp_dir) / uploaded_file.name
@@ -57,6 +64,7 @@ def render_step1():
57
  shutil.copy(video_path, persisted_path)
58
  st.session_state.video_path = persisted_path
59
 
 
60
  go_to_step(2)
61
  st.rerun()
62
  except Exception as e:
 
19
  if st.button("Refresh Status"):
20
  st.rerun()
21
  return
22
+
23
+ if 'audio_being_analyzed' not in st.session_state:
24
+ st.session_state['audio_being_analyzed'] = False
25
 
26
  uploaded_file = st.file_uploader(
27
  f"Select a video file (max {MAX_VIDEO_SIZE // (1024*1024)}MB)",
 
36
  st.error(f"File is too large ({uploaded_file.size / (1024*1024):.1f}MB). Max is {MAX_VIDEO_SIZE // (1024*1024)}MB.")
37
  return
38
 
39
+ if st.button("Start", type="primary", disabled=st.session_state.audio_being_analyzed):
40
  lock_file = acquire_lock_slot()
41
  if not lock_file:
42
  st.error("Sorry, all slots were taken just now. Please try again.")
43
  st.rerun()
44
 
45
  st.session_state.lock_file_path = lock_file
46
+ st.session_state.audio_being_analyzed = True
47
+ st.rerun()
48
+
49
+ if st.session_state.audio_being_analyzed:
50
  try:
51
  with tempfile.TemporaryDirectory() as temp_dir:
52
  video_path = Path(temp_dir) / uploaded_file.name
 
64
  shutil.copy(video_path, persisted_path)
65
  st.session_state.video_path = persisted_path
66
 
67
+ st.session_state.audio_being_analyzed = False
68
  go_to_step(2)
69
  st.rerun()
70
  except Exception as e: