@cloudflare/voice v0.4.0 now lets you inspect where each Voice Agent turn spends time and how it ends.
client.addEventListener("turnmetrics", (turn) => {
console.log(turn.outcome, turn.turnTotalMs);
});
About the Voice package
The @cloudflare/voice package lets you build real-time voice agents with Cloudflare Agents. It streams microphone audio to an Agent over WebSocket, transcribes speech, runs your model through onTurn(), converts the response to speech, and streams audio back to the caller.
A turn moves through several stages:
User speaks -> speech-to-text -> model -> text-to-speech -> audio
Previously, the package's four aggregate metrics covered successful, non-empty speech turns. They did not show how failed, aborted, empty, or text turns ended.
Turn metrics
Each speech or text turn now produces a typed VoiceTurnMetrics summary with:
- A
turnId for correlating events from the same turn.
- A terminal outcome such as
completed, no_output, output_limit, content_filtered, model_error, tts_error, or aborted.
- Timings for important stages, including speech-to-final-transcript, model-to-first-text, TTS-to-first-audio, and total turn duration.
These timings can overlap and are not additive. Timings for stages that a turn did not reach are omitted. …