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

@ -183,8 +183,11 @@ async fn handle_conn(
reminders: Option<&Reminders>,
bus: &Bus,
) -> Result<()> {
serve_one(stream, REQUEST_DEADLINES, |req| {
dispatch(req, store, wake, reminders, bus)
serve_one(stream, REQUEST_DEADLINES, async |req| match req {
// Waits on the swarm's speech-to-text service, so it is the one
// request that does not answer from the local store at once.
Request::Transcribe { path } => crate::transcribe::run(&path).await,
req => dispatch(req, store, wake, reminders, bus),
})
.await
}
@ -201,7 +204,7 @@ const REQUEST_DEADLINES: LineDeadlines = LineDeadlines {
async fn serve_one(
stream: UnixStream,
deadlines: LineDeadlines,
apply: impl FnOnce(Request) -> Response,
apply: impl AsyncFnOnce(Request) -> Response,
) -> Result<()> {
let (read, mut write) = stream.into_split();
let mut reader = BufReader::new(read);
@ -214,7 +217,7 @@ async fn serve_one(
Response::Err { message }
} else {
match serde_json::from_slice::<Request>(line.trim_ascii()) {
Ok(req) => apply(req),
Ok(req) => apply(req).await,
Err(e) => Response::Err {
message: format!("bad request: {e}"),
},
@ -276,6 +279,11 @@ fn dispatch(
Request::CountPendingReminders => count_pending_reminders(reminders),
Request::ReminderRollup { since_secs } => reminder_rollup(reminders, since_secs),
Request::Compact { wake_prompt } => compact(bus, wake_prompt),
// Answered by `handle_conn` before this runs: it waits on the queue,
// which this store-only function never does.
Request::Transcribe { .. } => Response::Err {
message: "transcribe is answered by the connection handler, not the store".to_owned(),
},
}
}
@ -695,7 +703,7 @@ mod tests {
/// Send `input` (then keep the write half open), return the one response line.
async fn exchange(input: Vec<u8>, deadlines: LineDeadlines) -> (Response, Result<()>) {
let (client, server) = UnixStream::pair().expect("socketpair");
let handler = tokio::spawn(serve_one(server, deadlines, |_| Response::Ok));
let handler = tokio::spawn(serve_one(server, deadlines, async |_| Response::Ok));
let (read, mut write) = client.into_split();
let _writer = tokio::spawn(async move {
let _ = write.write_all(&input).await;