feat: TTS backend abstraction + 4 'imba' features + Lua packs
Big push driven by user feedback ("делай имбу") and web research on what
voice assistants need to be the ideal:
TTS backend abstraction (P0.1)
- new module crates/jarvis-core/src/tts/{mod,sapi,piper,silero}.rs
- TtsBackend trait with SapiBackend (current PowerShell), PiperBackend
(rhasspy/piper, neural quality), SileroBackend (python subprocess)
- JARVIS_TTS env var picks (sapi|piper|silero). Auto-detect Piper if
binary + voice present in tools/piper/. Falls back to SAPI on missing.
- SpeakOpts {lang, detached, raw} replaces ad-hoc args. text_utils
sanitiser applied unless raw=true.
- llm_fallback + lua/api/tts both routed through tts::backend().
- tools/piper/install.ps1 downloads piper.exe + ru_RU-irina-medium.onnx
from rhasspy releases + huggingface. Smoke-test included.
- tools/silero/silero_tts.py helper (PyTorch); rust spawns it as subprocess.
IMBA-1 Agentic LLM router
- crates/jarvis-app/src/llm_router.rs
- When fuzzy/intent matcher fails, LLM picks the closest command from the
full registry. Returns JSON {command_id, confidence, reason}.
- Threshold-gated re-dispatch via substitute phrase. JARVIS_LLM_ROUTER=1
enables; JARVIS_LLM_ROUTER_THRESHOLD overrides 0.55 default.
- Inserted in app.rs::execute_command between "no match" and existing
llm_fallback chat fallback.
IMBA-2 Long-term memory
- crates/jarvis-core/src/long_term_memory.rs — JSON store at
APP_CONFIG_DIR/long_term_memory.json. Atomic write-through.
- remember/recall/search/forget/all/build_context API.
- Lua bindings: jarvis.memory.* (5 functions).
- llm_fallback auto-injects relevant facts (substring search of prompt)
into system message before LLM call.
- Pack resources/commands/memory_pack/ with 4 commands: remember, recall,
forget, list.
IMBA-3 Profile switching (work/game/sleep/driving/default)
- crates/jarvis-core/src/profiles.rs — JSON profiles at APP_CONFIG_DIR/profiles/
Auto-seeds 5 defaults on first run with personality + allow/deny lists +
greetings + emoji icons.
- active_profile.txt persists choice across restart.
- Lua bindings: jarvis.profile.{active,set,list,allows,active_name}.
- llm_fallback prepends profile personality to system prompt.
- Pack resources/commands/profile_switch/ with 6 voice triggers.
IMBA-4 Multimodal screenshot + vision LLM
- crates/jarvis-core/src/lua/api/vision.rs — gated on HTTP sandbox.
- jarvis.vision.screenshot() captures via PowerShell System.Drawing.
- jarvis.vision.describe(prompt?) sends base64 PNG to Groq vision model
(default llama-3.2-11b-vision-preview, override via GROQ_VISION_MODEL).
- Pack resources/commands/vision/ with 2 commands: describe + read_error.
P0.2 Continuous conversation grace window
- config::CONVERSATION_GRACE_MS = 30_000.
- app.rs: after command result, if grace_ms > 0 keep listening WITHOUT
re-wake for the grace duration. Existing CMS_WAIT_DELAY back-dated so
the existing timeout fires at start + grace_ms.
Tests: 24/24 jarvis-core unit tests pass (including 5 text_utils).
Build: cargo build --release -p jarvis-app and -p jarvis-gui both succeed
on Windows MSVC (VS 2026 Enterprise vcvars64).
Notes for setup:
- Piper voice install: pwsh tools/piper/install.ps1 (downloads ~90 MB).
- GROQ_TOKEN needed for IMBA-1 (router) and IMBA-4 (vision).
- All features are opt-in via env vars or auto-detect; existing SAPI +
fuzzy match path remains the default.
This commit is contained in:
parent
80b54af1ee
commit
0b1f1d4480
34 changed files with 2304 additions and 90 deletions
|
|
@ -323,21 +323,45 @@ fn recognize_command(
|
|||
// execute command and check if we should chain
|
||||
let should_chain = execute_command(&recognized_voice, rt);
|
||||
|
||||
if should_chain {
|
||||
// chain: reset and continue listening
|
||||
info!("Chaining enabled, continuing to listen...");
|
||||
let grace_ms = jarvis_core::config::CONVERSATION_GRACE_MS;
|
||||
if should_chain || grace_ms > 0 {
|
||||
// Either explicit chain OR P0.2 continuous-conversation grace window.
|
||||
// Reset listening state and keep going without re-wake.
|
||||
if should_chain {
|
||||
info!("Chain requested, continuing to listen...");
|
||||
} else {
|
||||
info!(
|
||||
"Continuous conversation: {}ms grace window for follow-up.",
|
||||
grace_ms
|
||||
);
|
||||
}
|
||||
stt::reset_speech_recognizer();
|
||||
vad_state = VadState::WaitingForVoice;
|
||||
silence_frames = 0;
|
||||
start = SystemTime::now();
|
||||
// For grace-mode, shorten the deadline to grace_ms (instead of CMS_WAIT_DELAY).
|
||||
// We set `start` such that the existing timeout check (line ~360) fires at
|
||||
// start + CMS_WAIT_DELAY = now + grace_ms.
|
||||
if !should_chain {
|
||||
let cms = jarvis_core::config::CMS_WAIT_DELAY.as_millis() as u64;
|
||||
if grace_ms < cms {
|
||||
// back-date `start` so the existing timeout fires at now + grace_ms
|
||||
let backdate_ms = cms - grace_ms;
|
||||
start = SystemTime::now()
|
||||
.checked_sub(std::time::Duration::from_millis(backdate_ms))
|
||||
.unwrap_or_else(SystemTime::now);
|
||||
} else {
|
||||
start = SystemTime::now();
|
||||
}
|
||||
} else {
|
||||
start = SystemTime::now();
|
||||
}
|
||||
audio_buffer.clear();
|
||||
webrtc_vad.reset();
|
||||
window = ListenWindow::new(jarvis_core::audio_processing::vad::webrtc::FRAME_MS);
|
||||
ipc::send(IpcEvent::Listening);
|
||||
continue;
|
||||
} else {
|
||||
// no chain: return to wake word
|
||||
info!("No chain, returning to wake word mode.");
|
||||
info!("Conversation grace disabled, returning to wake word mode.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -460,6 +484,26 @@ fn execute_command(text: &str, rt: &tokio::runtime::Runtime) -> bool {
|
|||
} else {
|
||||
info!("No command found for: {}", text);
|
||||
|
||||
// IMBA-1: Agentic LLM router — try to map unknown phrase to a known command
|
||||
// by asking the LLM. This is the killer feature competitors don't have.
|
||||
if crate::llm_router::is_enabled() {
|
||||
if let Some(routed) = crate::llm_router::try_route(text) {
|
||||
info!(
|
||||
"Router → {} ({}%): {} | substitute='{}'",
|
||||
routed.command_id,
|
||||
(routed.confidence * 100.0) as u32,
|
||||
routed.reason,
|
||||
routed.substitute_phrase
|
||||
);
|
||||
|
||||
// Re-dispatch with the canonical phrase for the chosen command.
|
||||
// Guard against infinite recursion: pass a marker if needed.
|
||||
if routed.substitute_phrase != text {
|
||||
return execute_command(&routed.substitute_phrase, rt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if jarvis_core::config::LLM_AUTO_FALLBACK
|
||||
&& crate::llm_fallback::is_enabled()
|
||||
&& text.chars().count() >= jarvis_core::config::LLM_AUTO_FALLBACK_MIN_CHARS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue