ricklon commited on
Commit
7d3f4c9
·
verified ·
1 Parent(s): ab19864

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -5
app.py CHANGED
@@ -27,6 +27,29 @@ if not HF_TOKEN:
27
  st.error("HF_TOKEN not found in environment variables. Please set it in your Hugging Face Space secrets.")
28
  st.stop()
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  def check_versions():
31
  st.info("Checking package versions...")
32
 
@@ -154,11 +177,7 @@ with tab1:
154
  with st.status("Processing audio...", expanded=True) as status:
155
  progress_bar = st.progress(0)
156
 
157
- def progress_hook(**kwargs):
158
- if 'completed' in kwargs and 'total' in kwargs:
159
- progress_percentage = min(kwargs['completed'] / kwargs['total'], 1.0)
160
- status.update(label=f"Processing: {progress_percentage:.1%} complete", state="running")
161
- progress_bar.progress(progress_percentage)
162
 
163
  # Run the pipeline on the audio file
164
  diarization_args = {
@@ -194,6 +213,7 @@ with tab1:
194
  # Clean up the temporary file
195
  os.unlink(tmp_path)
196
 
 
197
  with tab2:
198
  if 'diarization' in locals():
199
  st.subheader("Diarization Results")
 
27
  st.error("HF_TOKEN not found in environment variables. Please set it in your Hugging Face Space secrets.")
28
  st.stop()
29
 
30
+
31
+
32
+ class ProgressHook:
33
+ def __init__(self, status, progress_bar):
34
+ self.status = status
35
+ self.progress_bar = progress_bar
36
+ self.total = 0
37
+ self.completed = 0
38
+
39
+ def __call__(self, *args, **kwargs):
40
+ if 'completed' in kwargs and 'total' in kwargs:
41
+ self.completed = kwargs['completed']
42
+ self.total = kwargs['total']
43
+ elif len(args) == 2:
44
+ self.completed, self.total = args
45
+
46
+ if self.total > 0:
47
+ progress_percentage = min(self.completed / self.total, 1.0)
48
+ self.status.update(label=f"Processing: {progress_percentage:.1%} complete", state="running")
49
+ self.progress_bar.progress(progress_percentage)
50
+
51
+
52
+
53
  def check_versions():
54
  st.info("Checking package versions...")
55
 
 
177
  with st.status("Processing audio...", expanded=True) as status:
178
  progress_bar = st.progress(0)
179
 
180
+ progress_hook = ProgressHook(status, progress_bar)
 
 
 
 
181
 
182
  # Run the pipeline on the audio file
183
  diarization_args = {
 
213
  # Clean up the temporary file
214
  os.unlink(tmp_path)
215
 
216
+
217
  with tab2:
218
  if 'diarization' in locals():
219
  st.subheader("Diarization Results")