AbsoluteJS

Adapter Contracts

How provider adapters satisfy the @absolutejs/voice STT, TTS, and realtime contracts, including audio formats, endpointing, language strategy, and cancellation semantics.

#STTAdapter

STT adapters expose open() and return a session that receives audio chunks and emits partial, final, endOfTurn, error, and close events.
Provider-specific endpointing is normalized into endOfTurn so runtime turn detection can combine vendor, silence, semantic, or manual policies.
Adapters should reject unsupported encodings at open time instead of accepting audio that the provider cannot decode.
The voice runtime may replay buffered user audio to fallback STT providers when the primary provider returns empty, late, or low-confidence results.

#TTSAdapter

TTS adapters expose open() and return a session that receives assistant text and emits normalized audio chunks, errors, and close events.
Streaming TTS adapters should forward chunks as soon as the vendor body produces them so playback can start before the full utterance is generated.
Adapters that support warm sessions or WebSocket transports can reduce first-audio latency for repeated turns.
Optional cancel() support lets the runtime stop assistant audio during barge-in.

#RealtimeAdapter

Realtime adapters accept user audio or text and emit input transcripts, assistant transcripts, assistant audio, turn completion, errors, and close events.
OpenAI Realtime currently enforces pcm16 input at 24 kHz; the adapter validates that audio before send().
Gemini Live normalizes Gemini WebSocket events into the same RealtimeAdapter surface so the runtime route does not need provider-specific logic.
Realtime routes can coexist with cascaded STT/TTS routes under separate paths such as /voice/realtime and /voice/intake.

#Language And Formats

AudioFormat carries encoding, sample rate, and channel count; documented encodings include pcm_s16le, pcm_f32le, mulaw, pcm_mulaw, alaw, and pcm_alaw depending on provider.
languageStrategy resolves fixed, auto-detect, or allow-switching behavior before the adapter opens its provider session.
phraseHints and lexicon values are runtime-level inputs that adapters can map to provider-specific boosting, keyword, glossary, or vocabulary fields.
Telephony bridges usually prefer μ-law at 8 kHz at the carrier edge, while browser and realtime routes often use PCM at higher sample rates.