Sarvam Streaming Speech-to-Text — Python SDK
Real-time speech-to-text for Indian languages. Stream audio in, get transcripts back — with sentence-level segmented transcripts for high-quality, complete outputs.
Installation
pip install sarvam-transcribe-streaming-sdk
Requires Python 3.9+.
Quick Start
import asyncio
from sarvam_transcribe import SarvamStreamingClient
from sarvam_transcribe.handlers import TranscriptResultStreamHandler
from sarvam_transcribe.model import TranscriptEvent
SARVAM_STT_URL = "wss://stt.example.com"
SARVAM_API_KEY = "your-api-key"
AUDIO_FILE = "recording.pcm" # 16kHz, mono, 16-bit PCM
CHUNK_SIZE = 16000 # 500ms of audio
class MyHandler(TranscriptResultStreamHandler):
async def handle_transcript_event(self, event: TranscriptEvent):
for result in event.transcript.results:
for alt in result.alternatives:
prefix = "..." if result.is_partial else ">>>"
print(f"{prefix} {alt.transcript}")
async def main():
client = SarvamStreamingClient(
url=SARVAM_STT_URL,
api_key=SARVAM_API_KEY,
)
stream = await client.start_stream_transcription(
language_code="hi-IN",
)
async def send_audio():
with open(AUDIO_FILE, "rb") as f:
while chunk := f.read(CHUNK_SIZE):
await stream.input_stream.send_audio_event(audio_chunk=chunk)
await asyncio.sleep(CHUNK_SIZE / (16000 * 2)) # real-time pacing
await stream.input_stream.end_stream()
handler = MyHandler(stream.output_stream)
await asyncio.gather(send_audio(), handler.handle_events())
asyncio.run(main())
Output:
... प्रधानमंत्री ने
... प्रधानमंत्री ने आज कहा कि
>>> प्रधानमंत्री ने आज कहा कि देश आगे बढ़ रहा है।
... हमें
... हमें मिलकर काम
>>> हमें मिलकर काम करना होगा।
Lines prefixed with ... are partial results (the transcript so far, which
may still change). Lines prefixed with >>> are final results (complete,
endpointed sentences ready for downstream use).
Supported Languages
| Language | Code |
|---|---|
| Hindi | hi-IN |
| Bengali | bn-IN |
| Kannada | kn-IN |
| Malayalam | ml-IN |
| Marathi | mr-IN |
| Odia | od-IN |
| Punjabi | pa-IN |
| Tamil | ta-IN |
| Telugu | te-IN |
| English (Indian) | en-IN |
| Gujarati | gu-IN |
| Auto-detect | unknown |
Audio Requirements
| Property | Value |
|---|---|
| Format | Raw PCM (no WAV header) |
| Sample rate | 16,000 Hz |
| Bit depth | 16-bit signed, little-endian |
| Channels | Mono (1 channel) |
| Recommended chunk size | 100–500 ms (3,200–16,000 bytes) |
| Max chunk size | 32 KB (1 second) |
Documentation
For full API reference, examples (microphone streaming, file transcription, collecting results), error handling, and migration guide from AWS Transcribe SDK, contact us.
License
Apache-2.0
Metadata
Release files for sarvam-transcribe-streaming-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sarvam_transcribe_streaming_sdk-0.1.0.tar.gz | 9.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sarvam_transcribe_streaming_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.8 kB
Release files / sarvam_transcribe_streaming_sdk-0.1.0.tar.gz
| Download URL | sarvam_transcribe_streaming_sdk-0.1.0.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2007785fa062d04f62cf2094c2f7cb233e177f2e1754c3adbeee854597fdd79e
|
|
BLAKE2b-256 checksum How to use checksums |
a1dab1ebbbc611432dce6eab16aa2761bf57c3ee653f58d98c82a17c980b5ab6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / sarvam_transcribe_streaming_sdk-0.1.0-py3-none-any.whl
| Download URL | sarvam_transcribe_streaming_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1990aa0458f81b29dae31d9a93dca3ace581423b716df31958ed88b4639f9acf
|
|
BLAKE2b-256 checksum How to use checksums |
9eb23e094c7ea7cd841c435371825202e29e08107077df5e4af2e8fcff9dcc02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|