Python SDK for Sarvam Streaming Speech-to-Text
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sarvam_transcribe_streaming_sdk-0.1.0.tar.gz.
File metadata
- Download URL: sarvam_transcribe_streaming_sdk-0.1.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2007785fa062d04f62cf2094c2f7cb233e177f2e1754c3adbeee854597fdd79e
|
|
| MD5 |
a98b520ff7474a4288ab8206258fccbb
|
|
| BLAKE2b-256 |
a1dab1ebbbc611432dce6eab16aa2761bf57c3ee653f58d98c82a17c980b5ab6
|
File details
Details for the file sarvam_transcribe_streaming_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sarvam_transcribe_streaming_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1990aa0458f81b29dae31d9a93dca3ace581423b716df31958ed88b4639f9acf
|
|
| MD5 |
70858cc1a1e64efa99964b90732e17c9
|
|
| BLAKE2b-256 |
9eb23e094c7ea7cd841c435371825202e29e08107077df5e4af2e8fcff9dcc02
|