fix: voice — any speech = command when awake (no prefix lock), open window on wake, transcript preview in input

This commit is contained in:
2026-05-31 19:39:51 +00:00
parent 2ddce52c9a
commit 5b599b1617
+13 -9
View File
@@ -1780,16 +1780,14 @@ function initVoice() {
if (!voiceMode) {
if (WAKE_PHRASES.some(p => lc.includes(p))) enterVoiceMode();
} else if (!voiceMuted) {
// Awake — any speech is a command; strip optional "jarvis" prefix
voiceLastCmd = Date.now();
const inWindow = voiceActive > 0 && (Date.now() - voiceActive) < VOICE_ACTIVE_MS;
let cmd = null;
if (lc.startsWith(CMD_PREFIX)) {
cmd = transcript.substring(CMD_PREFIX.length).trim();
} else if (inWindow) {
cmd = transcript;
}
if (cmd) {
voiceActive = Date.now();
const cmd = lc.startsWith(CMD_PREFIX)
? transcript.substring(CMD_PREFIX.length).trim()
: transcript;
if (cmd) {
_showTranscript(cmd);
document.getElementById('textInput').value = cmd;
sendMessage();
}
@@ -1817,10 +1815,16 @@ function initVoice() {
};
}
function _showTranscript(text) {
const el = document.getElementById('textInput');
if (el) { el.placeholder = '▶ ' + text.substring(0, 60); setTimeout(() => { el.placeholder = 'Enter command or speak to JARVIS...'; }, 3000); }
}
function enterVoiceMode() {
voiceMode = true;
voiceMuted = false;
voiceLastCmd = Date.now();
voiceActive = Date.now(); // open free-listen window immediately on wake
updateMicBtn();
speak('Yes, ' + (sessionUser || 'Sir') + '?');
}
@@ -1838,7 +1842,7 @@ function updateMicBtn() {
if (!btn) return;
if (!voiceMode) {
btn.classList.remove('listening', 'muted');
btn.title = 'Click to activate or say "Hey JARVIS"';
btn.title = 'Click to activate, or say: wake up JARVIS / daddy\'s home';
icon.textContent = '🎤';
wave.classList.remove('active');
} else if (voiceMuted) {