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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -20
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # app.py (Updated Gradio UI)
2
  import gradio as gr
3
  import threading
4
  import queue
@@ -21,7 +21,7 @@ class MeetingProcessor:
21
  self.action_items = []
22
  self.urgent_alerts = []
23
  self.transcript_queue = queue.Queue()
24
- self.last_update_time = 0
25
 
26
  def start_processing(self):
27
  if self.running:
@@ -33,7 +33,6 @@ class MeetingProcessor:
33
  self.summary = ""
34
  self.action_items = []
35
  self.urgent_alerts = []
36
- self.last_update_time = time.time()
37
 
38
  # Start processing threads
39
  threading.Thread(target=self._audio_capture_thread, daemon=True).start()
@@ -89,7 +88,7 @@ class MeetingProcessor:
89
  self.notifier.send_urgent_alert(urgent_items)
90
 
91
  # Update timestamp for UI
92
- self.last_update_time = time.time()
93
  except queue.Empty:
94
  continue
95
 
@@ -155,12 +154,13 @@ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
155
  start_btn = gr.Button("Start Meeting", variant="primary")
156
  stop_btn = gr.Button("Stop Meeting", variant="stop")
157
  status_text = gr.Textbox(label="Status", interactive=False)
 
 
158
 
159
  with gr.Row():
160
  with gr.Column():
161
  duration_display = gr.Textbox(label="Duration", interactive=False)
162
  transcript_box = gr.Textbox(label="Live Transcript", lines=8, interactive=False)
163
- refresh_btn = gr.Button("Refresh", variant="secondary")
164
 
165
  with gr.Column():
166
  alerts_box = gr.Textbox(label="Urgent Alerts", lines=3, interactive=False)
@@ -182,7 +182,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
- status_text.value
186
  ]
187
 
188
  # Button actions
@@ -190,17 +190,32 @@ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
190
  fn=processor.start_processing,
191
  inputs=[],
192
  outputs=[status_text]
 
 
 
 
193
  )
194
 
195
  stop_btn.click(
196
  fn=processor.stop_processing,
197
  inputs=[],
198
  outputs=[status_text]
 
 
 
 
 
 
 
 
 
 
 
199
  )
200
 
201
  # Refresh button action
202
  refresh_btn.click(
203
- fn=update_components,
204
  inputs=[],
205
  outputs=[
206
  duration_display,
@@ -208,25 +223,30 @@ with gr.Blocks(title="Real-Time Meeting Summarizer", theme="soft") as app:
208
  action_items_box,
209
  alerts_box,
210
  summary_box,
211
- status_text
212
  ]
213
  )
214
 
215
  # Auto-refresh when meeting is running
216
- def auto_refresh():
217
- if processor.running:
218
- return update_components()
219
- return [gr.update()] * 6 # Return no updates
220
 
221
  # Set up periodic auto-refresh
222
- app.load(auto_refresh, inputs=None, outputs=[
223
- duration_display,
224
- transcript_box,
225
- action_items_box,
226
- alerts_box,
227
- summary_box,
228
- status_text
229
- ], every=1)
 
 
 
 
 
230
 
231
  if __name__ == "__main__":
232
  app.launch()
 
1
+ # app.py (Final Working Version)
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.last_update = time.time()
25
 
26
  def start_processing(self):
27
  if self.running:
 
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()
 
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
 
 
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():
162
  duration_display = gr.Textbox(label="Duration", interactive=False)
163
  transcript_box = gr.Textbox(label="Live Transcript", lines=8, interactive=False)
 
164
 
165
  with gr.Column():
166
  alerts_box = gr.Textbox(label="Urgent Alerts", lines=3, interactive=False)
 
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
 
190
  fn=processor.start_processing,
191
  inputs=[],
192
  outputs=[status_text]
193
+ ).then(
194
+ fn=lambda: 0,
195
+ inputs=[],
196
+ outputs=[last_update]
197
  )
198
 
199
  stop_btn.click(
200
  fn=processor.stop_processing,
201
  inputs=[],
202
  outputs=[status_text]
203
+ ).then(
204
+ update_components,
205
+ inputs=[],
206
+ outputs=[
207
+ duration_display,
208
+ transcript_box,
209
+ action_items_box,
210
+ alerts_box,
211
+ summary_box,
212
+ last_update
213
+ ]
214
  )
215
 
216
  # Refresh button action
217
  refresh_btn.click(
218
+ update_components,
219
  inputs=[],
220
  outputs=[
221
  duration_display,
 
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()