Skip to content

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

feat(channels): preload tinyvoice codec when voice replies are enabled

Steven Enamakelacf78c792e89
diff --git a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
index 200ff5bf51..0ce6cb60e0 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
@@ -61,6 +61,12 @@ impl ModuleChannelRuntime {
context: Arc<OnceLock<Weak<crate::channels::context::ChannelRuntimeContext>>>,
dispatch: mpsc::Sender<RuntimeChannelMessage>,
) -> Result<Self> {
+ #[cfg(feature = "voice")]
+ if channel_voice_codec_may_be_used(&config) {
+ if let Err(error) = crate::modules::ops::ensure_loaded(&config, "tinyvoice").await {
+ tracing::warn!("[channels] TinyVoice codec module is unavailable: {error}");
+ }
+ }
let client = crate::modules::client((*config).clone());
// Queued deliveries from before the storage contract move into the
// module's storage before it starts and reads its queue. Best effort:
@@ -289,6 +295,27 @@ impl ModuleChannelRuntime {
}
}
+#[cfg(feature = "voice")]
+fn channel_voice_codec_may_be_used(config: &Config) -> bool {
+ use crate::config::schema::VoiceReplyMode;
+
+ if crate::modules::ops::disabled_component(config, "tinyvoice").is_some() {
+ return false;
+ }
+
+ config.channel_voice.reply_mode != VoiceReplyMode::Never
+ || config
+ .channel_voice
+ .channels
+ .values()
+ .any(|override_| override_.reply_mode.is_some_and(|mode| mode != VoiceReplyMode::Never))
+ || config
+ .channel_voice
+ .threads
+ .values()
+ .any(|mode| *mode != VoiceReplyMode::Never)
+}
+
impl Drop for ModuleChannelRuntime {
fn drop(&mut self) {
if self.closed {