Skip to main content
The Live Capture API (/analyze/live/*) lets you push microphone or SIP audio chunks into Illocution and receive multi-agent analytics (transcripts, emotion, cognitive, transitions, summaries) as they finalize. Use this when you truly need live capture—not the Replay endpoint (POST /analyze/stream) that replays an already recorded file.

Endpoint Reference

All requests require X-API-Key. Live capture must be enabled server side (ENABLE_LIVE_STREAMING=true).

Prerequisites

  • Use 16-bit PCM WAV, MP3, or Opus—transcoding happens server side.
  • Chunk sizes between 32–128 kB keep latency low without spamming HTTP.
  • Only one SSE consumer may attach to events_endpoint at a time.

Recipe 1 – Start a session & attach to SSE

Event structure

  • status: {"phase": "ingesting"|"processing"|"completed", "progress": 0.0-1.0}
  • final_transcript: diarized utterance with timings/confidence
  • emotion: PAD + 7-way distribution per utterance
  • cognitive: engagement/focus/load plus textual rationale
  • transition / moment: detected shifts (e.g., objection, cta_commit)
  • summary_update: rolling recap near the end
  • error: structured {code,message}
  • done: {"conversation_id": "..."}

Recipe 2 – Stream audio chunks

Rules of thumb:
  • chunk_seq must be monotonically increasing with no gaps. Retries should resend the same chunk_seq.
  • Keep chunk_size consistent; jitter is acceptable but smaller chunks mean more HTTP overhead.
  • Adjust timeout on the client for large uploads; the server enforces chunk ordering and rejects late chunks after finalize.

Recipe 3 – Control session lifecycle

  • finalize stops chunk ingestion and lets the pipeline finish.
  • cancel tears down the session and emits error with your reason.
  • keepalive extends the TTL if you expect a long silence; send it before expires_at.

Full end-to-end async runner

Production Notes

  • Mirror microphone capture by feeding an asyncio.Queue into upload_chunks; convert PCM frames to bytes before POSTing.
  • Handle reconnection logic for SSE (e.g., exponential backoff) and surface error events to operators.
  • /metrics exposes events counters and average agent latency for monitoring.
  • Artifact bundles (timeline, summary, segmentation) are persisted and referenced by the done event payload.
  • Only attach the SSE consumer once; the API rejects a second events connection for the same session.
  • For more advanced demos, use scripts/test_live_stream.py in this repo as a baseline.