diff --git a/src-tauri/crates/berd-call/src/host_session.rs b/src-tauri/crates/berd-call/src/host_session.rs index 3b9ce4735..156d37d4e 100644 --- a/src-tauri/crates/berd-call/src/host_session.rs +++ b/src-tauri/crates/berd-call/src/host_session.rs @@ -951,6 +951,8 @@ struct PendingSpeak { text: String, non_blocking: bool, response: Option>>, + /// When the voice session was asked to speak, for timing diagnostics. + prepared: Instant, } enum AudioCommand { @@ -1421,6 +1423,7 @@ impl SessionActor { text, non_blocking, response: Some(response), + prepared: Instant::now(), }); } ControlCommand::Restart { @@ -1608,6 +1611,12 @@ impl SessionActor { SessionMessage::Admitted { id, speech_id, .. } if self.pending_prepare_id() == Some(id) => { + if let Some(pending) = &self.pending_speak { + eprintln!( + "berd-call: speech admitted after {} ms", + pending.prepared.elapsed().as_millis() + ); + } send_request(&self.writer, &SessionRequest::OutputReady { id, speech_id })?; } SessionMessage::OutputReadyResult { id, outcome, .. } @@ -1623,6 +1632,14 @@ impl SessionActor { } } } + SessionMessage::SpeechStarted { id, .. } if self.pending_prepare_id() == Some(id) => { + if let Some(pending) = &self.pending_speak { + eprintln!( + "berd-call: speech first audio accepted after {} ms", + pending.prepared.elapsed().as_millis() + ); + } + } SessionMessage::SpeechCompleted { id, .. } if self.pending_prepare_id() == Some(id) => { self.respond_speak(Ok(json!({"spoke":true,"status":"completed"}))); } @@ -3909,6 +3926,7 @@ mod tests { text: "first".into(), non_blocking: false, response: Some(first_tx), + prepared: Instant::now(), }); let (next_tx, next_rx) = mpsc::sync_channel(1); actor @@ -3969,6 +3987,7 @@ mod tests { text: "playing".into(), non_blocking: false, response: Some(playing_tx), + prepared: Instant::now(), }); let (queued_tx, queued) = mpsc::sync_channel(1); actor @@ -4046,6 +4065,7 @@ mod tests { text: "playing".into(), non_blocking: false, response: Some(playing_tx), + prepared: Instant::now(), }); let (restart, _restarted) = restart_command(); actor.handle_command(restart).unwrap(); @@ -4334,6 +4354,7 @@ mod tests { text: "playing".into(), non_blocking: false, response: Some(playing_tx), + prepared: Instant::now(), }); let (restart, restarted) = restart_command(); actor.handle_command(restart).unwrap();