diff --git a/modules/features/teamsbot/service.py b/modules/features/teamsbot/service.py index 4e68a9d7..6a9db449 100644 --- a/modules/features/teamsbot/service.py +++ b/modules/features/teamsbot/service.py @@ -778,6 +778,12 @@ class TeamsbotService: if self.config.responseMode == TeamsbotResponseMode.TRANSCRIBE_ONLY: return + # Stop phrases: trigger immediately without debounce (root cause: 3s debounce delayed stop) + if self._isStopPhrase(text): + logger.info(f"Session {sessionId}: Stop phrase detected, triggering analysis immediately") + await self._analyzeAndRespond(sessionId, interface, voiceInterface, websocket, createdTranscript) + return + # Update activity for any pending debounced trigger if self._pendingNameTrigger: self._pendingNameTrigger["lastActivity"] = time.time() @@ -855,6 +861,20 @@ class TeamsbotService: return False + def _isStopPhrase(self, text: str) -> bool: + """Check if text is a stop command (stop, halt, be quiet, etc.). Triggers immediate analysis.""" + if not text or len(text.strip()) < 2: + return False + t = text.strip().lower() + words = [w.strip(".,!?:;\"'()[]") for w in t.split() if w.strip()] + wordSet = set(words) + stopWords = {"stop", "stopp", "halt", "ruhe", "stille", "schweig", "arrete", "quiet", "shut"} + if wordSet & stopWords: + return True + if "sei still" in t or "be quiet" in t or "shut up" in t or "aufhoeren" in t or "aufhören" in t: + return True + return False + def _detectBotName(self, text: str) -> bool: """Check if text contains the bot's name (exact or phonetically similar).""" botNameLower = self.config.botName.lower()