From b0a6f2d2e943344ddab9d178716a330a5881220c Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Sun, 31 May 2026 16:38:27 +0000 Subject: [PATCH] =?UTF-8?q?feat:=2017s=20active=20listen=20window=20after?= =?UTF-8?q?=20command=20=E2=80=94=20no=20prefix=20needed=20for=20follow-up?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public_html/index.html | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/public_html/index.html b/public_html/index.html index 33d3901..9ba52b1 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -919,10 +919,12 @@ const IDLE_RELOAD_MS = 5 * 60 * 1000; // 5 min inactivity → full reload let voiceMode = false; // true = JARVIS awake (listening for commands) let voiceMuted = false; // true = awake but mic muted let voiceLastCmd = 0; -const VOICE_SLEEP_MS = 30 * 60 * 1000; // 30 min voice inactivity → sleep +const VOICE_SLEEP_MS = 30 * 60 * 1000; // 30 min voice inactivity → sleep +const VOICE_ACTIVE_MS = 17000; // 17s active window after each command +let voiceActive = 0; // timestamp of last issued command // Phase 1: full phrase required to wake from sleep const WAKE_PHRASES = ["wake up jarvis", "daddy's home", "wake up, jarvis", "daddys home"]; -// Phase 2: command prefix when awake — "jarvis " +// Phase 2: command prefix — "jarvis "; then 17s free-listen window const CMD_PREFIX = 'jarvis'; const FACE_MODEL_URL = 'https://cdn.jsdelivr.net/gh/justadudewhohacks/face-api.js@0.22.2/weights'; @@ -1747,14 +1749,19 @@ function initVoice() { // Sleeping — full wake phrase required if (WAKE_PHRASES.some(p => lc.includes(p))) enterVoiceMode(); } else if (!voiceMuted) { - // Awake — must start with "Jarvis" to trigger a command - voiceLastCmd = Date.now(); // any speech resets inactivity timer + // Awake — "Jarvis " triggers command; active window allows free speech + voiceLastCmd = Date.now(); // any detected speech resets 30-min sleep timer + const inWindow = voiceActive > 0 && (Date.now() - voiceActive) < VOICE_ACTIVE_MS; + let cmd = null; if (lc.startsWith(CMD_PREFIX)) { - const cmd = transcript.substring(CMD_PREFIX.length).trim(); - if (cmd) { - document.getElementById('textInput').value = cmd; - sendMessage(); - } + cmd = transcript.substring(CMD_PREFIX.length).trim(); + } else if (inWindow) { + cmd = transcript; // active window: no prefix needed + } + if (cmd) { + voiceActive = Date.now(); // reset 17s window + document.getElementById('textInput').value = cmd; + sendMessage(); } } };