Add application file
Browse files- requirements.txt +2 -0
- zoom_test_backend.py +71 -0
- zoom_test_frontend.py +84 -0
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
gradio>=4.0.0
|
zoom_test_backend.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# zoom_test_backend.py
|
| 2 |
+
import time
|
| 3 |
+
import threading
|
| 4 |
+
import random
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
from typing import Callable
|
| 7 |
+
|
| 8 |
+
class ZoomTranscriptionBackend:
|
| 9 |
+
def __init__(self):
|
| 10 |
+
self.is_listening = False
|
| 11 |
+
self.transcription_text = ""
|
| 12 |
+
self.speakers = ["Alice", "Bob", "Carol", "David"]
|
| 13 |
+
self.on_update_callback = None # For real-time updates
|
| 14 |
+
|
| 15 |
+
def set_update_callback(self, callback: Callable):
|
| 16 |
+
"""Set callback function when new transcription arrives"""
|
| 17 |
+
self.on_update_callback = callback
|
| 18 |
+
|
| 19 |
+
def start_listening(self):
|
| 20 |
+
"""Start Zoom RTMS connection (simulated for now)"""
|
| 21 |
+
if self.is_listening:
|
| 22 |
+
return "Already listening to meeting!"
|
| 23 |
+
|
| 24 |
+
self.is_listening = True
|
| 25 |
+
self.transcription_text = "๐ด Listening to Zoom meeting...\n\n"
|
| 26 |
+
|
| 27 |
+
# Start simulated transcription
|
| 28 |
+
threading.Thread(target=self._simulate_transcription, daemon=True).start()
|
| 29 |
+
|
| 30 |
+
return "โ
Connected to Zoom meeting! Live transcription starting..."
|
| 31 |
+
|
| 32 |
+
def _simulate_transcription(self):
|
| 33 |
+
"""Simulate real Zoom RTMS transcription"""
|
| 34 |
+
sample_phrases = [
|
| 35 |
+
"Okay team, let's start the meeting",
|
| 36 |
+
"I think we should focus on Q4 goals first",
|
| 37 |
+
"The budget looks good but we need to cut costs",
|
| 38 |
+
"Let's schedule follow-up for next week",
|
| 39 |
+
"Anyone have questions about the timeline?",
|
| 40 |
+
]
|
| 41 |
+
|
| 42 |
+
while self.is_listening:
|
| 43 |
+
time.sleep(random.uniform(3, 5))
|
| 44 |
+
|
| 45 |
+
if not self.is_listening:
|
| 46 |
+
break
|
| 47 |
+
|
| 48 |
+
speaker = random.choice(self.speakers)
|
| 49 |
+
phrase = random.choice(sample_phrases)
|
| 50 |
+
timestamp = datetime.now().strftime("%H:%M:%S")
|
| 51 |
+
|
| 52 |
+
new_transcript = f"[{timestamp}] {speaker}: {phrase}\n"
|
| 53 |
+
self.transcription_text += new_transcript
|
| 54 |
+
|
| 55 |
+
# Notify frontend if callback is set
|
| 56 |
+
if self.on_update_callback:
|
| 57 |
+
self.on_update_callback(self.transcription_text)
|
| 58 |
+
|
| 59 |
+
def stop_listening(self):
|
| 60 |
+
"""Stop the transcription"""
|
| 61 |
+
self.is_listening = False
|
| 62 |
+
return "โน๏ธ Stopped listening to meeting"
|
| 63 |
+
|
| 64 |
+
def get_transcription(self):
|
| 65 |
+
"""Get current transcription text"""
|
| 66 |
+
return self.transcription_text
|
| 67 |
+
|
| 68 |
+
def clear_transcription(self):
|
| 69 |
+
"""Clear all transcription text"""
|
| 70 |
+
self.transcription_text = ""
|
| 71 |
+
return "๐ Transcription cleared"
|
zoom_test_frontend.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# zoom_test_frontend.py
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from zoom_test_backend import ZoomTranscriptionBackend
|
| 4 |
+
|
| 5 |
+
# Initialize backend
|
| 6 |
+
backend = ZoomTranscriptionBackend()
|
| 7 |
+
|
| 8 |
+
def update_display():
|
| 9 |
+
"""Function to get latest transcription from backend"""
|
| 10 |
+
return backend.get_transcription()
|
| 11 |
+
|
| 12 |
+
def handle_start_listening():
|
| 13 |
+
"""Handle start button click"""
|
| 14 |
+
return backend.start_listening()
|
| 15 |
+
|
| 16 |
+
def handle_stop_listening():
|
| 17 |
+
"""Handle stop button click"""
|
| 18 |
+
return backend.stop_listening()
|
| 19 |
+
|
| 20 |
+
def handle_clear_transcription():
|
| 21 |
+
"""Handle clear button click"""
|
| 22 |
+
return backend.clear_transcription()
|
| 23 |
+
|
| 24 |
+
# Create Gradio interface
|
| 25 |
+
with gr.Blocks(title="Zoom Transcription Test") as demo:
|
| 26 |
+
gr.Markdown("# ๐ฏ Zoom Live Transcription Test")
|
| 27 |
+
gr.Markdown("Frontend UI - Backend handles all Zoom logic")
|
| 28 |
+
|
| 29 |
+
with gr.Row():
|
| 30 |
+
with gr.Column():
|
| 31 |
+
start_btn = gr.Button("๐ง Start Listening", variant="primary")
|
| 32 |
+
stop_btn = gr.Button("โน๏ธ Stop Listening", variant="secondary")
|
| 33 |
+
# In your frontend, add this button:
|
| 34 |
+
refresh_btn = gr.Button("๐ Refresh Transcription")
|
| 35 |
+
clear_btn = gr.Button("๐ Clear Text", variant="stop")
|
| 36 |
+
status = gr.Textbox(label="Status", interactive=False)
|
| 37 |
+
|
| 38 |
+
with gr.Row():
|
| 39 |
+
transcription_display = gr.Textbox(
|
| 40 |
+
label="Live Transcription",
|
| 41 |
+
lines=15,
|
| 42 |
+
max_lines=20,
|
| 43 |
+
interactive=False,
|
| 44 |
+
placeholder="Transcription will appear here live..."
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
# Auto-refresh the transcription display every second
|
| 48 |
+
demo.load(
|
| 49 |
+
fn=update_display,
|
| 50 |
+
outputs=transcription_display,
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
# Button actions
|
| 54 |
+
start_btn.click(
|
| 55 |
+
fn=handle_start_listening,
|
| 56 |
+
outputs=status
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
stop_btn.click(
|
| 60 |
+
fn=handle_stop_listening,
|
| 61 |
+
outputs=status
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# Add this click event:
|
| 66 |
+
refresh_btn.click(
|
| 67 |
+
fn=update_display,
|
| 68 |
+
outputs=transcription_display
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
clear_btn.click(
|
| 72 |
+
fn=handle_clear_transcription,
|
| 73 |
+
outputs=status
|
| 74 |
+
).then(
|
| 75 |
+
fn=update_display,
|
| 76 |
+
outputs=transcription_display
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
if __name__ == "__main__":
|
| 80 |
+
demo.launch(
|
| 81 |
+
server_name="0.0.0.0",
|
| 82 |
+
server_port=7860,
|
| 83 |
+
share=True
|
| 84 |
+
)
|