Expand description
HTTP + WebSocket server that accepts audio and streams transcripts.
Single port serves both REST API (health, transcribe, SSE) and WebSocket.
Modules§
- http
- HTTP handlers for REST API endpoints.
- metrics
- Minimal Prometheus text-exposition registry (replaces
metrics-exporter-prometheus). - rate_
limit - Per-IP token-bucket rate limiter.
Structs§
- Origin
Policy - Origin policy for CORS + cross-origin deny middleware.
- Runtime
Limits - Runtime limits surfaced to per-request handlers. Separate from
ServerConfigbecause it needs to travel throughhttp::AppStateto the WebSocket handler. - Server
Config - Server runtime configuration.
run_with_configis the canonical entry point;run/run_with_shutdownremain as thin wrappers for callers that only need the pre-0.6 positional parameters.
Enums§
- Frame
Outcome - Outcome returned by per-frame handlers. Keeps
handle_ws_innera thin orchestration loop instead of a 250-line one-big-match.
Functions§
- handle_
binary_ frame - Handle a single PCM16 audio frame: resample if needed, run inference in a
spawn_blockingguarded bycatch_unwind, and emit partial/final/error payloads. Always returns the triplet totriplet_opt(or recovers a fresh state after an inference panic) so the connection can keep serving. - handle_
ws - run
- Start the HTTP + WebSocket STT server on the given host and port.
- run_
with_ config - Start server with a full
ServerConfigand optional programmatic shutdown signal. This is the canonical entry point — the otherrun_*helpers construct a defaultServerConfigand dispatch here. - run_
with_ shutdown - Start server with an optional programmatic shutdown signal.
- session_
deadline_ instant - Clamp
shutdown_drain_secsto a minimum of 1 so the drain window is never zero-length (which would immediately kill in-flight tasks). fires in practice. - ws_
handler - ws_
handler_ legacy - Deprecated WebSocket endpoint at
/ws. Identical behaviour to/v1/wsbut emits a warn-level log on every upgrade and adds RFC 8594DeprecationplusLink: </v1/ws>; rel="successor-version"headers on the upgrade response so client libraries can surface the migration warning to users before v1.0 drops the alias. - ws_
shutdown_ response