RohitManglik commited on
Commit
bc62dd0
Β·
verified Β·
1 Parent(s): d71c05d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -61,6 +61,15 @@ def process_audio(audio_file):
61
  if audio_file is None:
62
  return "⚠️ No audio provided.\n\nPlease upload a file or record audio using your microphone, then click Analyze."
63
 
 
 
 
 
 
 
 
 
 
64
  try:
65
  # Transcribe full audio β€” do NOT pass trim timestamps
66
  result = whisper_model.transcribe(audio_file, task="translate")
@@ -539,7 +548,8 @@ footer,
539
 
540
  # ── Interface ──────────────────────────────────────────────
541
  def create_interface():
542
- with gr.Blocks(css=APP_CSS, theme=gr.themes.Base()) as interface:
 
543
 
544
  # Header
545
  gr.HTML("""
@@ -562,8 +572,6 @@ def create_interface():
562
  type="filepath",
563
  label="Upload Audio File",
564
  elem_classes="audio-component-wrap",
565
- show_download_button=False, # removes download clutter
566
- editable=False, # ← DISABLES trim entirely
567
  )
568
  upload_btn = gr.Button(
569
  "πŸš€ Analyze Uploaded Audio",
@@ -580,7 +588,6 @@ def create_interface():
580
  type="filepath",
581
  label="Microphone Recording",
582
  elem_classes="audio-component-wrap",
583
- editable=False, # ← DISABLES trim entirely
584
  )
585
  record_btn = gr.Button(
586
  "πŸŽ™οΈ Analyze Recorded Audio",
@@ -607,7 +614,6 @@ def create_interface():
607
  " πŸ” Confidence score\n"
608
  " β–“β–“β–“ Confidence bar"
609
  ),
610
- show_copy_button=True,
611
  interactive=False,
612
  )
613
 
@@ -635,4 +641,5 @@ def create_interface():
635
  # ── Launch ─────────────────────────────────────────────────
636
  if __name__ == "__main__":
637
  interface = create_interface()
638
- interface.launch(share=True)
 
 
61
  if audio_file is None:
62
  return "⚠️ No audio provided.\n\nPlease upload a file or record audio using your microphone, then click Analyze."
63
 
64
+ # Gradio 6 Audio with type="filepath" may pass a tuple (path, [start, end])
65
+ # when the user interacts with the trim tool. Always extract just the filepath
66
+ # so Whisper processes the full audio rather than a trimmed segment.
67
+ if isinstance(audio_file, (tuple, list)):
68
+ audio_file = audio_file[0]
69
+
70
+ if not audio_file:
71
+ return "⚠️ No audio file found."
72
+
73
  try:
74
  # Transcribe full audio β€” do NOT pass trim timestamps
75
  result = whisper_model.transcribe(audio_file, task="translate")
 
548
 
549
  # ── Interface ──────────────────────────────────────────────
550
  def create_interface():
551
+ # Gradio 6.0: css and theme go in launch(), NOT Blocks()
552
+ with gr.Blocks(theme=gr.themes.Base()) as interface:
553
 
554
  # Header
555
  gr.HTML("""
 
572
  type="filepath",
573
  label="Upload Audio File",
574
  elem_classes="audio-component-wrap",
 
 
575
  )
576
  upload_btn = gr.Button(
577
  "πŸš€ Analyze Uploaded Audio",
 
588
  type="filepath",
589
  label="Microphone Recording",
590
  elem_classes="audio-component-wrap",
 
591
  )
592
  record_btn = gr.Button(
593
  "πŸŽ™οΈ Analyze Recorded Audio",
 
614
  " πŸ” Confidence score\n"
615
  " β–“β–“β–“ Confidence bar"
616
  ),
 
617
  interactive=False,
618
  )
619
 
 
641
  # ── Launch ─────────────────────────────────────────────────
642
  if __name__ == "__main__":
643
  interface = create_interface()
644
+ # Gradio 6.0: css and theme are passed to launch()
645
+ interface.launch(share=True, css=APP_CSS)