← All Labs Conversational Voice Cascaded streaming voice on DurableAgent
Conversational Voice · Built

Cascaded streaming voice on DurableAgent

AudioWorklet PCM capture and streaming STT feed DurableAgent; LiveDoc deltas stream through SpeakabilityChunker to Multi-Context TTS; barge-in flushes audio, cancels TTS context, and calls Conversation.abort().

Built Needs: streaming Smoke: pnpm exec tsx examples/29-voice-cascaded-stream/run.ts --smoke Run: pnpm exec tsx examples/29-voice-cascaded-stream/run.ts Source: examples/29-voice-cascaded-stream

Mechanism: AudioWorklet (16 kHz PCM16) → Streaming STT (Deepgram Flux / gemini-3.5-transcribe-live / mock) → conv.submit() → Harness.observeConversation() (pi.live LiveDoc deltas) → SpeakabilityChunker → Streaming TTS (ElevenLabs Multi-Context WS / Cartesia Sonic / gemini-3.8-flash-tts / mock).

Cascaded streaming voice on DurableAgent

zsh
pnpm exec tsx examples/29-voice-cascaded-stream/run.ts          # :7491 + /shell/ with custom:voice-cascaded panel
pnpm exec tsx examples/29-voice-cascaded-stream/run.ts --smoke  # offline verification, exit 0

# Live cloud adapters (requires keys in .env)
dotenvx run -- pnpm exec tsx examples/29-voice-cascaded-stream/run.ts \
  --stt deepgram --tts elevenlabs --model google:gemini-4-hydrogen

Open http://127.0.0.1:7491/shell/ to see the Chat panel in the center and Voice: Cascaded Stream in the right rail (voice-cascaded.js). Both share the same agent.sqlite conversation.

Checks

CheckWhat it proves
streams-clauses-before-turn-endtts_clause and binary 24 kHz PCM frames arrive over /api/voice before turn_done.
code-blocks-summarized-not-readSpeakabilityChunker replaces fenced code blocks with "I included a code block; check the chat panel." instead of reading raw syntax aloud.
barge-in-aborts-durable-generationSending barge_in mid-stream cancels the TTS context, calls conv.abort(), emits interrupt, and increments VoiceSessionDoc.bargeIns.
shared-durable-ledger-with-chatSpoken turns appear inside GET /api/state alongside typed chat.
substrate-component-served/shell/manifest.json includes custom:voice-cascaded and /shell/custom/voice-cascaded.js returns 200.

Break it

In examples/29-voice-cascaded-stream/run.ts, remove await conv.abort(ctx) inside triggerBargeIn. The barge-in-aborts-durable-generation check keeps waiting on the held generation or leaves the conversation busy, and --smoke fails.

Files

  • run.ts: serveAgent + /api/voice WebSocket bridge, STT/TTS adapters, and --smoke.
  • components/voice-cascaded.js: Zero-dependency Substrate Shell panel with inline AudioWorklet capture & playback ring buffer.
  • PROMPT.md: Prompt to rebuild this lab.