Watch
0
0
Fork
You've already forked hyperhive
0

agents can transcribe an audio file: the transcribe_audio tool, through the harness and the speech-to-text service

This commit is contained in:
damocles 2026-11-12 10:14:54 +01:00 • committed by mara
commit eff209f756

View file

@ -24,13 +24,14 @@ mod args;
mod render;
pub use args::{
CancelLooseEndArgs, CompactArgs, GetAgentMetaArgs, MarkTodosDoneArgs, RemindArgs, SetStatusArgs,
CancelLooseEndArgs, CompactArgs, GetAgentMetaArgs, MarkTodosDoneArgs, RemindArgs,
SetStatusArgs, TranscribeAudioArgs,
};
pub use render::{annotate_retries, format_ack, format_agent_meta};
use render::{
dial_agent_socket, format_matrix_summary, local_reminders, local_todos, mark_local_todo_done,
mark_local_todos_done, matrix_unread_summary, render_loose_ends, reply_err,
mark_local_todos_done, matrix_unread_summary, render_loose_ends, reply_err, transcribe_local,
};
/// Write (or remove) the status file in the agent's own `state/` directory.
@ -329,6 +330,37 @@ impl AgentServer {
.await
}
#[tool(
description = "Get the text spoken in an audio file, from the swarm's speech-to-text \
service: a matrix voice memo (download it with the matrix `download_file` tool and pass \
the returned `path`), or any Ogg, WAV, FLAC, MP3, AMR, MP4/M4A or WebM file up to 6 MiB. \
The service keeps each transcript for a day, so the same memo heard by several agents is \
transcribed once. Can take minutes when other memos are queued ahead. Returns the text \
(empty for silence), or why it could not be transcribed."
)]
async fn transcribe_audio(&self, Parameters(args): Parameters<TranscribeAudioArgs>) -> String {
let log = format!("{args:?}");
run_tool_envelope("transcribe_audio", log, async move {
match transcribe_local(args.path).await {
Some(hive_agent_sock::Response::Transcript { text, .. }) => {
if text.trim().is_empty() {
"(no speech found)".to_owned()
} else {
text
}
}
Some(hive_agent_sock::Response::Err { message }) => {
format!("transcribe_audio failed: {message}")
}
Some(other) => format!("transcribe_audio unexpected response: {other:?}"),
None => "transcribe_audio: local agent socket unavailable \
(HIVE_AGENT_SOCKET unset or harness unreachable)"
.to_owned(),
}
})
.await
}
#[tool(
description = "Schedule a reminder that lands in this agent's own inbox at a future \
time (sender will appear as `reminder`). Use for self-paced follow-ups: 'check task \