Skip to content

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

feat(channels): load tinyvoice before outbound voice and preview audio inbound

Steven Enamakelfb7553198dd1
diff --git a/crates/openhuman-core/src/channels/host/voice.rs b/crates/openhuman-core/src/channels/host/voice.rs
index c33a56698e..1bc27fe8c6 100644
--- a/crates/openhuman-core/src/channels/host/voice.rs
+++ b/crates/openhuman-core/src/channels/host/voice.rs
@@ -233,6 +233,9 @@ impl ChannelVoiceHost {
let channel = request.scope.configured_instance.as_str();
let voice_cfg = &self.config.channel_voice;
check_outbound_length(voice_cfg, channel, &request.text)?;
+ crate::modules::ops::ensure_loaded(&self.config, "tinyvoice")
+ .await
+ .map_err(anyhow::Error::msg)?;
let request_id = uuid::Uuid::new_v4();
let started = Instant::now();
let voice = request
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
index 6cb6a922a7..b73448af65 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -22,6 +22,24 @@ use super::super::host_agent::{self, HostRoute};
use super::approval::{channel_has_approval_surface, try_route_approval_reply};
use super::RuntimeChannelMessage;
+fn inbound_console_preview(
+ envelope: &tinychannels_bus::ChannelInboundEnvelope,
+ text: &str,
+) -> String {
+ let contains_audio = envelope.parts.iter().any(|part| {
+ matches!(
+ part,
+ tinychannels_bus::ContentPart::VoiceNote { .. }
+ | tinychannels_bus::ContentPart::Audio { .. }
+ )
+ });
+ if contains_audio {
+ "[voice message]".to_owned()
+ } else {
+ truncate_with_ellipsis(text, 80)
+ }
+}
+
pub(crate) async fn process_channel_runtime_message(
ctx: Arc<ChannelRuntimeContext>,
runtime_msg: RuntimeChannelMessage,
@@ -106,7 +124,7 @@ pub(crate) async fn process_channel_runtime_message(
" 💬 [{}] from {}: {}",
msg.channel,
msg.sender,
- truncate_with_ellipsis(&msg.content, 80)
+ inbound_console_preview(&envelope, &msg.content)
);
BUS.publish(DomainEvent::ChannelMessageReceived {
@@ -618,3 +636,7 @@ pub(crate) async fn process_channel_runtime_message(
workspace_dir: ctx.workspace_dir.as_ref().clone(),
});
}
+
+#[cfg(test)]
+#[path = "turn_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn_tests.rs
new file mode 100644
index 0000000000..1560afe2f8
--- /dev/null
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn_tests.rs
@@ -0,0 +1,31 @@
+use super::*;
+
+#[test]
+fn voice_message_console_preview_never_includes_transcript_text() {
+ let envelope = tinychannels_bus::ChannelInboundEnvelope {
+ parts: vec![tinychannels_bus::ContentPart::VoiceNote {
+ voice_note: tinychannels_bus::VoiceNote {
+ transcript: Some(tinychannels_bus::VoiceTranscript {
+ text: "private dictated words".into(),
+ language: Some("en".into()),
+ state: tinychannels_bus::VoiceTranscriptState::Complete,
+ source: tinychannels_bus::VoiceTranscriptSource::HostStt,
+ }),
+ ..Default::default()
+ },
+ }],
+ ..Default::default()
+ };
+
+ assert_eq!(
+ inbound_console_preview(&envelope, "private dictated words"),
+ "[voice message]"
+ );
+}
+
+#[test]
+fn ordinary_text_console_preview_remains_readable() {
+ let envelope = tinychannels_bus::ChannelInboundEnvelope::default();
+
+ assert_eq!(inbound_console_preview(&envelope, "hello"), "hello");
+}