Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(voice): remove unused provider server handlers

Steven Enamakel51aff9b4bea9
diff --git a/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs b/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
index 3d11875ce1..139ced3635 100644
--- a/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
+++ b/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
@@ -418,191 +418,3 @@ pub(crate) fn handle_voice_test_provider(
}
})
}
-
-pub(crate) fn handle_voice_server_start(
- ctx: DispatchCtx,
- params: Map<String, Value>,
-) -> ControllerFuture {
- Box::pin(async move {
- use crate::voice::server::{global_server, VoiceServerConfig};
- use tinyvoice_bus::hotkey::ActivationMode;
-
- let config = ctx.load_config().await?;
-
- let hotkey = params
- .get("hotkey")
- .and_then(|v| v.as_str())
- .unwrap_or(&config.voice_server.hotkey)
- .to_string();
-
- let activation_mode = match params.get("activation_mode").and_then(|v| v.as_str()) {
- Some("push") => ActivationMode::Push,
- Some("tap") => ActivationMode::Tap,
- Some(other) => {
- log::warn!(
- "[voice_server] unrecognized activation_mode '{}', defaulting to Push",
- other
- );
- ActivationMode::Push
- }
- None => match config.voice_server.activation_mode {
- crate::config::VoiceActivationMode::Push => ActivationMode::Push,
- crate::config::VoiceActivationMode::Tap => ActivationMode::Tap,
- },
- };
-
- let skip_cleanup = params
- .get("skip_cleanup")
- .and_then(|v| v.as_bool())
- .unwrap_or(config.voice_server.skip_cleanup);
-
- let server_config = VoiceServerConfig {
- hotkey,
- activation_mode,
- skip_cleanup,
- context: None,
- min_duration_secs: config.voice_server.min_duration_secs,
- silence_threshold: config.voice_server.silence_threshold,
- custom_dictionary: config.voice_server.custom_dictionary.clone(),
- };
-
- // Check if a server is already running with a different config.
- if let Some(existing) = crate::voice::server::try_global_server() {
- let existing_status = existing.status().await;
- if existing_status.state != crate::voice::server::ServerState::Stopped {
- if existing_status.hotkey != server_config.hotkey
- || existing_status.activation_mode != server_config.activation_mode
- {
- return Err(format!(
- "voice server already running (hotkey={}, mode={:?}); \
- stop it first before starting with different config",
- existing_status.hotkey, existing_status.activation_mode
- ));
- }
- // Same config, already running — return current status.
- return serde_json::to_value(existing_status)
- .map_err(|e| format!("serialize error: {e}"));
- }
- }
-
- let server = global_server(server_config);
- let config_clone = config.clone();
- let server_for_err = server.clone();
- let run_ctx = ctx.clone();
-
- tokio::spawn(async move {
- if let Err(e) = server.run(&run_ctx, &config_clone).await {
- log::warn!("[voice_server] server exited with error: {e}");
- server_for_err.set_last_error(&e).await;
- }
- });
-
- // Give the server a moment to start.
- tokio::time::sleep(std::time::Duration::from_millis(200)).await;
-
- if let Some(s) = crate::voice::server::try_global_server() {
- let status = s.status().await;
- serde_json::to_value(status).map_err(|e| format!("serialize error: {e}"))
- } else {
- Err("voice server failed to initialize".to_string())
- }
- })
-}
-
-pub(crate) fn handle_voice_server_stop(
- _ctx: DispatchCtx,
- _params: Map<String, Value>,
-) -> ControllerFuture {
- Box::pin(async move {
- if let Some(server) = crate::voice::server::try_global_server() {
- server.stop().await;
- tokio::time::sleep(std::time::Duration::from_millis(200)).await;
- let status = server.status().await;
- serde_json::to_value(status).map_err(|e| format!("serialize error: {e}"))
- } else {
- // Not running — return a stopped status rather than an error.
- let status = crate::voice::server::VoiceServerStatus {
- state: crate::voice::server::ServerState::Stopped,
- hotkey: String::new(),
- activation_mode: tinyvoice_bus::hotkey::ActivationMode::Push,
- transcription_count: 0,
- last_error: None,
- };
- serde_json::to_value(status).map_err(|e| format!("serialize error: {e}"))
- }
- })
-}
-
-pub(crate) fn handle_voice_server_status(
- _ctx: DispatchCtx,
- _params: Map<String, Value>,
-) -> ControllerFuture {
- Box::pin(async move {
- if let Some(server) = crate::voice::server::try_global_server() {
- let status = server.status().await;
- serde_json::to_value(status).map_err(|e| format!("serialize error: {e}"))
- } else {
- let status = crate::voice::server::VoiceServerStatus {
- state: crate::voice::server::ServerState::Stopped,
- hotkey: String::new(),
- activation_mode: tinyvoice_bus::hotkey::ActivationMode::Push,
- transcription_count: 0,
- last_error: None,
- };
- serde_json::to_value(status).map_err(|e| format!("serialize error: {e}"))
- }
- })
-}
-
-// ---------------------------------------------------------------------------
-// Overlay STT notify handler
-// ---------------------------------------------------------------------------
-
-pub(crate) fn handle_overlay_stt_notify(
- _ctx: DispatchCtx,
- params: Map<String, Value>,
-) -> ControllerFuture {
- Box::pin(async move {
- let p = deserialize_params::<OverlaySttNotifyParams>(params)?;
- log::debug!(
- "[overlay_stt_notify] state={:?}, has_text={}, text_len={}",
- p.state,
- p.text.is_some(),
- p.text.as_deref().map_or(0, |t| t.len())
- );
-
- use crate::voice::dictation_listener::{
- publish_dictation_event, publish_transcription, DictationEvent,
- };
-
- match p.state {
- OverlaySttState::RecordingStarted => {
- publish_dictation_event(DictationEvent {
- event_type: "pressed".to_string(),
- hotkey: "chat_button".to_string(),
- activation_mode: "toggle".to_string(),
- });
- }
- OverlaySttState::TranscriptionDone => {
- let text = p.text.ok_or_else(|| {
- "invalid params: `text` is required for transcription_done".to_string()
- })?;
- publish_transcription(text);
- publish_dictation_event(DictationEvent {
- event_type: "released".to_string(),
- hotkey: "chat_button".to_string(),
- activation_mode: "toggle".to_string(),
- });
- }
- OverlaySttState::Cancelled | OverlaySttState::Error => {
- publish_dictation_event(DictationEvent {
- event_type: "released".to_string(),
- hotkey: "chat_button".to_string(),
- activation_mode: "toggle".to_string(),
- });
- }
- }
-
- Ok(serde_json::json!({ "ok": true }))
- })
-}