Skip to content

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

fix(voice): sync legacy stt_engine when provider is set

Steven Enamakelc761eb3d0ade
diff --git a/crates/openhuman-core/src/config/schemas/controllers.rs b/crates/openhuman-core/src/config/schemas/controllers.rs
index d96a7d7336..0e6c033154 100644
--- a/crates/openhuman-core/src/config/schemas/controllers.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers.rs
@@ -8,7 +8,6 @@ mod agent;
mod inference;
mod integrations;
mod registry;
-mod voice;
mod workspace;
pub use registry::{all_controller_schemas, all_registered_controllers};
diff --git a/crates/openhuman-core/src/config/schemas/schema_defs.rs b/crates/openhuman-core/src/config/schemas/schema_defs.rs
index 7f3acb7e33..2e04109603 100644
--- a/crates/openhuman-core/src/config/schemas/schema_defs.rs
+++ b/crates/openhuman-core/src/config/schemas/schema_defs.rs
@@ -6,7 +6,6 @@ use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
mod agent;
mod inference;
mod integrations;
-mod voice;
mod workspace;
#[cfg(test)]
@@ -17,7 +16,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
inference::lookup(function)
.or_else(|| agent::lookup(function))
.or_else(|| workspace::lookup(function))
- .or_else(|| voice::lookup(function))
.or_else(|| integrations::lookup(function))
.unwrap_or_else(|| ControllerSchema {
namespace: "config",
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 87499c19cc..3c5457e828 100644
--- a/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
+++ b/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
@@ -35,6 +35,7 @@ pub(crate) fn handle_voice_set_providers(
validate_stt_provider(stt)?;
config.local_ai.stt_provider = stt.to_string();
config.stt_provider = Some(stt.to_string());
+ sync_legacy_stt_engine(&mut config, stt);
}
if let Some(tts) = p
.tts_provider
@@ -188,6 +189,7 @@ pub(crate) fn handle_voice_update_provider_settings(
// Sync to legacy field so voice_status / voice_stt_dispatch
// pick up the change without waiting for a restart.
config.local_ai.stt_provider = trimmed.to_string();
+ sync_legacy_stt_engine(&mut config, trimmed);
}
}
@@ -236,6 +238,15 @@ pub(crate) fn handle_voice_update_provider_settings(
})
}
+/// Keep the persisted engine fallback aligned when a known provider is chosen.
+/// Custom `slug:model` routing remains in `stt_provider` and leaves the legacy
+/// fallback untouched.
+fn sync_legacy_stt_engine(config: &mut crate::config::Config, provider: &str) {
+ if let Some(engine) = crate::config::SttEngine::parse(provider) {
+ config.voice_server.stt_engine = engine;
+ }
+}
+
pub(crate) fn handle_voice_list_models(
ctx: DispatchCtx,
params: Map<String, Value>,
diff --git a/crates/openhuman-core/src/voice/schemas/handlers/provider_server_tests.rs b/crates/openhuman-core/src/voice/schemas/handlers/provider_server_tests.rs
index 10a3950087..6803d166f6 100644
--- a/crates/openhuman-core/src/voice/schemas/handlers/provider_server_tests.rs
+++ b/crates/openhuman-core/src/voice/schemas/handlers/provider_server_tests.rs
@@ -13,18 +13,35 @@ async fn choosing_backend_resets_a_legacy_nondefault_stt_engine() {
config.clone(),
));
- let params = Map::from_iter([("stt_provider".to_string(), Value::String("cloud".into()))]);
- handle_voice_set_providers(ctx, params)
+ let custom = Map::from_iter([(
+ "stt_provider".to_string(),
+ Value::String("custom-provider:model-v2".into()),
+ )]);
+ handle_voice_set_providers(ctx.clone(), custom)
.await
- .expect("setting the backend provider should succeed");
+ .expect("setting a custom provider should succeed");
+ let persisted = crate::config::Config::load_from_config_path(
+ &config.config_path,
+ &config.workspace_dir,
+ )
+ .await
+ .unwrap();
+ assert_eq!(persisted.voice_server.stt_engine, crate::config::SttEngine::Elevenlabs);
+ assert_eq!(crate::voice::effective_stt_provider(&persisted), "custom-provider:model-v2");
- let persisted =
- crate::config::Config::load_from_config_path(&config.config_path, &config.workspace_dir)
- .await
- .unwrap();
- assert_eq!(
- persisted.voice_server.stt_engine,
- crate::config::SttEngine::Backend
- );
- assert_eq!(crate::voice::effective_stt_provider(&persisted), "cloud");
+ for alias in ["cloud", "backend", "openhuman"] {
+ let params = Map::from_iter([("stt_provider".to_string(), Value::String(alias.into()))]);
+ handle_voice_set_providers(ctx.clone(), params)
+ .await
+ .expect("setting a backend alias should succeed");
+
+ let persisted = crate::config::Config::load_from_config_path(
+ &config.config_path,
+ &config.workspace_dir,
+ )
+ .await
+ .unwrap();
+ assert_eq!(persisted.voice_server.stt_engine, crate::config::SttEngine::Backend);
+ assert_eq!(crate::voice::effective_stt_provider(&persisted), "cloud");
+ }
}