Spaces:
Runtime error
Runtime error
adjust ui layout
Browse files
app.py
CHANGED
@@ -559,53 +559,68 @@ DEMO_CSS = """
|
|
559 |
"""
|
560 |
Demo = gr.Blocks(css=DEMO_CSS)
|
561 |
with Demo:
|
562 |
-
gr.Markdown("## Whisper vs. SenseVoice (
|
563 |
-
|
564 |
audio_input = gr.Audio(sources=["upload", "microphone"], type="filepath", label="Audio Input")
|
565 |
-
|
566 |
-
# Examples
|
567 |
examples = gr.Examples(
|
568 |
-
examples=[
|
569 |
-
["interview.mp3"],
|
570 |
-
["news.mp3"]
|
571 |
-
],
|
572 |
inputs=[audio_input],
|
573 |
label="Example Audio Files"
|
574 |
)
|
575 |
|
|
|
|
|
576 |
with gr.Row():
|
577 |
with gr.Column():
|
578 |
gr.Markdown("### Faster-Whisper ASR")
|
579 |
-
whisper_dd
|
580 |
-
whisper_lang
|
581 |
-
device_radio
|
582 |
-
diar_check
|
583 |
-
|
584 |
-
out_w_d = gr.HTML(label="Diarized Transcript", visible=True, elem_classes=["diar"])
|
585 |
-
# Toggle visibility based on checkbox
|
586 |
-
diar_check.change(lambda e: gr.update(visible=not e), inputs=diar_check, outputs=out_w)
|
587 |
-
diar_check.change(lambda e: gr.update(visible=e), inputs=diar_check, outputs=out_w_d)
|
588 |
-
btn_w = gr.Button("Transcribe with Faster-Whisper")
|
589 |
-
btn_w.click(fn=transcribe_fwhisper_stream,
|
590 |
-
inputs=[whisper_dd, whisper_lang, audio_input, device_radio, diar_check],
|
591 |
-
outputs=[out_w, out_w_d])
|
592 |
|
593 |
with gr.Column():
|
594 |
gr.Markdown("### FunASR SenseVoice ASR")
|
595 |
-
sense_dd
|
596 |
-
sense_lang
|
597 |
-
|
598 |
-
punct_chk
|
599 |
-
diar_s_chk
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
609 |
|
610 |
if __name__ == "__main__":
|
611 |
Demo.launch()
|
|
|
559 |
"""
|
560 |
Demo = gr.Blocks(css=DEMO_CSS)
|
561 |
with Demo:
|
562 |
+
gr.Markdown("## Whisper vs. SenseVoice (…)")
|
|
|
563 |
audio_input = gr.Audio(sources=["upload", "microphone"], type="filepath", label="Audio Input")
|
|
|
|
|
564 |
examples = gr.Examples(
|
565 |
+
examples=[["interview.mp3"], ["news.mp3"]],
|
|
|
|
|
|
|
566 |
inputs=[audio_input],
|
567 |
label="Example Audio Files"
|
568 |
)
|
569 |
|
570 |
+
# ────────────────────────────────────────────────────────────────
|
571 |
+
# 1) CONTROL PANELS (still side-by-side)
|
572 |
with gr.Row():
|
573 |
with gr.Column():
|
574 |
gr.Markdown("### Faster-Whisper ASR")
|
575 |
+
whisper_dd = gr.Dropdown(choices=WHISPER_MODELS, value=WHISPER_MODELS[0], label="Whisper Model")
|
576 |
+
whisper_lang = gr.Dropdown(choices=WHISPER_LANGUAGES, value="auto", label="Whisper Language")
|
577 |
+
device_radio = gr.Radio(choices=["GPU","CPU"], value="GPU", label="Device")
|
578 |
+
diar_check = gr.Checkbox(label="Enable Diarization", value=True)
|
579 |
+
btn_w = gr.Button("Transcribe with Faster-Whisper")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
|
581 |
with gr.Column():
|
582 |
gr.Markdown("### FunASR SenseVoice ASR")
|
583 |
+
sense_dd = gr.Dropdown(choices=SENSEVOICE_MODELS, value=SENSEVOICE_MODELS[0], label="SenseVoice Model")
|
584 |
+
sense_lang = gr.Dropdown(choices=SENSEVOICE_LANGUAGES, value="auto", label="SenseVoice Language")
|
585 |
+
device_radio_s = gr.Radio(choices=["GPU","CPU"], value="GPU", label="Device")
|
586 |
+
punct_chk = gr.Checkbox(label="Enable Punctuation", value=True)
|
587 |
+
diar_s_chk = gr.Checkbox(label="Enable Diarization", value=True)
|
588 |
+
btn_s = gr.Button("Transcribe with SenseVoice")
|
589 |
+
|
590 |
+
# ────────────────────────────────────────────────────────────────
|
591 |
+
# 2) SHARED TRANSCRIPT ROW (aligned side-by-side)
|
592 |
+
with gr.Row():
|
593 |
+
with gr.Column():
|
594 |
+
gr.Markdown("### Faster-Whisper Output")
|
595 |
+
out_w = gr.Textbox(label="Raw Transcript", visible=False)
|
596 |
+
out_w_d = gr.HTML(label="Diarized Transcript", elem_classes=["diar"])
|
597 |
+
|
598 |
+
with gr.Column():
|
599 |
+
gr.Markdown("### SenseVoice Output")
|
600 |
+
out_s = gr.Textbox(label="Raw Transcript", visible=False)
|
601 |
+
out_s_d = gr.HTML(label="Diarized Transcript", elem_classes=["diar"])
|
602 |
+
|
603 |
+
# ────────────────────────────────────────────────────────────────
|
604 |
+
# 3) WIRING UP TOGGLES & BUTTONS
|
605 |
+
# toggle raw ↔ diarized for each system
|
606 |
+
diar_check.change(lambda e: gr.update(visible=not e), diar_check, out_w)
|
607 |
+
diar_check.change(lambda e: gr.update(visible=e), diar_check, out_w_d)
|
608 |
+
|
609 |
+
diar_s_chk.change(lambda e: gr.update(visible=not e), diar_s_chk, out_s)
|
610 |
+
diar_s_chk.change(lambda e: gr.update(visible=e), diar_s_chk, out_s_d)
|
611 |
+
|
612 |
+
# wire the callbacks into those shared boxes
|
613 |
+
btn_w.click(
|
614 |
+
fn=transcribe_fwhisper_stream,
|
615 |
+
inputs=[whisper_dd, whisper_lang, audio_input, device_radio, diar_check],
|
616 |
+
outputs=[out_w, out_w_d]
|
617 |
+
)
|
618 |
+
btn_s.click(
|
619 |
+
fn=transcribe_sense_steam,
|
620 |
+
inputs=[sense_dd, sense_lang, audio_input, punct_chk, diar_s_chk, device_radio_s],
|
621 |
+
outputs=[out_s, out_s_d]
|
622 |
+
)
|
623 |
+
|
624 |
|
625 |
if __name__ == "__main__":
|
626 |
Demo.launch()
|