Usage guide
Setup, environment variables, and Python/JavaScript/Go usage examples.
GladiaSTT
Gladia real-time speech-to-text via WebSocket streaming. Wraps the Gladia Live Speech Recognition API (v2) using thesolaria-1
model, which supports 90+ languages with optional per-utterance language
detection (code-switching).
Constructor
Gladia API key. Falls back to the
GLADIA_API_KEY environment variable when None.Gladia recognition model.
"solaria-1" is the only production model and the default.ISO 639-1 language codes to hint at (e.g.
["en", "fr"]). Only the first element is used. When None the default is "english".When
True, language is re-detected on every utterance. When False, language is detected once on the first utterance and held for the session. Default: True.Sample rate (Hz) of the incoming audio before any resampling. Valid values:
8000, 16000, 32000, 44100, 48000. Default: 48000.Sample rate (Hz) forwarded to the Gladia WebSocket session. Default:
16000.PCM encoding format sent over the WebSocket. Valid values:
"wav/pcm" (default), "wav/alaw", "wav/ulaw".Bit depth of the PCM samples. Valid values:
8, 16 (default), 24, 32.Number of audio channels (1–8). Default:
1 (mono).When
True, partial (non-final) transcripts are emitted over the WebSocket before the utterance is complete. Default: False.aclose
emit
The event to emit.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.on_stt_transcript
An async callable that receives each
STTResponse.process_audio
Raw audio bytes to transcribe.
Optional language code to guide recognition.
stream_transcribe
An async iterator yielding raw audio byte chunks.
STTResponse: Transcription events produced as audio is consumed.