gaur3009 commited on
Commit
b840602
·
verified ·
1 Parent(s): 23c62ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -29
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # app.py (Final Working Version)
2
  import gradio as gr
3
  import threading
4
  import queue
@@ -21,6 +21,7 @@ class MeetingProcessor:
21
  self.action_items = []
22
  self.urgent_alerts = []
23
  self.transcript_queue = queue.Queue()
 
24
  self.last_update = time.time()
25
 
26
  def start_processing(self):
@@ -33,6 +34,7 @@ class MeetingProcessor:
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()
@@ -87,8 +89,8 @@ class MeetingProcessor:
87
  self.urgent_alerts.extend(urgent_items)
88
  self.notifier.send_urgent_alert(urgent_items)
89
 
90
- # Update timestamp for UI
91
- self.last_update = time.time()
92
  except queue.Empty:
93
  continue
94
 
@@ -114,6 +116,9 @@ class MeetingProcessor:
114
  recipients=config.NOTIFICATION_RECIPIENTS
115
  )
116
 
 
 
 
117
  return "Meeting processing stopped! Report sent. ✅"
118
 
119
  def get_current_status(self):
@@ -154,8 +159,7 @@ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
154
  start_btn = gr.Button("Start Meeting", variant="primary")
155
  stop_btn = gr.Button("Stop Meeting", variant="stop")
156
  status_text = gr.Textbox(label="Status", interactive=False)
157
- refresh_btn = gr.Button("Refresh", variant="secondary")
158
- last_update = gr.State(value=0) # Track last update time
159
 
160
  with gr.Row():
161
  with gr.Column():
@@ -182,7 +186,7 @@ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
182
  for item in current_status["alerts"]
183
  ) if current_status["alerts"] else "No urgent alerts",
184
  current_status["summary"],
185
- time.time() # Update timestamp
186
  ]
187
 
188
  # Button actions
@@ -191,9 +195,16 @@ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
191
  inputs=[],
192
  outputs=[status_text]
193
  ).then(
194
- fn=lambda: 0,
195
  inputs=[],
196
- outputs=[last_update]
 
 
 
 
 
 
 
197
  )
198
 
199
  stop_btn.click(
@@ -209,7 +220,7 @@ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
209
  action_items_box,
210
  alerts_box,
211
  summary_box,
212
- last_update
213
  ]
214
  )
215
 
@@ -223,30 +234,36 @@ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
223
  action_items_box,
224
  alerts_box,
225
  summary_box,
226
- last_update
227
  ]
228
  )
229
 
230
- # Auto-refresh when meeting is running
231
- def check_for_updates(last_update_time):
232
- if processor.running and processor.last_update > last_update_time:
233
- return update_components() + [processor.last_update]
234
- return [gr.update()] * 5 + [last_update_time]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
- # Set up periodic auto-refresh
237
- app.load(
238
- fn=check_for_updates,
239
- inputs=[last_update],
240
- outputs=[
241
- duration_display,
242
- transcript_box,
243
- action_items_box,
244
- alerts_box,
245
- summary_box,
246
- last_update
247
- ],
248
- every=1
249
- )
250
 
251
  if __name__ == "__main__":
252
  app.launch()
 
1
+ # app.py (Working Version without 'every' parameter)
2
  import gradio as gr
3
  import threading
4
  import queue
 
21
  self.action_items = []
22
  self.urgent_alerts = []
23
  self.transcript_queue = queue.Queue()
24
+ self.ui_update_event = threading.Event()
25
  self.last_update = time.time()
26
 
27
  def start_processing(self):
 
34
  self.summary = ""
35
  self.action_items = []
36
  self.urgent_alerts = []
37
+ self.ui_update_event.set() # Trigger UI update
38
 
39
  # Start processing threads
40
  threading.Thread(target=self._audio_capture_thread, daemon=True).start()
 
89
  self.urgent_alerts.extend(urgent_items)
90
  self.notifier.send_urgent_alert(urgent_items)
91
 
92
+ # Trigger UI update
93
+ self.ui_update_event.set()
94
  except queue.Empty:
95
  continue
96
 
 
116
  recipients=config.NOTIFICATION_RECIPIENTS
117
  )
118
 
119
+ # Trigger final UI update
120
+ self.ui_update_event.set()
121
+
122
  return "Meeting processing stopped! Report sent. ✅"
123
 
124
  def get_current_status(self):
 
159
  start_btn = gr.Button("Start Meeting", variant="primary")
160
  stop_btn = gr.Button("Stop Meeting", variant="stop")
161
  status_text = gr.Textbox(label="Status", interactive=False)
162
+ refresh_btn = gr.Button("Refresh Now", variant="secondary")
 
163
 
164
  with gr.Row():
165
  with gr.Column():
 
186
  for item in current_status["alerts"]
187
  ) if current_status["alerts"] else "No urgent alerts",
188
  current_status["summary"],
189
+ "Recording" if processor.running else "Stopped"
190
  ]
191
 
192
  # Button actions
 
195
  inputs=[],
196
  outputs=[status_text]
197
  ).then(
198
+ update_components,
199
  inputs=[],
200
+ outputs=[
201
+ duration_display,
202
+ transcript_box,
203
+ action_items_box,
204
+ alerts_box,
205
+ summary_box,
206
+ status_text
207
+ ]
208
  )
209
 
210
  stop_btn.click(
 
220
  action_items_box,
221
  alerts_box,
222
  summary_box,
223
+ status_text
224
  ]
225
  )
226
 
 
234
  action_items_box,
235
  alerts_box,
236
  summary_box,
237
+ status_text
238
  ]
239
  )
240
 
241
+ # Auto-refresh thread
242
+ def auto_refresh():
243
+ while True:
244
+ # Wait for update event
245
+ processor.ui_update_event.wait()
246
+ processor.ui_update_event.clear()
247
+
248
+ # Update the UI components
249
+ app.queue().put(
250
+ update_components,
251
+ inputs=[],
252
+ outputs=[
253
+ duration_display,
254
+ transcript_box,
255
+ action_items_box,
256
+ alerts_box,
257
+ summary_box,
258
+ status_text
259
+ ]
260
+ )
261
+
262
+ # Sleep briefly to avoid excessive updates
263
+ time.sleep(0.5)
264
 
265
+ # Start the auto-refresh thread
266
+ threading.Thread(target=auto_refresh, daemon=True).start()
 
 
 
 
 
 
 
 
 
 
 
 
267
 
268
  if __name__ == "__main__":
269
  app.launch()