bodhi-realtime-agent / STTProvider
Interface: STTProvider
Defined in: src/types/transport.ts:146
Provider-agnostic interface for pluggable speech-to-text providers.
VoiceSession creates the provider, calls configure() with the transport's audio format, then start(). Audio flows via feedAudio(); turn signals via commit()/handleInterrupted()/handleTurnComplete(). Results arrive via the onTranscript/onPartialTranscript callbacks.
Properties
onPartialTranscript?
optionalonPartialTranscript?: (text) =>void
Defined in: src/types/transport.ts:190
Partial/interim transcription (streaming providers only). Replaces any previous partial for the same turn.
Parameters
text
string
Returns
void
onTranscript?
optionalonTranscript?: (text,turnId) =>void
Defined in: src/types/transport.ts:186
Final transcription of user speech.
Parameters
text
string
The transcribed text.
turnId
number | undefined
The turn this transcript belongs to (from commit()). Undefined when a streaming provider's VAD auto-commits before the framework calls commit().
Returns
void
supportedEncodings?
readonlyoptionalsupportedEncodings?: readonly ("pcm"|"pcmu")[]
Defined in: src/types/transport.ts:151
Optional static declaration of which audio encodings the provider can consume. When omitted, defaults to ['pcm'] (today's behaviour). VoiceSession reads this at configure time and decides whether to feed raw PCM or encode to G.711 before calling feedAudio().
Methods
commit()
commit(
turnId):void
Defined in: src/types/transport.ts:171
Signal that the user's turn has ended (model started responding). For batch providers, this triggers transcription. For streaming providers, this may trigger a manual commit.
Parameters
turnId
number
Monotonically increasing turn counter for ordering.
Returns
void
configure()
configure(
audio):void
Defined in: src/types/transport.ts:156
Configure the audio format that feedAudio() will deliver. Called once before start(). The provider MUST resample or reject if it cannot handle the given format.
Parameters
audio
Returns
void
feedAudio()
feedAudio(
base64Pcm):void
Defined in: src/types/transport.ts:165
Feed audio data. Format matches the STTAudioConfig from configure().
Parameters
base64Pcm
string
Base64-encoded PCM audio chunk.
Returns
void
handleInterrupted()
handleInterrupted():
void
Defined in: src/types/transport.ts:175
Signal that the current turn was interrupted by the user. Providers MUST preserve buffered audio for the next commit().
Returns
void
handleTurnComplete()
handleTurnComplete():
void
Defined in: src/types/transport.ts:179
Signal a natural turn completion (model finished, no interruption). Batch providers SHOULD clear buffers. Streaming providers may no-op.
Returns
void
start()
start():
Promise<void>
Defined in: src/types/transport.ts:159
Start the STT session (e.g. open WebSocket).
Returns
Promise<void>
stop()
stop():
Promise<void>
Defined in: src/types/transport.ts:161
Stop the STT session (e.g. close WebSocket).
Returns
Promise<void>