rtc-asr is a lightweight FastAPI service for benchmarking and serving ASR over REST or WebSocket. This can be used for real time and on demand caption generation or transcription. It is optimized for warmed, local or on-device inference paths, especially low-power and average CPU, Apple Silicon, and small accelerator setups. The core contract stays stable while you swap ASR backends underneath it, which makes it useful as a thin speech layer in RTC stacks, voice agents, and local benchmarking.
An open-source project from WebRTC.ventures.
The service currently supports faster-whisper, qwen-asr, parakeet, parakeet-mlx, parakeet-nemo, and experimental voxtral backends behind the same API surface.
GET /healthfor liveness plus active backend/model metadataGET /readyfor preload status and degraded startup reportingGET /api/modelsfor backend/model capability metadata that RTC clients can inspectPOST /api/transcribefor one-shot base64 audio requestsPOST /api/transcribe/filefor uploaded file transcriptionws://.../v1/stt/streamfor Local STT v1 JSON-control plus binary-PCM websocket streaming (recommended)ws://.../ws/streamfor the older buffered websocket transcription path withready,partial,final,canceled, anderrorevents- Shared client helpers in
src/rtc_client.pyandsrc/streaming.py - A browser Pipecat demo at
http://127.0.0.1:8090/rtc-asrwhen you run the companion demo service
python3 -m venv .venv
. .venv/bin/activate
pip install -U pip
pip install -r requirements.txt
uvicorn src.main:app --host 0.0.0.0 --port 8080 --reloadThe default local dependency set is pinned for the repo's qwen-asr stack. If you want to run the Hugging Face Parakeet path outside Docker Compose, upgrade that local runtime first:
pip install --upgrade --no-deps huggingface-hub==1.18.0 transformers==5.10.2
docker compose build docker compose up -d docker compose ps docker compose logs -f
That Compose stack starts the main ASR service on http://127.0.0.1:8080; make start is the equivalent ASR-only shortcut. Use make start-demo or docker compose --profile demo up -d --build when you also want the browser Pipecat demo on http://127.0.0.1:8090/rtc-asr.
Compose tags the default ASR image as realtime-asr:faster-whisper-cpu. The Dockerfile also exposes backend-specific build targets: asr-faster-whisper-cpu, asr-qwen-cpu, asr-parakeet-transformers-cpu, asr-parakeet-nemo-cpu, and browser-pipecat-demo. The backend benchmark targets use separate tags such as realtime-asr:qwen-cpu, realtime-asr:parakeet-transformers-cpu, and realtime-asr:parakeet-nemo-cpu so repeated builds can be inspected and compared without overwriting the default image.
Compose persists downloaded Hugging Face model files in the rtc_asr_hf_cache Docker named volume and points HF_HOME and HUGGINGFACE_HUB_CACHE at that mount. A named volume avoids the extra host-filesystem translation cost that Docker Desktop can add to a bind-mounted ./.cache/huggingface directory while still surviving container recreation. Inspect it with docker volume inspect rtc-asr_rtc_asr_hf_cache; clear it with docker compose down -v when you intentionally want a cold-cache run.
The Dockerfile uses a BuildKit pip cache mount, so repeated backend builds can reuse downloaded wheels without baking pip's cache into the runtime image. Docker Compose enables BuildKit by default on current Docker Desktop and Docker Engine releases; if a legacy shell disables it, run DOCKER_BUILDKIT=1 docker compose build.
Run make compose-config-check before heavier image builds when you only need a fast structural check of the default ASR-only config, the optional browser demo profile, and the Qwen, Transformers Parakeet, and NeMo Parakeet backend selections.
For the most useful default CPU baseline, start with:
ASR_BACKEND=faster-whisper ASR_MODEL_SIZE=base.en ASR_DEVICE=cpu ASR_COMPUTE_TYPE=int8
If you only need a smoke-test edge lane, tiny.en is a reasonable alternate quick-start. Use base.en for the more representative low-power benchmark lane.
HOST=0.0.0.0 PORT=8080 SAMPLE_RATE=16000 STREAM_MAX_BUFFER_BYTES=1048576 LOCAL_STT_ENABLE_PCM16_FAST_PATH=true LOCAL_STT_REQUIRE_TARGET_SAMPLE_RATE=true LOCAL_STT_TARGET_SAMPLE_RATE=16000 ASR_BACKEND=faster-whisper ASR_MODEL_SIZE=base.en ASR_DEVICE=cpu ASR_COMPUTE_TYPE=int8 ASR_PRELOAD_MODEL=false ASR_FAIL_FAST=false
Backend-specific variables are available for Qwen, Parakeet, NeMo Parakeet, and experimental Voxtral. Set ASR_VOXTRAL_MAX_NEW_TOKENS to cap realtime decode length for predictable latency on the Transformers path, and optionally set ASR_VOXTRAL_ATTN_IMPLEMENTATION when a local Transformers/Torch stack needs a specific attention backend such as sdpa or flash_attention_2. Voxtral accepts ASR_BACKEND=voxtral, voxtral-realtime, voxtral-mini, or voxtral-mini-4b for the Mini 4B Transformers adapter, and ASR_BACKEND=voxtral-mlx, voxtral-realtime-mlx, voxtral-mini-mlx, or voxtral-mini-4b-mlx for the Apple Silicon MLX 4-bit adapter. Set ASR_VOXTRAL_TRANSCRIPTION_DELAY_MS=480 for the MLX model-card default latency/accuracy balance. Set ASR_PRELOAD_MODEL=true when you want startup-time backend validation instead of lazy first-use loading. See API Reference and Troubleshooting for backend-specific behavior.
If ASR_DEVICE is unset but CUDA_VISIBLE_DEVICES exposes a GPU, the service defaults to cuda. Legacy aliases MODEL_NAME and AUDIO_SAMPLE_RATE are still accepted for compatibility.
| Profile | Target | Backend | Model | Notes |
|---|---|---|---|---|
| Tiny CPU | Raspberry Pi / mini PC | faster-whisper |
tiny.en int8 |
Best smoke test, lowest accuracy |
| Practical CPU | Mac Mini / N100 / laptop | faster-whisper or parakeet-nemo |
base.en int8 or nvidia/parakeet-tdt_ctc-110m |
Good default benchmark lane; 110M Parakeet is the higher-quality CPU comparison |
| Apple Silicon | M-series Mac | parakeet-mlx or voxtral-mlx |
mlx-community/parakeet-tdt_ctc-110m, mlx-community/parakeet-tdt-0.6b-v3, or mlx-community/Voxtral-Mini-4B-Realtime-2602-4bit |
Strong warmed latency and power tradeoff; Voxtral MLX is the 4-bit realtime comparison lane |
| Not low-power | Large CPU or accelerator comparison lane | qwen-asr, experimental voxtral, Canary Flash, or larger Parakeet variants |
Qwen/Qwen3-ASR-0.6B, mistralai/Voxtral-Mini-4B-Realtime-2602, nvidia/canary-1b-flash, or nvidia/parakeet-tdt-0.6b-v3 |
Useful comparison, not the default edge path |
Current checked-in benchmarks make the Apple Silicon story especially strong for the warmed parakeet-mlx-service-110m lane. See Benchmarks for the latest artifact-backed numbers.
Prefer ws://localhost:8080/v1/stt/stream for new integrations. The Local STT v1 contract is the primary streaming surface for this repo, and docs/local-stt-v1.md is the canonical integration guide.
Use the legacy ws://localhost:8080/ws/stream route only when you need backward compatibility with the older buffered websocket API or when comparing against historical benchmark artifacts. That route remains useful as a local buffered-websocket stress harness, but it is not the contract we want new clients to target.
For the full Local STT v1 handshake, message types, and examples, start with docs/local-stt-v1.md. At a high level:
- Open
ws://localhost:8080/v1/stt/stream. - Send the Local STT v1 control message that configures the stream.
- Send mono PCM16 audio as binary websocket frames.
- Read interim and final transcript events from the server.
- End the turn using the Local STT v1 finalize/close flow described in the spec.
The legacy /ws/stream path is buffered websocket ASR rather than a frame-synchronous decoder contract. Partial transcripts are generated from buffered windows and backend behavior varies. A fast partial event there does not always mean the backend is a true streaming ASR model.
Example start event:
{
"type": "start",
"language": "en",
"sample_rate": 16000,
"partial_interval_chunks": 1,
"partial_window_seconds": 1.0,
"max_buffer_seconds": 10.0
}Example ready event:
{
"type": "ready",
"stream_id": 1,
"backend": "faster-whisper",
"model": "base.en",
"language": "en",
"sample_rate": 16000,
"partial_interval_chunks": 1,
"max_buffer_bytes": 1048576
}After a final event, the legacy /ws/stream socket stays open so the client can start the next utterance without reconnecting.
- Preferred transport is mono PCM16 chunks over binary websocket frames.
- JSON base64 audio events are still supported for simpler clients.
- A
sample_ratemust be supplied in thestartevent for raw PCM streams. - Start with
100to200ms PCM16 chunks for service benchmarking. - Use
20ms only when bridging from RTC audio frames, and aggregate before websocket transmission unless you are explicitly measuring per-frame overhead. - The service decodes and resamples once through the shared audio processor before handing audio to the configured backend.
partial_window_secondsandmax_buffer_secondslet clients cap how much buffered audio feeds partials and finals.
Use WebRTC, RTP, or Opus only at the media edge, then forward normalized raw audio into rtc-asr over a simple websocket. That keeps rtc-asr focused on ASR benchmarking and serving instead of turning it into a media server.
This is also why the repo ships a small Local STT service and Pipecat adapter instead of relying only on existing Pipecat STT plugins. Pipecat already gives voice apps a strong media and pipeline layer, and its provider plugins are a good fit when the ASR runtime is an external service. rtc-asr covers a different job: keep local ASR models warm, expose the same REST/websocket contract across backends, capture reproducible latency artifacts, and let Pipecat talk to that sidecar through a minimal PCM protocol. That separation makes local CPU, Apple Silicon, and accelerator experiments comparable without baking one Pipecat release or one hosted provider schema into the ASR service.
Browser / mobile mic
-> WebRTC / RTP / Opus
Pipecat transport
-> decoded PCM frames, usually ~20 ms
Chunk aggregator
-> binary PCM16 websocket frame every 80-160 ms
rtc-asr /v1/stt/stream
-> partial/final transcript events
Voice agent pipeline
Why aggregate 20 ms frames before sending them to rtc-asr? Sending every RTC frame directly is responsive in theory, but it creates unnecessary websocket and CPU overhead while giving the backend very little audio context per partial. Aggregating roughly 4 to 8 RTC frames into 80 to 160 ms websocket chunks keeps transcription responsive, produces steadier partials, maps cleanly from RTC frame cadence, and avoids excessive message rates on smaller devices. Larger chunks can be useful for benchmarking, but they start to trade away live interaction latency.
Most ASR backends have a cold-start penalty from model load, graph compilation, and first-request cache setup. That means the very first transcription can be much slower than steady-state traffic, especially for MLX, MPS, and larger transformer-based models.
Best practice for production-style serving:
- Set
ASR_PRELOAD_MODEL=trueso model load happens at startup instead of on the first live request. - Gate traffic on
GET /readyrather than onlyGET /healthso callers wait for preload to finish. - Send one short warm-up transcription after startup or deploy before measuring latency or shifting traffic.
- Keep the process resident and reuse it across requests; avoid one-shot CLI-style invocations if you care about real serving latency.
- If a platform idles containers or workers aggressively, use a small synthetic keep-warm request on a cadence that matches that platform's eviction behavior.
In this repo, checked-in service benchmarks use warmed server flows for apples-to-apples latency comparisons. Cold CLI preview artifacts are useful for exploration, but they should not be treated as the steady-state serving baseline.
For low-power claims, latency alone is not enough. Recommended benchmark fields:
- device, CPU, and RAM
- accelerator type: none, MPS, MLX, CUDA, or NPU
- wall latency: REST mean and P95, ASR TTFB / first partial, and final
- realtime factor (
RTF) - peak RSS memory
- CPU utilization
- package power when available
- sustained thermal behavior over
5to10minutes - transcript churn across partial updates
The checked-in artifacts already cover warmed service latency, ASR TTFB / first partial responsiveness, RTF, Local STT interim transcript churn, process RSS, and CPU utilization. Use --package-power-watts and --thermal-state to attach external power and thermal observations when those measurements are available.
- Prefer
/v1/stt/streamfor active development and new clients;/ws/streamis the legacy buffered websocket path. /ws/streamis buffered websocket ASR, not a native frame-synchronous decoder API.- Partial transcripts are computed from the current buffered window, so lower latency settings can increase transcript instability.
- Backend behavior varies widely; equal chunk cadence does not guarantee equal partial quality or equal streaming semantics.
rtc-asris not a WebRTC media server. Use Pipecat, LiveKit, or another transport layer for RTC session handling and audio decoding.
python -m compileall src tests pytest tests/test_client.py tests/test_model_loader.py tests/test_smoke.py -v curl http://localhost:8080/health curl -f http://localhost:8080/ready curl http://localhost:8080/api/models
Use the checked-in benchmark flow when you need reproducible latency artifacts:
For pre/post optimization comparisons, keep the audio fixture, --frame-ms, --partial-interval-ms, backend, model, device, compute type, preload setting, and run count unchanged between artifacts. Compare summary.time_to_first_interim_ms, summary.partial_cadence_p95_ms, summary.time_to_final_after_finalize_ms, summary.audio_end_finalization_rtf, summary.audio_send_duration_ms, summary.send_receive_overlap_ms, summary.pcm16_normalization_p95_ms, warning counts, and protocol error counts first; summary.send_receive_overlap_ms proves interim/final events arrived while audio was still being sent, summary.audio_end_finalization_rtf normalizes finalization lag by clip duration, and summary.asr_decode_p95_ms stays reserved for server-side backend decode timing when exposed separately. Then inspect raw per-run samples for outliers before claiming a regression or win.
make benchmark-faster-whisper-matrix make benchmark-qwen-mps make benchmark-compose-qwen make benchmark-compose-parakeet make benchmark-compose-parakeet-nemo make benchmark-site-check make benchmark-artifact-cleanup-check
For fair comparisons, benchmark the warmed service path when possible. One-shot runs mostly measure startup overhead, while the service harness reflects the latency users see after preload and warm-up.
The benchmark harness now defaults to preloaded runs. Managed benchmark servers start with ASR_PRELOAD_MODEL=true, and benchmarks against an existing service fail by default unless /api/models reports preload_enabled=true. Use --allow-unpreloaded-service only when you intentionally want a cold-path diagnostic run.
Use make benchmark-artifact-cleanup-check in CI or release prep to fail when legacy benchmark artifacts older than BENCHMARK_ARTIFACT_CLEANUP_DAYS still need cleanup.
Use make benchmark-artifact-cleanup-plan when you want the matching artifact and detail-page paths printed relative to the repo root for a reviewable cleanup commit.
For direct script usage, --repo-relative-paths also accepts shorter cleanup aliases like --repo-paths, --repo-relative, --relative-paths, and --relative.
The stale-artifact summary output flags also accept review-friendly aliases such as --summary-text, --text-summary, --summary-text-output, --text-summary-output, --summary-json, --summary-json-output, --json-summary-output, --csv-summary, --csv-summary-output, --summary-csv-output, --markdown-summary, --markdown-summary-output, --summary-md, --md-summary, --summary-md-output, and --md-summary-output.
The stale-artifact sort flags accept readable direction aliases such as --sort largest-to-smallest, --sort smallest-to-largest, --sort newest-to-oldest, and --sort oldest-to-newest.
The Compose image size report accepts readable image tag aliases such as --tag, --tags, and --image-tags, readable summary aliases such as --summary, --summary-json, --summary-csv, and --summary-markdown, readable budget aliases such as --size-budget, --total-budget, --deduplicated-total-budget, --age-budget, --older-than, and --missing-budget, plus readable sort aliases such as --sort largest-to-smallest, --sort newest-to-oldest, --sort stale-first, --sort present-first, --sort present-last, --sort missing-first, --sort missing-last, --sort known-size-first, --sort known-size-last, --sort known-created-first, --sort known-created-last, --sort duplicate-id-first, and --sort duplicate-id-last, and readable gate aliases including --all-images-present, --any-image-present, --require-known-image-size, --require-known-image-created, --known-image-id, and --unique-image-ids. Size budgets accept units such as MB or GiB; image age budgets accept bare days plus h, d, and w suffixes. Summary output also reports deduplicated present-image size and shared-image size savings so tag aliases do not hide the actual local Docker footprint. Use --include-container-refs to show container names that currently reference inspected tags before any manual prune, and use make compose-image-hygiene-check for a review-friendly 14-day metadata and duplicate-ID gate before pruning local Compose images.
The Local STT backend comparison script accepts review-friendly aliases such as --baseline-key, --baseline-backend, --candidate-key, --candidate-backend, --json-output, --comparison-output, --markdown-report, --report-output, --min-ttfb-win-ms, --min-first-interim-win-ms, --require-resources, --require-resource-evidence, and --min-streams. Its resource evidence check also accepts common artifact field aliases such as metrics.memory.rss_peak_mb and metrics.cpu.average_utilization_percent.
The streaming backend artifact comparison script accepts path aliases such as --baseline-artifact, --baseline-json, --candidate-artifact, --candidate-json, --json-output, --comparison-output, --markdown-report, --md-report, --summary-markdown, and --report-output. The Local STT transport comparator also accepts readable Markdown output aliases such as --markdown-report, --md-report, --summary-markdown, and --report-output, plus readable minimum-run aliases such as --minimum-runs, --min-run-count, --minimum-run-count, --min-samples, and --minimum-samples.
The one-shot Parakeet MLX benchmark accepts readable aliases such as --mlx-model, --runs, --input-audio, --synthesis-text, --cli-command, --average-package-power-watts, --thermal-status, --thermal-duration-min, and --json-output.
The repo has a few different roles in one place: the main ASR service, benchmark tooling, docs and generated artifacts, and Pipecat-facing examples or adapters. The quickest way to orient yourself is:
src/: mainrtc-asrFastAPI service, backend adapters, audio normalization, shared client helpers, and Local STT v1 protocol codetests/: service, protocol, benchmark, and integration-focused test coveragedocs/: human-facing docs, benchmark notes, and the checked-in site contentdocs/benchmark-results/: tracked JSON benchmark artifacts, generated detail pages, and the homepage manifest used bydocs/index.htmlexamples/browser_pipecat_demo/: browser + Pipecat demo that talks tortc-asrexamples/pipecat_local_stt_bot/: example Pipecat bot that consumes the Local STT flowpipecat-local-stt/: separate Python package for the reusable Pipecat Local STT adapter/plugin codescripts/: manifest generation, homepage prerendering, and other repo maintenance helpersmodels/: optional local model cache or runtime assets when you are experimenting outside Compose
Two names are easy to confuse:
pipecat-local-stt/is the standalone adapter packageexamples/pipecat_local_stt_bot/is an example app that uses that adapter
Longer term, we may want to tighten that naming story further, but the intended split today is package vs example application.
Start here, depending on what you need:
- Service entrypoints:
src/main.py - Backend loading and selection:
src/model_loader.py - Primary streaming contract: Local STT v1
- Benchmarks and published results: Benchmarks
- Pipecat integration code:
pipecat-local-stt/andexamples/pipecat_local_stt_bot/
Reference docs:
- Docs Index
- API Reference
- Pipecat Integration
- Browser Pipecat Demo
- LiveKit Integration
- Troubleshooting
This project is part of the WebRTC.ventures open-source voice-agent reliability initiative. The projects remain independently usable and integrate through explicit adapters and evidence contracts:
- ConversationAgentEvals orchestrates tests, normalizes evidence, and reports regressions.
- Agentic Contact Center is the reference voice-agent target and demonstration.
- rtc-asr provides optional local streaming speech-to-text and reproducible ASR benchmarks.
- ASSERT remains the upstream evaluation engine.
flowchart LR
CAE["ConversationAgentEvals<br/>Test orchestration + evidence"]
ACC["Agentic Contact Center<br/>Reference target"]
ASR["rtc-asr<br/>Optional local STT"]
ASSERT["ASSERT<br/>Evaluation engine"]
CAE -->|"test scenarios"| ACC
ACC -->|"proof bundle"| CAE
ACC -->|"audio"| ASR
ASR -->|"transcripts"| ACC
CAE -->|"canonical evaluation"| ASSERT
Licensed under the Apache License 2.0.
