/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
| Purpose | Method & Path | Notes |
|---|---|---|
| Start session | POST /analyze/live/start | Returns session_id, chunk/events/control URLs, TTL metadata. |
| Push audio chunk | POST /analyze/live/{session_id}/chunk | Send sequential binary chunks (chunk_seq 0,1,2,…) up to one active session. |
| Control session | POST /analyze/live/{session_id}/control | finalize, cancel, or keepalive to extend TTL. |
| Subscribe to analytics | GET /analyze/live/{session_id}/events | Single SSE stream per session; emits status, final_transcript, emotion, cognitive, transition, moment, summary_update, error, done. |
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_endpointat 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/confidenceemotion: PAD + 7-way distribution per utterancecognitive: engagement/focus/load plus textual rationaletransition/moment: detected shifts (e.g.,objection,cta_commit)summary_update: rolling recap near the enderror: structured{code,message}done:{"conversation_id": "..."}
Recipe 2 – Stream audio chunks
chunk_seqmust be monotonically increasing with no gaps. Retries should resend the samechunk_seq.- Keep
chunk_sizeconsistent; jitter is acceptable but smaller chunks mean more HTTP overhead. - Adjust
timeouton the client for large uploads; the server enforces chunk ordering and rejects late chunks afterfinalize.
Recipe 3 – Control session lifecycle
finalizestops chunk ingestion and lets the pipeline finish.canceltears down the session and emitserrorwith your reason.keepaliveextends the TTL if you expect a long silence; send it beforeexpires_at.
Full end-to-end async runner
Production Notes
- Mirror microphone capture by feeding an
asyncio.Queueintoupload_chunks; convert PCM frames to bytes before POSTing. - Handle reconnection logic for SSE (e.g., exponential backoff) and surface
errorevents to operators. /metricsexposeseventscounters and average agent latency for monitoring.- Artifact bundles (timeline, summary, segmentation) are persisted and referenced by the
doneevent payload. - Only attach the SSE consumer once; the API rejects a second
eventsconnection for the same session. - For more advanced demos, use
scripts/test_live_stream.pyin this repo as a baseline.