Overview
The SDK exposes two STT clients. Both authenticate with a single API key and support the same ten Indian languages.REST — transcribe a file
Pass a path, aPath, or any binary file object. Paths are opened and closed for you.
Response
transcribe() returns the parsed JSON body as a dict:
Parameters
Accepted file extensions:
.wav, .mp3, .flac, .ogg, .m4a, .aac. Anything else raises InvalidAudioError locally, without a network round trip.
Inverse Text Normalization
format="transcribe" rewrites numbers, currency, dates, and phone numbers into conventional written form. Add itn_native_numerals=True to keep digits in the target script.
ITN is currently supported for
hi-IN and en-IN only. See ITN reference.REST — transcribe raw bytes
When audio never touches disk — an upload handler, an S3 object, a recording buffer — usetranscribe_bytes(). The filename is a format hint for the server, not a real path.
Parameters
Realtime — streaming WebSocket
GnaniSTTStreamClient streams raw PCM to the server. Server-side VAD detects end of speech and emits a transcript per segment — you do not need to decide where utterances end.
The client is async and works as an async context manager: entering connects, exiting closes.
Constructor parameters
Invalid values raise
ValueError in the constructor, before connecting.
PCM specification
Audio must be raw PCM binary frames — no WAV, MP3, or other container mid-stream.
The SDK exports these as constants so you never hard-code them:
Realtime — three usage patterns
- Callbacks (simplest)
- Async iteration
- Manual lifecycle
stream_audio() sends and receives concurrently, paces frames for you, and returns every transcript when the source is exhausted. Best for transcribing a file or a finite stream.Stream events
Every event is a typed dataclass. Each carries.raw, the untouched JSON payload, for anything not surfaced as an attribute.
dataclass
Received once, immediately after the handshake.
dataclass
VAD has detected end of speech and transcription has begun. Useful for a “thinking” indicator.
dataclass
The transcript for one completed speech segment.
dataclass
The server encountered an error. The connection may still be usable.
Supported languages
Both clients support the same ten languages. STT uses the-IN suffix throughout.
Read them at runtime instead of hard-coding:
Realtime streaming is single-language — one
language_code per session. Multi-language input is supported only on REST POST /stt/v3 via multi_lang_codes, which is not yet exposed through the SDK.Error handling
All six inherit from
GnaniSTTError.
Further Reading
- Python SDK overview — installation, auth, client selection
- Python SDK — Text-to-Speech
- STT REST API — endpoint reference
- STT Realtime API — WebSocket protocol reference