Anam Transcription

Durable capture · live words · background events

One audio source, three transport responsibilities

The recommended browser integration uses durable HTTP PCM ingestion, an SSE metadata feed for background completion, and an optional read-only Socket.IO connection for live words. File upload uses HTTP. The transcription service processes audio and speakers; downstream applications own their reports, business rules and notifications to end users.

Responsibility Current transport Recovery
Audio capture durable_pcm_v1 HTTP append Source offset, SHA-256, writer generation and immutable receipts
Completion after leaving the screen GET /v1/events SSE Tenant-bound cursor, replay and current snapshot
Optional live words Socket.IO job:watch Per-source committed/partial snapshot and current canonical HTTP result
Canonical transcript and protected playback HTTP reads / ranged audio Fetch current authorized status, revision and availability

Credentials and resource ownership

Keep anam_sk_… backend keys exclusively on a trusted server. The integration backend reserves a capture through POST /v1/captures and issues a short, actor- and job-scoped browser token through POST /v1/browser-credentials. A public tenant UUID is a locator and grants no access. Browser requests use Authorization: Bearer <browser token>, never a query-string credential.

Use the minimum scopes required: capture:write for append/finish, jobs:read for status/transcript, recordings:read for playback, and events:read for events. Revoke grants when the host's own resource permissions change. A long-lived connection does not replace those permissions.

Durable capture flow

Trusted backend: reserve durable_pcm_v1 capture + issue scoped browser token
Browser: claim a private writer UUID/generation per reserved source
  → append exact PCM bytes at their source offset + SHA-256
  ← acknowledge only that exact frame; committed_offset is a separate high-water mark
  → release writer to pause; claim/handoff explicitly to resume
  → finish with one persisted idempotency key and all source final offsets
  ← durable seal receipt (202 / sealing), then managed processing, SSE status and HTTP result

The wire format is 16 kHz, mono, signed 16-bit little-endian PCM (pcm_s16le_16000_mono). Append whole Int16 samples and positive even offsets, with at most 1 MiB per request. Use the recorder's tested resampler; do not send MP3/WebM/WAV bytes as raw PCM.

Browser endpoint Purpose
GET /v1/browser/jobs/:jobId/capture Recover source generations, offsets and current seal status
POST …/capture/sources/:sourceId/writer Claim or recover the exact writer handoff
POST …/capture/sources/:sourceId/chunks Binary append with X-Anam-Writer-Generation, X-Anam-Chunk-Offset, X-Anam-Chunk-Sha256
POST …/capture/sources/:sourceId/writer/release Release the exact writer/generation without starting final processing
POST …/capture/finish Seal every source and schedule canonical ASR/speaker processing

Persist pending frames and writer/finish intents before sending. After a timeout, replay the exact offset, checksum and bytes; do not invent a new offset or discard every frame below the server high-water mark. Reload recovers pending delivery; it cannot recover microphone audio that the browser never captured. Known source faults remain visible even after successful processing.

Recording first; optional live delivery

Source acquisition, append acknowledgments and the immutable finish manifest do not await realtime quota, Redis publication or inference. The finish response is 202 while state: sealing: its bytes and manifest are durable, but materialization and final processing remain pending. Independent managed recovery lanes handle materialization, final ASR/diarization dispatch and optional live publication. A live failure cannot gate final work.

realtime_enabled retains the requested policy. Use realtime_delivery for requested, effective, state and a bounded reason. Live admission is counted per capture, including all sources. A quota or publisher outage reports degradation while recording continues. Effective transport admission and an open socket do not certify worker capacity or successful live text inference. Paused/crashed live quota expires at REALTIME_SESSION_IDLE_MS.

GET /readyz requires PostgreSQL and source storage; it may report 200 degraded when Redis is unavailable. Use GET /readyz/processing for strict queue-delivery dependencies. Neither probe proves GPU capacity, accuracy or latency.

Background completion: SSE

