The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed crates/openhuman-core/src/voice/README.md
Steven Enamakelf6e7837d73c1
diff --git a/crates/openhuman-core/src/voice/README.md b/crates/openhuman-core/src/voice/README.mdindex 0e820f20e3..1d466a19df 100644--- a/crates/openhuman-core/src/voice/README.md+++ b/crates/openhuman-core/src/voice/README.md@@ -22,9 +22,9 @@ has a local option (Piper) alongside the hosted proxy and third-party APIs.the default-ON `voice` Cargo feature. When the feature is off, [`stub`] takesits place and mirrors the subset of the public surface that always-on / othergated callers depend on (`server`, `dictation_listener`, `streaming`,-`reply_speech`, `cloud_transcribe`, `create_stt_provider`,-`effective_stt_provider`, `publish_ptt_transcript_committed`) with-no-op / disabled-error bodies. `compile_status::VOICE_COMPILED_IN` is+`reply_speech`, `cloud_transcribe`, `always_on`, `cli`,+`create_stt_provider`, `effective_stt_provider`,+`publish_ptt_transcript_committed`) with no-op / disabled-error bodies. `compile_status::VOICE_COMPILED_IN` isdeliberately ungated so a consumer that requires voice (the desktop shell) canassert at compile time that it did not silently get the stub build (#4901).Keeping the two surfaces in lockstep is enforced by the disabled-build check@@ -37,10 +37,10 @@ Keeping the two surfaces in lockstep is enforced by the disabled-build check| `mod.rs` | Module docstring, feature gate, and exports; re-exports inference-side voice submodules (`cloud_transcribe`, `local_speech`, `postprocess`, `streaming`); defines `cloud_transcribe_default_model()` (`"whisper-v1"`). || `types.rs` | RPC DTOs: `VoiceSpeechResult`, `VoiceTtsResult`, `VoiceStatus` + `From<LocalAi*>` conversions. || `ops.rs` | Business logic returning `RpcOutcome<T>`: `voice_status`, `voice_transcribe`, `voice_transcribe_bytes`, `voice_tts`, `normalize_extension`. |-| `factory/` | `SttProvider` / `TtsProvider` traits; cloud/piper/external implementations; `create_stt_provider` / `create_tts_provider`; `effective_*_provider`; slug:model parsing; `DEFAULT_STT_MODEL`, `DEFAULT_PIPER_VOICE`. Split into `entry.rs` (public entry points + constants), `traits.rs`, `stt_providers.rs`, `tts_providers.rs`, `helpers.rs`. |+| `factory/` | `SttProvider` / `TtsProvider` traits; cloud/piper/external implementations; `create_stt_provider` / `create_tts_provider`; `effective_*_provider`; slug:model parsing; `DEFAULT_STT_MODEL`, `DEFAULT_PIPER_VOICE`. Split into `entry.rs` (public entry points + constants), `traits.rs`, `stt_providers.rs` (`CloudSttProvider`, `ExternalSttProvider`), `tts_providers.rs` (`CloudTtsProvider`, `PiperTtsProvider`, `ExternalTtsProvider`), `helpers.rs` (`split_slug_model`, `effective_*_provider`, slug-keyed lookup in `config.voice_providers`). || `schemas/` | Controller schemas, registry exports, and all `handle_voice_*` / `handle_overlay_stt_notify` RPC handlers. Split into `registry.rs`, `params.rs`, `helpers.rs`, `handlers.rs` (+ `handlers/provider_server.rs`, `handlers/transcribe_tts.rs`). |-| `server.rs` | The `VoiceServer` dictation runtime: hotkey event loop, recording lifecycle, duration/silence/hallucination gates, background processing, global singleton (`global_server` / `try_global_server` / `start_if_enabled` / `run_standalone`). |-| `always_on.rs` | Phase 2 always-on listening: keeps the mic open continuously and uses VAD to carve utterances instead of gating on a hotkey. Owns the `cpal` stream and thread discipline; everything else (segmenting, resample, energies, wake-word gate) runs in the `tinyvoice` module. Opt-in (`config.voice_server.always_on_enabled`), pauses on screen lock. |+| `server.rs` (+ `server_part_01.rs`, `server_part_02.rs`) | The `VoiceServer` dictation runtime: hotkey event loop, recording lifecycle, duration/silence/hallucination gates, background processing, global singleton (`global_server` / `try_global_server` / `start_if_enabled` / `run_standalone`). |+| `always_on.rs` (+ `always_on_part_01.rs`, `always_on_part_02.rs`) | Phase 2 always-on listening: keeps the mic open continuously and uses VAD to carve utterances instead of gating on a hotkey. Owns the `cpal` stream and thread discipline; everything else (VAD session, resample, energies, WAV encode, wake-word gate, command/intent routing) runs in the `tinyvoice` module. Opt-in (`config.voice_server.always_on_enabled`); pauses while the screen is locked (macOS only — other platforms have no lock signal yet). || `bus.rs` | Publishes `DomainEvent::Voice(VoiceEvent::PttTranscriptCommitted)` via `publish_ptt_transcript_committed`. || `compile_status.rs` | `VOICE_COMPILED_IN` — see the gate section above. || `hotkey.rs` | rdev-based global hotkey listener; `ActivationMode` (Tap/Push), `HotkeyEvent`, `HotkeyCombination`, `parse_hotkey`, `start_listener`. |@@ -50,10 +50,10 @@ Keeping the two surfaces in lockstep is enforced by the disabled-build check| `dictation_listener.rs` | Core-side dictation broadcast bus: `DictationEvent`, `publish_dictation_event` / `subscribe_dictation_events`, `publish_transcription` / `subscribe_transcription_results`, rdev listener lifecycle (`start_if_enabled` / `stop`), `normalize_hotkey_for_rdev`. || `reply_speech.rs` | Agent reply synthesis via backend `/openai/v1/audio/speech`; `ReplySpeechResult`, `VisemeFrame`, `AlignmentFrame`, `ReplySpeechOptions`, `synthesize_reply`, tolerant response normalization. || `realtime.rs` | Mints a short-lived signed WebSocket URL from the backend's `/voice-agent/get-signed-url` so the desktop client can open an ElevenLabs Agents session directly (#5399); the provider API key never leaves the server. |-| `realtime_harness.rs` | `voice:harness` socket turn handler for realtime sessions: runs the local orchestrator agent (same brain as chat/meet) on each turn the backend relays from the ElevenLabs Custom-LLM proxy, streaming `voice:harness:delta` / `:done` / `:error` back. |+| `realtime_harness.rs` (+ `realtime_harness_part_01.rs`, `realtime_harness_part_02.rs`) | `voice:harness` socket turn handler for realtime sessions: runs the local orchestrator agent (same brain as chat/meet) on each turn the backend relays from the ElevenLabs Custom-LLM proxy, streaming `voice:harness:delta` / `:done` / `:error` back. || `stub.rs` | Disabled-voice facade compiled when `voice` is OFF; mirrors the real public surface with no-op / error bodies. || `cli.rs` | `openhuman voice` / `openhuman dictate` subcommand adapter — runs a blocking standalone dictation server (domain-owned, since it blocks forever and doesn't fit the controller registry). |-| `*_tests.rs` | Sibling test suites wired via `#[path = ...]`: `always_on_tests.rs`, `audio_capture_tests.rs`, `bus_tests.rs`, `compile_status_tests.rs`, `dictation_listener_tests.rs`, `hotkey_tests.rs`, `ops_tests.rs`, `realtime_harness_tests.rs`, `realtime_tests.rs`, `reply_speech_tests.rs`, `schemas_tests.rs`, `server_tests.rs`, `text_input_tests.rs`, `types_tests.rs`; other files use inline `#[cfg(test)]`. |+| `*_tests.rs` | Sibling test suites wired via `#[path = ...]` (no inline `#[cfg(test)] mod` blocks — `pnpm rust:layout` rejects them): `always_on_tests.rs`, `audio_capture_tests.rs`, `bus_tests.rs`, `compile_status_tests.rs`, `dictation_listener_tests.rs`, `hotkey_tests.rs`, `ops_tests.rs`, `realtime_harness_tests.rs`, `realtime_tests.rs`, `reply_speech_tests.rs`, `schemas_tests.rs` (wired from `schemas/mod.rs`), `server_tests.rs`, `text_input_tests.rs`, `types_tests.rs`, `factory/factory_tests.rs`, `factory/stt_providers_tests.rs`, `audio_toolkit/ops_tests.rs`. |## Public surface@@ -72,7 +72,7 @@ Namespace `voice` (registered in `all_voice_registered_controllers`):| RPC method | Purpose || --- | --- |-| `voice.status` | STT/TTS binary + model availability and active provider selection. |+| `voice.status` | Availability without executing anything: STT = the effective provider constructs and (for non-hosted slugs) has a credential; TTS = Piper binary + voice model resolve. || `voice.agent_signed_url` | Mint a short-lived signed WebSocket URL for a realtime ElevenLabs Agents session. || `voice.transcribe` | Transcribe a file path, optional LLM cleanup. || `voice.transcribe_bytes` | Transcribe raw audio bytes (writes temp file), with hallucination filter + cleanup. |@@ -89,8 +89,9 @@ Namespace `voice` (registered in `all_voice_registered_controllers`):| `voice.overlay_stt_notify` | Bridge chat-button STT state transitions into the dictation/transcription buses. |Provider strings follow the grammar `cloud` / `openhuman` / `backend` (hosted-proxy), `piper` (local TTS), `<slug>` or `<slug>:<model|voice>` (registry-lookup in `config.voice_providers`). `"whisper"` and `"local"` used to select+proxy; `create_tts_provider` matches only `cloud` / `openhuman`), `piper`+(local TTS), `<slug>` or `<slug>:<model|voice>` (registry lookup in+`config.voice_providers`). `"whisper"` and `"local"` used to selectthe bundled whisper.cpp engine; that engine is gone, so both strings now fallthrough to the slug lookup and error by name — `config::migrations` rewritespersisted configs so a user never reaches that error.@@ -114,17 +115,23 @@ results reach the frontend without Tauri-side shortcut registration).- `tinyvoice-bus` (`crates/openhuman-core/Cargo.toml`, optional, gated by the`voice` feature) — the wire contract for the loaded `tinyvoice` module.-- `crate::modules::voice` — the loaded `tinyvoice` native module. `audio_capture.rs`- and `always_on.rs` call into it (as `tinyvoice`) for frame preparation, resample,- per-frame energies, and WAV framing; this crate owns only the `cpal` stream and- policy decisions, not the audio math.+- `crate::modules::voice` — the host-side wrapper over the loaded `tinyvoice`+ native module (the `voice` feature pulls in `modules` for it). `audio_capture.rs`+ and `always_on.rs` call it (imported as `tinyvoice`) for frame preparation,+ resample, per-frame energies, WAV encoding, the VAD session, wake-word+ detection and command/intent routing; `ops.rs` and `server.rs` call+ `is_hallucinated` (`HallucinationMode::{Conversation,Dictation}`). This crate+ owns only the `cpal` stream and policy decisions, not the audio or transcript+ math.## PersistenceNo dedicated `store.rs`. State is persisted into the shared TOML `Config` viathe config domain: `config.local_ai.{stt,tts}_provider`,`config.local_ai.{stt_model_id,tts_voice_id}`, top-level-`config.{stt,tts}_provider`, and `config.voice_providers` (the registry). The+`config.{stt,tts}_provider`, `config.voice_server.*` (`stt_engine`,+`always_on_enabled`, `wake_word`, hotkey, gates), and `config.voice_providers`+(the registry). Thedictation `VoiceServer` keeps in-memory runtime state only (state machine,transcription count, rolling recent-transcript buffer for context) behind a`OnceCell` singleton.@@ -135,28 +142,32 @@ transcription count, rolling recent-transcript buffer for context) behind a- `crate::config` — `Config`, `config::rpc::load_config_with_timeout`, voice-server / dictation config sections, and `config::schema::voice_providers` (`VoiceProviderCreds`, capability/auth/API-style enums).- `crate::desktop::accessibility` (macOS only) — focused-text inspection (`focused_text_context_verbose`) and the Swift globe-key listener (`globe_listener_start` / `globe_listener_poll`) used in place of rdev for the Fn key.- `crate::api` — `BackendOAuthClient`, `effective_backend_api_url`, `get_session_token` for backend-proxied reply-speech and the realtime signed-URL bootstrap.-- `crate::modules::voice` (`tinyvoice`) — frame prep, resample, energy, and WAV framing math shared with `audio_toolkit` and `always_on`.+- `crate::modules::voice` (`tinyvoice`) — see Contract crates above.- `crate::core::all` (`ControllerFuture`, `RegisteredController`), `crate::core::{ControllerSchema, FieldSchema, TypeSchema}`, `crate::core::bus::BUS` + `crate::core::events` (event publishing), `crate::core::logging` (CLI run init), and `crate::rpc::RpcOutcome`.- External crates: `cpal` (capture), `rdev` (hotkeys), `enigo` + `arboard` (paste insertion), `reqwest` (external provider HTTP + realtime bootstrap), `tokio`/`tokio-util`, `once_cell`.## Used by-- `crates/openhuman-core/src/core/all.rs` — registers the voice controllers.-- `crates/openhuman-core/src/core/socketio.rs` — subscribes to the dictation/transcription broadcast buses; `streaming::handle_dictation_ws`.-- `crates/openhuman-core/src/core/jsonrpc.rs` — WebSocket upgrade for streaming dictation.+- `crates/openhuman-core/src/core/all.rs` — registers the `voice` and `audio_toolkit` controllers (gated) and the `openhuman voice` CLI adapter (ungated, so the stub answers with a "voice disabled" error).+- `crates/openhuman-core/src/core/socketio.rs` — subscribes to the dictation/transcription broadcast buses and forwards them to Socket.IO clients.+- `crates/openhuman-core/src/core/jsonrpc.rs` — WebSocket upgrade for streaming dictation (`streaming::handle_dictation_ws`).+- `crates/openhuman-core/src/platform/socket/event_handlers.rs` — spawns `realtime_harness::handle_voice_harness_turn` for each `voice:harness` socket event.- `crates/openhuman-core/src/web_chat/run_task.rs` — synthesizes agent reply speech and publishes PTT transcript-committed events.-- `crates/openhuman-core/src/channels/host/adapters.rs` — channel-side STT/TTS provider dispatch and reply synthesis.+- `crates/openhuman-core/src/channels/host/adapters.rs` — channel-side STT provider dispatch and reply synthesis.- `crates/openhuman-core/src/security/credentials/ops_part_01.rs` — starts/stops the dictation server, dictation listener, and always-on listener when credentials that gate them change.+- `crates/openhuman-core/src/config/schemas/controllers_part_02.rs` — re-applies `always_on::start_if_enabled` live after voice-server settings are saved.+- `crates/openhuman-core/src/inference/local/service/speech.rs` — the local-AI service's STT path resolves and constructs the provider through `effective_stt_provider` / `create_stt_provider`.- `crates/openhuman-core/src/inference/local/install_piper.rs` — references `DEFAULT_PIPER_VOICE`.-- `crates/openhuman-core/src/desktop/overlay/` — the notch overlay subscribes to the same dictation/transcription pattern.+- `crates/openhuman-core/src/tools/mod.rs` — re-exports `voice::audio_toolkit::tools::*` into the agent tool catalog.+- `crates/openhuman-app/src/lib.rs` — `const` asserts `VOICE_COMPILED_IN`.## Notes / gotchas- **macOS hotkey safety (#2677):** rdev's CGEventTap callback calls `TSMGetInputSourceProperty` off the main thread, which crashes with `EXC_BREAKPOINT` on macOS 26. So on macOS the core-side `dictation_listener::start_if_enabled` is a no-op and the voice server only supports the `fn` (Globe) key via the Swift globe listener; all other keys return an error. Non-macOS uses rdev for all keys.- **Two server instances:** `global_server` registers the singleton observed by the `voice.server_*` RPCs; `run_standalone` (CLI) deliberately creates an isolated, unregistered `VoiceServer`.- **Reply-speech and realtime approval-gate classification is "internal"** — if `reply_speech` is ever wrapped in a `Tool`, `external_effect()` MUST stay `false` so the approval gate never prompts on TTS (see file docstring + #1339/#1206). `realtime_harness` turns are classified `ExternalChannel` instead, since they originate as user speech over a channel.-- **Provider precedence:** `effective_*_provider` prefers the top-level `config.{stt,tts}_provider`, falls back to `config.local_ai.*_provider`, then defaults to `"cloud"`.+- **Provider precedence:** `effective_tts_provider` prefers the top-level `config.tts_provider`, falls back to `config.local_ai.tts_provider`, then `"cloud"`. `effective_stt_provider` walks `config.stt_provider` → `config.local_ai.stt_provider` but only accepts one that names a *specific* provider; `""`/`cloud`/`openhuman`/`backend` defer to `config.voice_server.stt_engine.provider_string()` so an engine picked in Settings is not shadowed by the legacy `"cloud"` default.- **Piper-voice guard:** dispatch handlers only default to `DEFAULT_PIPER_VOICE` when the active provider is `piper`; sending a Piper voice id to a cloud/external endpoint would be invalid.-- **Dictation pipeline gates** (in `server.rs`): minimum duration → peak-RMS silence threshold → hallucination filter → empty-text — each drops the recording before delivery. A `session_generation` counter discards stale state transitions from superseded recordings.+- **Dictation pipeline gates** (in `server_part_02.rs`): minimum duration → peak-RMS silence threshold → hallucination filter (`tinyvoice::is_hallucinated`) / empty-text — each drops the recording before delivery. A `session_generation` counter discards stale state transitions from superseded recordings.- **Kokoro TTS is intentionally not implemented** in this cut; the doc in `factory/entry.rs` describes how to add it as a new branch + sibling module.- **No local STT branch:** `"whisper"`/`"local"` provider strings are legacy and error rather than silently falling back — a real misconfiguration should surface, not degrade quietly (see `factory/entry.rs::create_stt_provider`).