How heinrick7/astera-live-transcriber works
Purpose and entry points
Astera Live Transcriber is an independent Python service that converts audio into structured transcription segments, timestamps, revisions, and lifecycle events; it deliberately does not perform clinical interpretation. The ASGI entry point is src/astera_live_transcriber/main.py, which exposes HTTP, WebSocket, and a local browser UI through src/astera_live_transcriber/presentation/api/app.py.
API and session boundary
The presentation layer accepts batch-compatible WAV transcription, realtime file uploads, engine/model status requests, and bidirectional realtime audio sessions. Routes and WebSocket protocol are separated from application logic in:
• src/astera_live_transcriber/presentation/api/routes/transcriptions.py
• src/astera_live_transcriber/presentation/api/routes/files.py
• src/astera_live_transcriber/presentation/api/websocket/realtime.py
API-key authentication and dependency composition sit at the infrastructure/presentation boundary in src/astera_live_transcriber/infrastructure/auth/api_key.py and src/astera_live_transcriber/presentation/api/dependencies.py.
Application ports and orchestration
Hexagonal ports isolate the core from audio sources, speech engines, VAD, turn detection, and outbound event delivery:
• src/astera_live_transcriber/application/ports/audio_source.py
• src/astera_live_transcriber/application/ports/transcription_engine.py
• src/astera_live_transcriber/application/ports/event_publisher.py
Use cases coordinate batch and streaming paths in src/astera_live_transcriber/application/use_cases/transcribe_audio.py and src/astera_live_transcriber/application/use_cases/stream_transcription.py. Services divide pipeline processing, segmentation, streaming/session work, and inference orchestration.
Realtime audio pipeline
Audio enters as canonical PCM16 mono 16 kHz chunks (direct WebSocket) or is read from an uploaded MP3/WAV file. Chunks pass through an in-memory ring buffer, RMS VAD, and time-based turn detection before transcription. Key implementation stages are:
• src/astera_live_transcriber/application/services/audio_pipeline.py
• src/astera_live_transcriber/infrastructure/audio/buffer.py
• src/astera_live_transcriber/infrastructure/vad/rms.py
• src/astera_live_transcriber/infrastructure/turn_detection/time_based.py
The pipeline applies bounded backpressure and session cleanup. File sessions retain the source temporarily and stream/decode it rather than materializing full PCM: src/astera_live_transcriber/infrastructure/audio/file_session_manager.py, src/astera_live_transcriber/infrastructure/audio/file_source.py. File decoding requires ffmpeg.
Transcript lifecycle and domain model
Domain entities model audio, sessions, transcription segments, and events. Realtime output follows stable segment identity through partial → revised → committed; EOF or microphone stop flushes and force-commits active speech. Core definitions are:
• src/astera_live_transcriber/domain/transcription/entities.py
• src/astera_live_transcriber/domain/transcription/events.py
• src/astera_live_transcriber/domain/session/entities.py
src/astera_live_transcriber/application/services/segment_service.py owns segment construction/lifecycle, while transcription_service.py invokes the selected engine.
Speech-engine runtime
A runtime-selected engine adapter implements the transcription port:
• src/astera_live_transcriber/infrastructure/engines/runtime.py
• src/astera_live_transcriber/infrastructure/engines/noop/adapter.py
• src/astera_live_transcriber/infrastructure/engines/parakeet/adapter.py
noop is the safe default. Optional NVIDIA Parakeet TDT 0.6B v3 INT8 uses sherpa-onnx; its loader validates all ONNX artifacts, loads once, and keeps the recognizer resident (src/astera_live_transcriber/infrastructure/engines/parakeet/loader.py). Missing Parakeet assets fail explicitly rather than falling back.
Runtime, delivery, and observability
The service runs under Uvicorn/Python, with Docker Compose for local deployment (Dockerfile, docker-compose.yml). Configuration is environment-driven in src/astera_live_transcriber/infrastructure/config/settings.py. Logging and pipeline metrics—including lag, inference rate, and discarded late cancellation results—are implemented in src/astera_live_transcriber/infrastructure/observability/logging.py and src/astera_live_transcriber/infrastructure/observability/metrics.py. CI runs in GitHub Actions; staging deployment is manually triggered and isolated from production.
Main entry points: audio_pipeline.py Streaming audio pipeline · app.py API application · stream_transcription.py Streaming transcription · dependencies.py Auth and dependencies
Components 20
Presentation
- ASGI entry point
src/astera_live_transcriber/main.py - API application
src/astera_live_transcriber/presentation/api/app.py - Transcription and file routes · Supports WAV transcription, uploads, and engine status.
src/astera_live_transcriber/presentation/api/routes/transcriptions.py - Realtime WebSocket · Accepts bidirectional PCM16 mono 16 kHz sessions.
src/astera_live_transcriber/presentation/api/websocket/realtime.py - Auth and dependencies · API-key authentication and dependency wiring.
src/astera_live_transcriber/presentation/api/dependencies.py
Application Core
- Batch transcription
src/astera_live_transcriber/application/use_cases/transcribe_audio.py - Streaming transcription
src/astera_live_transcriber/application/use_cases/stream_transcription.py - Core ports · Abstract audio sources, engines, VAD, turn detection, and event delivery.
src/astera_live_transcriber/application/ports/transcription_engine.py - Segment lifecycle · Builds partial, revised, and committed segments.
src/astera_live_transcriber/application/services/segment_service.py - Transcript and session model · Stable segment identity and lifecycle events.
src/astera_live_transcriber/domain/transcription/entities.py
Audio Processing
- Streaming audio pipeline · Applies bounded backpressure and cleanup.
src/astera_live_transcriber/application/services/audio_pipeline.py - In-memory ring buffer
src/astera_live_transcriber/infrastructure/audio/buffer.py - RMS VAD
src/astera_live_transcriber/infrastructure/vad/rms.py - Time-based turn detection
src/astera_live_transcriber/infrastructure/turn_detection/time_based.py - Streaming file source · Temporarily retains and ffmpeg-decodes uploaded MP3/WAV without full PCM materialization.
src/astera_live_transcriber/infrastructure/audio/file_session_manager.py
Speech Engines
- Runtime engine selector · Selects the configured transcription engine.
src/astera_live_transcriber/infrastructure/engines/runtime.py - Noop and Parakeet adapters · Noop is default; Parakeet missing assets fail explicitly.
src/astera_live_transcriber/infrastructure/engines/parakeet/adapter.py - Parakeet model loader · Validates assets and retains a resident sherpa-onnx recognizer.
src/astera_live_transcriber/infrastructure/engines/parakeet/loader.py
Runtime & Operations
- Uvicorn and Docker deployment · Python service with local Docker Compose deployment.
Dockerfile - Logging and pipeline metrics · Records lag, inference rate, and discarded late cancellations.
src/astera_live_transcriber/infrastructure/observability/metrics.py
Connections 23
- ASGI entry point → API application: starts
- API application → Transcription and file routes: serves
- API application → Realtime WebSocket: serves
- API application → Auth and dependencies: wires
- Auth and dependencies → Batch transcription: injects
- Auth and dependencies → Streaming transcription: injects
- Transcription and file routes → Batch transcription: batch/upload requests
- Realtime WebSocket → Streaming transcription: audio session
- Batch transcription → Streaming file source: reads uploaded audio
- Streaming transcription → Streaming audio pipeline: processes chunks
- Streaming file source → Streaming audio pipeline: decoded stream
- Streaming audio pipeline → In-memory ring buffer: buffers
- Streaming audio pipeline → RMS VAD: detects speech
- RMS VAD → Time-based turn detection: speech timing
- Time-based turn detection → Segment lifecycle: opens and flushes turns
- Segment lifecycle → Transcript and session model: emits lifecycle
- Streaming audio pipeline → Runtime engine selector: transcribes turns
- Runtime engine selector → Core ports: implements engine port
- Runtime engine selector → Noop and Parakeet adapters: selects
- Noop and Parakeet adapters → Parakeet model loader: loads Parakeet
- Streaming transcription → Transcript and session model: publishes events
- Streaming audio pipeline → Logging and pipeline metrics: records metrics
- Uvicorn and Docker deployment → ASGI entry point: runs