mirror of
https://github.com/myronblair/jarvis
synced 2026-07-28 16:52:46 -05:00
fix: voice — any speech = command when awake (no prefix lock), open window on wake, transcript preview in input
This commit is contained in:
+13
-9
@@ -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;
|
|
||||||
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();
|
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;
|
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user