Metadata-Version: 2.4
Name: bhashini-client
Version: 0.2.0
Summary: Production-ready Python SDK for Bhashini inference services.
Home-page: https://github.com/bhashini-dibd/Bhashini-client-python-library.git
Author: Sai
Author-email: digitalindiabhashinidivision@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: openpyxl>=3.1.0; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-python
Dynamic: summary

# 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 `serviceId` inside the service implementation
- safe postprocessing for clean outputs
- graceful fallback to `"Invalid input"` and `"API Error"`

## Installation

```bash
pip install .
```

## Usage

```python
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:

```bash
pytest
```
