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
feat(voice): add voice server types and recorder
Steven Enamakel0fbb7e28dd36
diff --git a/crates/openhuman-core/src/voice/server/recorder.rs b/crates/openhuman-core/src/voice/server/recorder.rsnew file mode 100644index 0000000000..e7567bb5f0--- /dev/null+++ b/crates/openhuman-core/src/voice/server/recorder.rs@@ -0,0 +1,59 @@+//! Host handle on the module-owned hotkey -> record -> finish state machine.+//!+//! The phase, generation guard and setup / stop-intent buffering live in the+//! `tinyvoice` module (`SessionOpen` / `SessionAdvance`). This wrapper only+//! reports facts to it, mirrors the phase it answers with so `status()` needs+//! no bus call, and serialises the call and the mirror write so two tasks+//! cannot leave the mirror behind the module.++use std::sync::Arc;++use log::{debug, warn};+use tokio::sync::Mutex;++use crate::config::Config;+use crate::modules::voice::{RecorderSession, SessionAdvance, SessionInput};++use super::types::ServerState;+use super::LOG_PREFIX;++/// A recording session plus the phase mirror it keeps current.+#[derive(Clone)]+pub(super) struct Recorder {+ session: RecorderSession,+ state: Arc<Mutex<ServerState>>,+}++impl Recorder {+ pub(super) fn new(session: RecorderSession, state: Arc<Mutex<ServerState>>) -> Self {+ Self { session, state }+ }++ /// Report `input`; `None` when the module could not be reached or the+ /// session is gone. A failure is logged, never fatal: a stale pipeline+ /// finishing after the server stopped lands here by design.+ pub(super) async fn advance(&self, config: &Config, input: SessionInput) -> Option<SessionAdvance> {+ let mut state = self.state.lock().await;+ match self.session.advance(config, input).await {+ Ok(reply) => {+ debug!(+ "{LOG_PREFIX} session input={input:?} accepted={} phase={:?} generation={} action={:?}",+ reply.accepted, reply.phase, reply.generation, reply.action+ );+ *state = reply.phase.into();+ Some(reply)+ }+ Err(error) => {+ warn!("{LOG_PREFIX} session input={input:?} failed: {error}");+ None+ }+ }+ }++ /// Release the module-side session.+ pub(super) async fn close(&self, config: &Config) {+ if let Err(error) = self.session.close(config).await {+ warn!("{LOG_PREFIX} closing the recording session failed: {error}");+ }+ }+}diff --git a/crates/openhuman-core/src/voice/server/types.rs b/crates/openhuman-core/src/voice/server/types.rsindex 09a1e2ab7d..daa4e50e34 100644--- a/crates/openhuman-core/src/voice/server/types.rs+++ b/crates/openhuman-core/src/voice/server/types.rs@@ -17,6 +17,18 @@ pub enum ServerState {Transcribing,}+impl From<crate::modules::voice::SessionPhase> for ServerState {+ fn from(phase: crate::modules::voice::SessionPhase) -> Self {+ use crate::modules::voice::SessionPhase;+ match phase {+ SessionPhase::Stopped => Self::Stopped,+ SessionPhase::Idle => Self::Idle,+ SessionPhase::Recording => Self::Recording,+ SessionPhase::Transcribing => Self::Transcribing,+ }+ }+}+/// Status snapshot of the voice server.#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]pub struct VoiceServerStatus {diff --git a/vendor/tinyvoice b/vendor/tinyvoiceindex dfb09f5fd3..b9de772d8d 160000--- a/vendor/tinyvoice+++ b/vendor/tinyvoice@@ -1 +1 @@-Subproject commit dfb09f5fd33502b93e4b9d432ed055f99c477d96+Subproject commit b9de772d8db7968c005fcbdbd09ed87d69260ed2