Skip to main content
Use these synchronous recipes if your integration runs inside a WSGI app, Lambda, or any environment where asyncio is inconvenient. This walkthrough targets the true live capture API (/analyze/live/*) that streams transcripts, emotion, and cognitive analytics as the media arrives. It is not the Replay endpoint (POST /analyze/stream), which simply replays an uploaded file.

Endpoint Reference

All requests require X-API-Key, and live capture must be enabled on the deployment (ENABLE_LIVE_STREAMING=true).

Requirements

  • Audio input: 16-bit PCM WAV, MP3, or Opus are safe defaults (server handles transcoding).
  • Chunking: 32–128 kB provides good latency without overwhelming FastAPI.
  • SSE: Only one consumer may connect to events_endpoint per session.

Recipe 1 – Start a session & read SSE synchronously

Event payloads mirror the async cookbook: status, final_transcript, emotion, cognitive, transition, moment, summary_update, error, done.

Recipe 2 – Stream audio chunks synchronously

Guidelines:
  • chunk_seq must be exactly 0,1,2.... On retry, resend the same sequence number.
  • Keep chunk sizes consistent; smaller chunks reduce latency but increase HTTP overhead.
  • The server rejects additional chunks after you send finalize.

Recipe 3 – Control the session

Recipe 4 – Full synchronous runner with threads

To ingest while listening for analytics, use a background thread for SSE.

Production Notes

  • Replace the file reader with microphone capture: enqueue PCM frames and write them out via upload_chunks without staging on disk.
  • Add exponential backoff & retry for requests.post calls; resend the same chunk_seq if you get a transient network error.
  • If the SSE thread exits without a done event, inspect the last error payload and consider restarting the session.
  • Monitor /metrics for events counts and agent latency to ensure the live service keeps up with ingest.
  • Artifacts (timeline, summary, segmentation, agent outputs) are persisted and referenced by the final done event.