gaur3009 commited on
Commit
6574244
·
verified ·
1 Parent(s): 14505b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +155 -62
app.py CHANGED
@@ -1,9 +1,10 @@
1
- # File: main.py (Enhanced Entry Point)
 
2
  import time
3
  import threading
4
  import queue
5
  from audio_capture import AudioRecorder
6
- from transcriber import WhisperTranscriber
7
  from analyzer import MeetingAnalyzer
8
  from integrations import Notifier
9
  import config
@@ -11,88 +12,180 @@ import config
11
  class MeetingProcessor:
12
  def __init__(self):
13
  self.recorder = AudioRecorder()
14
- self.transcriber = WhisperTranscriber()
15
  self.analyzer = MeetingAnalyzer()
16
  self.notifier = Notifier()
17
  self.transcript_queue = queue.Queue()
 
 
 
 
 
 
 
 
 
 
 
18
  self.running = True
 
 
 
 
 
19
 
20
  # Start processing threads
21
- threading.Thread(target=self._transcription_worker, daemon=True).start()
22
- threading.Thread(target=self._analysis_worker, daemon=True).start()
 
23
 
24
- def _transcription_worker(self):
 
 
 
25
  while self.running:
26
- audio_chunk = self.recorder.get_audio_chunk()
27
- if audio_chunk:
28
- try:
29
- transcript = self.transcriber.transcribe(audio_chunk)
30
- if transcript:
31
- self.transcript_queue.put(transcript)
32
- except Exception as e:
33
- print(f"Transcription error: {str(e)}")
34
  time.sleep(0.1)
35
 
36
- def _analysis_worker(self):
 
 
 
 
 
 
 
 
37
  while self.running:
38
  try:
39
  transcript = self.transcript_queue.get(timeout=1.0)
40
  self.analyzer.process_chunk(transcript)
41
- # Real-time action item detection
42
- urgent_items = self.analyzer.detect_urgent_action_items()
43
- if urgent_items:
44
- print("\n🚨 URGENT ACTION ITEM DETECTED!")
45
- for item in urgent_items:
46
- print(f"• {item['task']} (Owner: {item['owner']}, Deadline: {item['deadline']})")
47
- self.notifier.send_urgent_alert(urgent_items)
48
  except queue.Empty:
49
  continue
50
 
51
- def start(self):
52
- print("🎤 Starting meeting processing... Press Ctrl+C to end meeting")
53
- self.recorder.start_recording()
54
-
55
- try:
56
- # Keep main thread alive
57
- while True:
58
- time.sleep(1)
59
- except KeyboardInterrupt:
60
- print("\n⏹️ Meeting ended. Generating final report...")
61
- self.running = False
62
- self._finalize_processing()
63
-
64
- def _finalize_processing(self):
65
- # Process remaining audio
66
- final_audio = self.recorder.stop_recording()
67
- if final_audio:
68
- final_transcript = self.transcriber.transcribe_final(final_audio)
69
- if final_transcript:
70
- self.analyzer.process_chunk(final_transcript)
71
-
72
- # Generate AI analysis
73
- full_transcript = self.analyzer.get_full_transcript()
74
- summary = self.analyzer.generate_summary()
75
- action_items = self.analyzer.extract_action_items()
76
- decisions = self.analyzer.extract_decisions()
77
 
78
- # Display results
79
- print("\n📝 Final Meeting Summary:")
80
- print(summary)
81
- print("\n✅ Action Items:")
82
- for i, item in enumerate(action_items, 1):
83
- print(f"{i}. {item['task']} (Owner: {item['owner']}, Deadline: {item['deadline']})")
84
 
85
- # Send comprehensive report
86
  self.notifier.send_comprehensive_report(
87
- summary=summary,
88
- action_items=action_items,
89
- decisions=decisions,
90
- transcript=full_transcript,
91
  recipients=config.NOTIFICATION_RECIPIENTS
92
  )
93
 
