|
|
|
|
|
import gradio as gr |
|
|
from zoom_test_backend import ZoomTranscriptionBackend |
|
|
|
|
|
|
|
|
backend = ZoomTranscriptionBackend() |
|
|
|
|
|
def update_display(): |
|
|
"""Function to get latest transcription from backend""" |
|
|
return backend.get_transcription() |
|
|
|
|
|
def handle_start_listening(): |
|
|
"""Handle start button click""" |
|
|
return backend.start_listening() |
|
|
|
|
|
def handle_stop_listening(): |
|
|
"""Handle stop button click""" |
|
|
return backend.stop_listening() |
|
|
|
|
|
def handle_clear_transcription(): |
|
|
"""Handle clear button click""" |
|
|
return backend.clear_transcription() |
|
|
|
|
|
|
|
|
with gr.Blocks(title="Zoom Transcription Test") as demo: |
|
|
gr.Markdown("# π― Zoom Live Transcription Test") |
|
|
gr.Markdown("Frontend UI - Backend handles all Zoom logic") |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
start_btn = gr.Button("π§ Start Listening", variant="primary") |
|
|
stop_btn = gr.Button("βΉοΈ Stop Listening", variant="secondary") |
|
|
|
|
|
refresh_btn = gr.Button("π Refresh Transcription") |
|
|
clear_btn = gr.Button("π Clear Text", variant="stop") |
|
|
status = gr.Textbox(label="Status", interactive=False) |
|
|
|
|
|
with gr.Row(): |
|
|
transcription_display = gr.Textbox( |
|
|
label="Live Transcription", |
|
|
lines=15, |
|
|
max_lines=20, |
|
|
interactive=False, |
|
|
placeholder="Transcription will appear here live..." |
|
|
) |
|
|
|
|
|
|
|
|
demo.load( |
|
|
fn=update_display, |
|
|
outputs=transcription_display, |
|
|
) |
|
|
|
|
|
|
|
|
start_btn.click( |
|
|
fn=handle_start_listening, |
|
|
outputs=status |
|
|
) |
|
|
|
|
|
stop_btn.click( |
|
|
fn=handle_stop_listening, |
|
|
outputs=status |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
refresh_btn.click( |
|
|
fn=update_display, |
|
|
outputs=transcription_display |
|
|
) |
|
|
|
|
|
clear_btn.click( |
|
|
fn=handle_clear_transcription, |
|
|
outputs=status |
|
|
).then( |
|
|
fn=update_display, |
|
|
outputs=transcription_display |
|
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch( |
|
|
server_name="0.0.0.0", |
|
|
server_port=7860, |
|
|
share=True |
|
|
) |