| | |
| | import time |
| | import threading |
| | import random |
| | from datetime import datetime |
| | from typing import Callable |
| |
|
| | class ZoomTranscriptionBackend: |
| | def __init__(self): |
| | self.is_listening = False |
| | self.transcription_text = "" |
| | self.speakers = ["Alice", "Bob", "Carol", "David"] |
| | self.on_update_callback = None |
| | |
| | def set_update_callback(self, callback: Callable): |
| | """Set callback function when new transcription arrives""" |
| | self.on_update_callback = callback |
| | |
| | def start_listening(self): |
| | """Start Zoom RTMS connection (simulated for now)""" |
| | if self.is_listening: |
| | return "Already listening to meeting!" |
| | |
| | self.is_listening = True |
| | self.transcription_text = "๐ด Listening to Zoom meeting...\n\n" |
| | |
| | |
| | threading.Thread(target=self._simulate_transcription, daemon=True).start() |
| | |
| | return "โ
Connected to Zoom meeting! Live transcription starting..." |
| | |
| | def _simulate_transcription(self): |
| | """Simulate real Zoom RTMS transcription""" |
| | sample_phrases = [ |
| | "Okay team, let's start the meeting", |
| | "I think we should focus on Q4 goals first", |
| | "The budget looks good but we need to cut costs", |
| | "Let's schedule follow-up for next week", |
| | "Anyone have questions about the timeline?", |
| | ] |
| | |
| | while self.is_listening: |
| | time.sleep(random.uniform(3, 5)) |
| | |
| | if not self.is_listening: |
| | break |
| | |
| | speaker = random.choice(self.speakers) |
| | phrase = random.choice(sample_phrases) |
| | timestamp = datetime.now().strftime("%H:%M:%S") |
| | |
| | new_transcript = f"[{timestamp}] {speaker}: {phrase}\n" |
| | self.transcription_text += new_transcript |
| | |
| | |
| | if self.on_update_callback: |
| | self.on_update_callback(self.transcription_text) |
| | |
| | def stop_listening(self): |
| | """Stop the transcription""" |
| | self.is_listening = False |
| | return "โน๏ธ Stopped listening to meeting" |
| | |
| | def get_transcription(self): |
| | """Get current transcription text""" |
| | return self.transcription_text |
| | |
| | def clear_transcription(self): |
| | """Clear all transcription text""" |
| | self.transcription_text = "" |
| | return "๐ Transcription cleared" |