Muhammad Abdullah commited on
Commit
65cbbaf
·
verified ·
1 Parent(s): 780b189

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -295,6 +295,11 @@ class TranscriptionProgress:
295
  self.progress_bar.progress(progress)
296
  if self.status_text is not None:
297
  self.status_text.text(status)
 
 
 
 
 
298
 
299
  @st.cache_resource
300
  def load_model(language='en', summarizer_type='bart'):
@@ -344,12 +349,12 @@ def process_chunks(chunks, sr, processor, model, device, language, chunk_duratio
344
  transcript = []
345
  chunk_start = 0
346
  total_chunks = len(chunks)
347
- progress_bar = st.progress(0)
348
- status_text = st.empty()
349
  if os.path.exists(transcript_file):
350
  os.remove(transcript_file)
351
  for i, chunk in enumerate(chunks):
352
- status_text.text(f"Processing chunk {i+1}/{total_chunks}...")
353
  try:
354
  memory = psutil.virtual_memory()
355
  st.write(f"Memory usage: {memory.percent}% (Chunk {i+1}/{total_chunks})")
@@ -358,12 +363,10 @@ def process_chunks(chunks, sr, processor, model, device, language, chunk_duratio
358
  with open(transcript_file, "w", encoding="utf-8") as f:
359
  json.dump(transcript, f, ensure_ascii=False)
360
  chunk_start += chunk_duration
361
- progress_bar.progress((i + 1) / total_chunks)
362
  except Exception as e:
363
  st.error(f"Error processing chunk {i+1}: {str(e)}")
364
  break
365
- status_text.text("Processing complete!")
366
- progress_bar.empty()
367
  return transcript
368
 
369
  def summarize_text(text, tokenizer, model, device, summarizer_type='bart'):
 
295
  self.progress_bar.progress(progress)
296
  if self.status_text is not None:
297
  self.status_text.text(status)
298
+ def clear(self):
299
+ if self.status_text is not None:
300
+ self.status_text.text("Processing complete!")
301
+ if self.progress_bar is not None:
302
+ self.progress_bar.empty()
303
 
304
  @st.cache_resource
305
  def load_model(language='en', summarizer_type='bart'):
 
349
  transcript = []
350
  chunk_start = 0
351
  total_chunks = len(chunks)
352
+ progress = TranscriptionProgress()
353
+ progress.init_progress()
354
  if os.path.exists(transcript_file):
355
  os.remove(transcript_file)
356
  for i, chunk in enumerate(chunks):
357
+ progress.update((i + 1) / total_chunks, f"Processing chunk {i+1}/{total_chunks}...")
358
  try:
359
  memory = psutil.virtual_memory()
360
  st.write(f"Memory usage: {memory.percent}% (Chunk {i+1}/{total_chunks})")
 
363
  with open(transcript_file, "w", encoding="utf-8") as f:
364
  json.dump(transcript, f, ensure_ascii=False)
365
  chunk_start += chunk_duration
 
366
  except Exception as e:
367
  st.error(f"Error processing chunk {i+1}: {str(e)}")
368
  break
369
+ progress.clear()
 
370
  return transcript
371
 
372
  def summarize_text(text, tokenizer, model, device, summarizer_type='bart'):