Added context match

This commit is contained in:
Charles Wambua
2026-06-26 15:38:09 +03:00
parent dba78a2766
commit 138580475c
6 changed files with 294 additions and 58 deletions

52
main.py
View File

@@ -102,9 +102,13 @@ class MeetingAssistant:
on_disarm=self.audio_listener.disarm,
on_capture=self.overlay.request_capture, # marshals onto Qt thread
on_toggle=self.overlay.request_toggle, # marshals onto Qt thread
on_summary=self._handle_summary, # spawns its own worker thread
on_listen=self._handle_toggle_listen, # switch auto-listen / push-to-talk
ptt_key=audio_cfg.get("ptt_key", "alt_r"),
capture_key=screen_cfg.get("capture_key", "ctrl+shift+space"),
toggle_key=hotkeys_cfg.get("toggle_overlay", "ctrl+shift+h"),
summary_key=hotkeys_cfg.get("meeting_summary", "ctrl+shift+s"),
listen_key=hotkeys_cfg.get("toggle_listening", "ctrl+shift+m"),
)
# Screen-capture handler runs on the Qt main thread (via the overlay bridge)
self.overlay.on_capture = self._handle_screen_capture
@@ -121,11 +125,15 @@ class MeetingAssistant:
mode = audio_cfg.get("capture_mode", "push_to_talk")
print("✅ Meeting Assistant Ready!")
print("==================================================")
listen_key = hotkeys_cfg.get("toggle_listening", "ctrl+shift+m")
if mode == "push_to_talk":
print(f"🎙️ Hold [{ptt}] to capture audio, release to answer")
else:
print("🎤 Listening continuously for questions")
print("🎤 Auto-listening (no key needed)")
print(f"🔁 Press [{listen_key}] to toggle auto-listen ⇄ push-to-talk")
print(f"📸 Press [{cap}] then drag a box over an on-screen question")
summ = hotkeys_cfg.get("meeting_summary", "ctrl+shift+s")
print(f"📝 Press [{summ}] for a summary of the meeting so far")
print(" Answers appear in the overlay (top-right)")
print(" Type a question here + Enter to test AI")
print(" Ctrl+C to stop")
@@ -314,6 +322,48 @@ class MeetingAssistant:
except Exception:
pass
# ------------------------------------------------------------------
# End-of-meeting summary
# ------------------------------------------------------------------
def _handle_toggle_listen(self):
"""Hotkey handler: switch between auto-listen and push-to-talk."""
on = self.audio_listener.toggle_auto_listen()
if on:
self.overlay.show_status("🔊 Auto-listen ON — listening on its own")
else:
self.overlay.show_status("🎙️ Push-to-talk — hold the key to capture")
def _handle_summary(self):
"""Hotkey handler (pynput thread): summarize the meeting in the background."""
threading.Thread(target=self._summary_worker, daemon=True).start()
def _summary_worker(self):
transcript = self.context_manager.get_full_transcript()
if not transcript:
self.overlay.show_status("No meeting captured yet — nothing to summarize.")
print(" (No transcript captured yet.)")
return
with self.answer_lock:
if self.answering and hasattr(self.ai_engine, "interrupt"):
self.ai_engine.interrupt()
self.answering = True
try:
self.overlay.show_status("📝 Summarizing the meeting...")
print("\n📝 Summarizing the meeting...")
summary = self.ai_engine.summarize_meeting(transcript)
if not summary:
return
self.overlay.show_answer(summary, "Meeting summary", suggested=False)
self.logger.info("Meeting summary generated.")
self.logger.info(f"Summary: {summary}")
print(f"\n📋 Meeting Summary:\n{summary}\n")
except Exception as e:
print(f"❌ Error summarizing meeting: {e}")
finally:
with self.answer_lock:
self.answering = False
# ------------------------------------------------------------------
# Manual terminal input for testing
# ------------------------------------------------------------------