Update app.py
Browse files
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 |
-
|
|
|
|
| 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 |
-
|
|
|
|
|
|
| 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)
|