Finish certifies every reserved source with a positive confirmed byte offset. A source with zero recorded bytes cannot be omitted or invented, even with allow_incomplete: true. Acquire/resume the missing source before sealing, or retain the capture for recovery. Explicit incomplete-audio salvage preserves known faults; it does not turn missing sources into a complete recording. Browser integrations must not advertise executable salvage for an empty reserved source.

Use authenticated fetch streaming for GET /v1/events; native EventSource cannot set the required Bearer header. Send the previous opaque cursor in Last-Event-ID (or ?cursor=…, without a conflicting header). Keep this connection above route components so changing screens does not cancel it.

Event Meaning
feed.snapshot Authorized current jobs and high-water cursor; check truncated
job.updated / job.deleted Content-free status notice; reconcile through authorized HTTP reads
feed.checkpoint Advance the opaque cursor past filtered events
feed.reset History expired or has a gap; recover current state rather than assuming complete replay
feed.closed Shutdown, source failure or expired/revoked authority; renew/reconnect as appropriate

The feed contains no speech, arbitrary metadata, speaker labels or raw error details. Replay is bounded (1,000 events; 100 snapshot jobs); retention is 7 days / 10,000 events per tenant. It is not the audit-history API. Slow readers are disconnected rather than buffered indefinitely. Browser tokens expire; renew through the trusted integration backend. If SSE is unavailable, use bounded status polling with jitter/backoff and stop it when SSE recovers or the job becomes terminal.

Optional live words: read-only Socket.IO

Live processing requires the tenant capability and an explicitly live-enabled capture. Default Socket.IO path: /socket.io. This watch connection does not upload audio or hold a recording writer.

import { io } from 'socket.io-client';
const socket = io(SERVICE_ORIGIN, {
  auth: { browser_token: shortLivedToken },
  transports: ['websocket'],
});
// Token scopes: jobs:read + events:read, restricted to this job.
const snapshot = await socket.timeout(10000).emitWithAck('job:watch', { job_id: jobId });
if (!snapshot.ok) throw new Error(snapshot.error.code);
// Re-watch after reconnection; restore snapshot and reconcile canonical HTTP status.
// Before expiry, get a replacement from the trusted backend:
await socket.timeout(10000).emitWithAck('auth:refresh', { browser_token: replacementToken });

A replacement grant must preserve tenant and actor; rooms outside its new read/watch scope are removed. Backend-only key connections are also revalidated on a bounded 5-second interval and disconnected after revocation/deactivation. Browser expiry is checked on operations; database revocation checks are bounded to 5 seconds. Reconnection can fail and missed socket packets are not a durable final-result contract.

Server event Client behavior
transcript:committed Append fresh committed segments, with deduplication by source/session and sequence
transcript:partial Replace the draft tail; discard stale per-source sequence values
transcript:text Text may precede speaker inference; it is not final attribution readiness
transcript:speakers Apply speaker assignments to existing text
transcript:final Canonical result supersedes the live draft; confirm status/integrity through HTTP
job:status Reconcile status; never infer source completeness from status alone

Read subscriptions do not own recordings

Socket.IO supports job:watch and auth:refresh only. All audio acquisition, writer release and finalization use the durable HTTP capture API. Losing or renewing a live-text watcher does not pause, finish or invalidate recording. On reconnect, subscribe to the authorized job and reconcile the returned per-source sequence-bearing snapshot before applying new text.

Cost and acceptance boundaries

Base final-only capture does not start live ASR. Optional live ASR consumes additional inference work. SSE, sockets and polling all consume connection, CPU and network resources; no transport choice alone proves a lower GPU bill. Production latency, GPU capacity and cost require representative deployment measurements. Test recovery, grant renewal/revocation, source gaps and out-of-screen completion before release.

Repository contracts: docs/durable-capture-protocol.md, docs/transport-and-notifications.md, docs/native-capture-contract.md. See REST for request schemas and Webhooks for server delivery. Primary reference: Socket.IO delivery guarantees.