Production-ready Python SDK for Bhashini inference services.
Project description
bhashini-client
bhashini-client is a Python SDK for working with Bhashini inference APIs. The package wraps common pipeline calls behind simple service classes and a unified BhashiniClient, with direct service IDs embedded in each service as requested.
Overview
The SDK currently supports:
- ASR (Automatic Speech Recognition)
- NMT (Neural Machine Translation)
- TTS (Text-to-Speech)
- Transliteration
- Text Language Detection
- OCR
- NER
Each service includes:
- input preprocessing and validation
- hardcoded
serviceIdinside the service implementation - safe postprocessing for clean outputs
- graceful fallback to
"Invalid input"and"API Error"
Installation
pip install .
Usage
from bhashini_client import BhashiniClient
client = BhashiniClient(api_key="your-api-key")
print(client.asr("https://example.com/audio.wav", "hi"))
print(client.nmt("Hello world", "en", "hi"))
print(client.tts("नमस्ते दुनिया", "hi"))
print(client.transliterate("namaste", "en", "hi"))
print(client.detect_language("नमस्ते दुनिया"))
print(client.ocr("https://example.com/page.png", "hi"))
print(client.ner("OpenAI is in Delhi", "en"))
Services
ASR
Transcribes speech from a remote audio URL.
NMT
Translates text from one language to another.
TTS
Generates speech output and returns a usable audio location or content.
Transliteration
Returns transliterated text with suggestions.
Language Detection
Returns the most likely language code and score.
OCR
Extracts text from printed, scene, or handwritten image URLs.
NER
Extracts named entities as a list of {text, label} dictionaries.
Testing Approach
Tests are written with pytest and cover:
- normal cases
- empty input
- whitespace input
- numeric input
- mixed input
- invalid input type
- API failure fallback
Every test prints Test ID, Input, and Output. A test_results.xlsx workbook is generated automatically at the project root after test execution to help track expected versus actual behavior.
Run tests with:
pytest
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 bhashini_client-0.2.0.tar.gz.
File metadata
- Download URL: bhashini_client-0.2.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c53fea663c013bc8ff3bebb1d7289d7a739672c3e481d2c27541c460ebc1020
|
|
| MD5 |
cb652059abe1ec8c2e30bf3b5e84eeb6
|
|
| BLAKE2b-256 |
303e7a45a0e7481e6e8d42a602de8ec5806ce84f41280aefd00280046e2e043e
|
File details
Details for the file bhashini_client-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bhashini_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
178b1d9a5ce53847186b5653fd57e2d5bd1b10380c1ec30f797056d9866eb14b
|
|
| MD5 |
cbaef59a9bb1b91d3cec5fd0b705b6b8
|
|
| BLAKE2b-256 |
c665ec1092783c8844fde3ea210fd65be21baaba9598209113dd97b4cd40606b
|