Metadata-Version: 2.5
Name: tapra
Version: 0.1.1
Summary: Official Python SDK for the Tapra API: Tunisian code-switching transcription, speech, translation, and script conversion.
License: Proprietary
Requires-Python: >=3.10
Requires-Dist: httpx>=0.21.2
Requires-Dist: pydantic>=1.9.2
Requires-Dist: typing-extensions>=4.0.0
Provides-Extra: aiohttp
Requires-Dist: aiohttp<4,>=3.10.0; extra == 'aiohttp'
Requires-Dist: httpx-aiohttp>=0.1.8; extra == 'aiohttp'
Provides-Extra: realtime
Requires-Dist: websockets>=13; extra == 'realtime'
Description-Content-Type: text/markdown

# Tapra Python SDK

Official Python client for the Tapra API: Tunisian Arabic / French / English code-switching
transcription, speech, translation, and Arabizi ↔ Arabic conversion.

```bash
pip install "tapra[realtime]"   # drop [realtime] if you only use the REST endpoints
```

```python
from tapra import Tapra

client = Tapra(base_url="https://api.example.com")  # api_key defaults to TAPRA_API_KEY

with open("meeting.m4a", "rb") as audio:
    transcript = client.transcriptions.create(file=audio, timestamps="word")
print(transcript.text)

client.script.convert(text="3lech 7abit l9anoun?", direction="ZI2AR")
for event in client.translations.create_stream(input="عندي برشا خدمة", target="French"):
    print(event.type, event.delta)
```

Async: `AsyncTapra` has the same methods. Errors raise typed exceptions
(`PaymentRequiredError` for HTTP 402, `UnauthorizedError`, …) whose `.body.error` holds
`type` and `message`. Pass `idempotency_key=` to retry metered requests safely, and use
`client.<resource>.with_raw_response.<method>()` to read `x-tapra-cost-tnd`.

## Realtime transcription

```python
from tapra import connect_realtime

async with connect_realtime(base_url="https://api.example.com", language="ar-AR") as session:
    for chunk in pcm_chunks:            # mono pcm_s16le, 16 kHz
        await session.send_audio(chunk)
    final = await session.stop()
print(final.text, final.usage)
```

## Development

`src/tapra/` is generated by Fern from `openapi/tapra-api.json`; do not edit it by hand.
`src/tapra/realtime.py` is hand-written (kept by `.fernignore`). Tests: `sdks/tests/python`.
