Skip to content

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

fix(voice): honour caller-supplied STT model in cloud provider

Steven Enamakel7ab0dfe84743
diff --git a/crates/openhuman-tinyhumans/src/voice/speech_providers.rs b/crates/openhuman-tinyhumans/src/voice/speech_providers.rs
index 00db9644af..42b7274756 100644
--- a/crates/openhuman-tinyhumans/src/voice/speech_providers.rs
+++ b/crates/openhuman-tinyhumans/src/voice/speech_providers.rs
@@ -25,8 +25,8 @@ const LOG_PREFIX: &str = "[voice-factory]";
pub const STT_SLUGS: [&str; 3] = ["cloud", "openhuman", "backend"];
/// TTS slugs the hosted provider answers to.
pub const TTS_SLUGS: [&str; 2] = ["cloud", "openhuman"];
-/// Default STT model id for the hosted transcription proxy. The factory's
-/// caller-supplied model is ignored: the proxy picks from this one.
+/// Default STT model id for the hosted transcription proxy, used when the
+/// caller names no model.
pub const DEFAULT_CLOUD_STT_MODEL: &str = "whisper-v1";
/// Cloud STT. Stateless; cheap to construct.
@@ -121,11 +121,22 @@ impl TtsProvider for CloudTtsProvider {
}
}
+/// The model the hosted STT provider is built with: the caller's, else the
+/// proxy default.
+fn stt_model(requested: &str) -> &str {
+ let requested = requested.trim();
+ if requested.is_empty() {
+ DEFAULT_CLOUD_STT_MODEL
+ } else {
+ requested
+ }
+}
+
/// Registers the hosted STT and TTS providers under their slugs.
pub(super) fn register() {
for slug in STT_SLUGS {
- register_stt_provider(slug, |_model, _config| {
- Ok(Box::new(CloudSttProvider::new(DEFAULT_CLOUD_STT_MODEL)))
+ register_stt_provider(slug, |model, _config| {
+ Ok(Box::new(CloudSttProvider::new(stt_model(model))))
});
}
for slug in TTS_SLUGS {
diff --git a/crates/openhuman-tinyhumans/src/voice/speech_providers_tests.rs b/crates/openhuman-tinyhumans/src/voice/speech_providers_tests.rs
index b40e5e4560..eaf86b9a1c 100644
--- a/crates/openhuman-tinyhumans/src/voice/speech_providers_tests.rs
+++ b/crates/openhuman-tinyhumans/src/voice/speech_providers_tests.rs
@@ -31,3 +31,13 @@ fn cloud_tts_without_a_voice_carries_none_so_the_backend_default_applies() {
let provider = CloudTtsProvider::new(Some("JBFqnCBsd6RMkjVDRZzb".into()));
assert_eq!(provider.voice.as_deref(), Some("JBFqnCBsd6RMkjVDRZzb"));
}
+
+/// The model the caller names reaches the provider; only an empty one falls
+/// back to the proxy default.
+#[test]
+fn the_callers_stt_model_is_passed_through() {
+ assert_eq!(stt_model("whisper-large"), "whisper-large");
+ assert_eq!(stt_model(" whisper-large "), "whisper-large");
+ assert_eq!(stt_model(""), DEFAULT_CLOUD_STT_MODEL);
+ assert_eq!(stt_model(" "), DEFAULT_CLOUD_STT_MODEL);
+}