94
- print("\n🚀 Comprehensive report sent to all recipients!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  if __name__ == "__main__":
97
- processor = MeetingProcessor()
98
- processor.start()
 
1
+ # app.py (Gradio UI Application)
2
+ import gradio as gr
3
  import time
4
  import threading
5
  import queue
6
  from audio_capture import AudioRecorder
7
+ from transcriber import SpeechTranscriber
8
  from analyzer import MeetingAnalyzer
9
  from integrations import Notifier
10
  import config
 
12
  class MeetingProcessor:
13
  def __init__(self):
14
  self.recorder = AudioRecorder()
15
+ self.transcriber = SpeechTranscriber()
16
  self.analyzer = MeetingAnalyzer()
17
  self.notifier = Notifier()
18
  self.transcript_queue = queue.Queue()
19
+ self.running = False
20
+ self.start_time = None
21
+ self.transcript_history = []
22
+ self.summary = ""
23
+ self.action_items = []
24
+ self.urgent_alerts = []
25
+
26
+ def start_processing(self):
27
+ if self.running:
28
+ return "Already running!"
29
+
30
  self.running = True
31
+ self.start_time = time.time()
32
+ self.transcript_history = []
33
+ self.summary = ""
34
+ self.action_items = []
35
+ self.urgent_alerts = []
36
 
37
  # Start processing threads
38
+ threading.Thread(target=self._audio_capture_thread, daemon=True).start()
39
+ threading.Thread(target=self._transcription_thread, daemon=True).start()
40
+ threading.Thread(target=self._analysis_thread, daemon=True).start()
41
 
42
+ return "Meeting processing started! 🎤"
43
+
44
+ def _audio_capture_thread(self):
45
+ self.recorder.start_recording()
46
  while self.running:
47
+ chunk = self.recorder.get_audio_chunk()
48
+ if chunk:
49
+ self.transcriber.add_audio_chunk(chunk)
 
 
 
 
 
50
  time.sleep(0.1)
51
 
52
+ def _transcription_thread(self):
53
+ while self.running:
54
+ transcript = self.transcriber.get_transcript_chunk()
55
+ if transcript:
56
+ self.transcript_queue.put(transcript)
57
+ self.transcript_history.append(transcript)
58
+ time.sleep(0.5)
59
+
60
+ def _analysis_thread(self):
61
  while self.running:
62
  try:
63
  transcript = self.transcript_queue.get(timeout=1.0)
64
  self.analyzer.process_chunk(transcript)
65
+
66
+ # Check for urgent items periodically
67
+ if len(self.transcript_history) % 5 == 0:
68
+ urgent_items = self.analyzer.detect_urgent_action_items()
69
+ if urgent_items:
70
+ self.urgent_alerts.extend(urgent_items)
71
+ self.notifier.send_urgent_alert(urgent_items)
72
  except queue.Empty:
73
  continue
74
 
75
+ def stop_processing(self):
76
+ if not self.running:
77
+ return "Not running!"
78
+
79
+ self.running = False
80
+ self.recorder.stop_recording()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
+ # Generate final analysis
83
+ self.summary = self.analyzer.generate_summary()
84
+ self.action_items = self.analyzer.extract_action_items()
 
 
 
85
 
86
+ # Send final report
87
  self.notifier.send_comprehensive_report(
88
+ summary=self.summary,
89
+ action_items=self.action_items,
90
+ decisions=self.analyzer.extract_decisions(),
91
+ transcript="\n".join(self.transcript_history),
92
  recipients=config.NOTIFICATION_RECIPIENTS
93
  )
94
 
95
+ return "Meeting processing stopped! Report sent. "
96
+
97
+ def get_current_status(self):
98
+ if not self.running:
99
+ return {
100
+ "status": "Stopped",
101
+ "duration": "00:00",
102
+ "transcript": "",
103
+ "summary": self.summary,
104
+ "action_items": self.action_items,
105
+ "alerts": self.urgent_alerts
106
+ }
107
+
108
+ elapsed = time.time() - self.start_time
109
+ mins, secs = divmod(int(elapsed), 60)
110
+
111
+ # Only show last 5 transcript entries
112
+ recent_transcript = "\n".join(self.transcript_history[-5:])
113
+
114
+ return {
115
+ "status": "Recording",
116
+ "duration": f"{mins:02d}:{secs:02d}",
117
+ "transcript": recent_transcript,
118
+ "summary": self.summary if self.summary else "Summary will appear after meeting ends",
119
+ "action_items": self.action_items,
120
+ "alerts": self.urgent_alerts
121
+ }
122
+
123
+ # Initialize processor
124
+ processor = MeetingProcessor()
125
 
126
+ # Create Gradio interface
127
+ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
128
+ gr.Markdown("# 🎙️ Real-Time Meeting Summarizer")
129
+ gr.Markdown("Start this during any meeting to get live transcription and automatic summaries")
130
+
131
+ with gr.Row():
132
+ start_btn = gr.Button("Start Meeting", variant="primary")
133
+ stop_btn = gr.Button("Stop Meeting", variant="stop")
134
+ status_text = gr.Textbox(label="Status", interactive=False)
135
+
136
+ with gr.Row():
137
+ with gr.Column():
138
+ duration_display = gr.Textbox(label="Duration", interactive=False)
139
+ transcript_box = gr.Textbox(label="Live Transcript", lines=8, interactive=False)
140
+
141
+ with gr.Column():
142
+ alerts_box = gr.Textbox(label="Urgent Alerts", lines=3, interactive=False)
143
+ summary_box = gr.Textbox(label="Meeting Summary", lines=5, interactive=False)
144
+ action_items_box = gr.Textbox(label="Action Items", lines=5, interactive=False)
145
+
146
+ # State for live updates
147
+ state = gr.State(value=processor.get_current_status())
148
+
149
+ # Update function for live components
150
+ def update_components():
151
+ current_status = processor.get_current_status()
152
+ return {
153
+ duration_display: current_status["duration"],
154
+ transcript_box: current_status["transcript"],
155
+ summary_box: current_status["summary"],
156
+ action_items_box: "\n".join(
157
+ f"• {item['task']} (Owner: {item['owner']}, Deadline: {item['deadline']})"
158
+ for item in current_status["action_items"]
159
+ ),
160
+ alerts_box: "\n".join(
161
+ f"🚨 {item['task']} (Owner: {item['owner']}, Deadline: {item['deadline']})"
162
+ for item in current_status["alerts"]
163
+ ) if current_status["alerts"] else "No urgent alerts",
164
+ state: current_status
165
+ }
166
+
167
+ # Button actions
168
+ start_btn.click(
169
+ fn=processor.start_processing,
170
+ inputs=[],
171
+ outputs=[status_text]
172
+ )
173
+
174
+ stop_btn.click(
175
+ fn=processor.stop_processing,
176
+ inputs=[],
177
+ outputs=[status_text]
178
+ )
179
+
180
+ # Live updates
181
+ app.load(update_components, inputs=[state], outputs=[
182
+ duration_display,
183
+ transcript_box,
184
+ summary_box,
185
+ action_items_box,
186
+ alerts_box,
187
+ state
188
+ ], every=1)
189
+
190
  if __name__ == "__main__":
191
+ app.launch()