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 (!voiceMode) {
if (WAKE_PHRASES.some(p => lc.includes(p))) enterVoiceMode(); if (WAKE_PHRASES.some(p => lc.includes(p))) enterVoiceMode();
} else if (!voiceMuted) { } else if (!voiceMuted) {
// Awake — any speech is a command; strip optional "jarvis" prefix
voiceLastCmd = Date.now(); voiceLastCmd = Date.now();
const inWindow = voiceActive > 0 && (Date.now() - voiceActive) < VOICE_ACTIVE_MS; voiceActive = Date.now();
let cmd = null; const cmd = lc.startsWith(CMD_PREFIX)
if (lc.startsWith(CMD_PREFIX)) { ? transcript.substring(CMD_PREFIX.length).trim()
cmd = transcript.substring(CMD_PREFIX.length).trim(); : transcript;
} else if (inWindow) {
cmd = transcript;
}
if (cmd) { if (cmd) {
voiceActive = Date.now(); _showTranscript(cmd);
document.getElementById('textInput').value = cmd; document.getElementById('textInput').value = cmd;
sendMessage(); 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() { function enterVoiceMode() {
voiceMode = true; voiceMode = true;
voiceMuted = false; voiceMuted = false;
voiceLastCmd = Date.now(); voiceLastCmd = Date.now();
voiceActive = Date.now(); // open free-listen window immediately on wake
updateMicBtn(); updateMicBtn();
speak('Yes, ' + (sessionUser || 'Sir') + '?'); speak('Yes, ' + (sessionUser || 'Sir') + '?');
} }
@@ -1838,7 +1842,7 @@ function updateMicBtn() {
if (!btn) return; if (!btn) return;
if (!voiceMode) { if (!voiceMode) {
btn.classList.remove('listening', 'muted'); 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 = '🎤'; icon.textContent = '🎤';
wave.classList.remove('active'); wave.classList.remove('active');
} else if (voiceMuted) { } else if (voiceMuted) {