Metadata-Version: 2.1
Name: convozen
Version: 0.3.3
Summary: Python SDK for ConvoZen TTS and STT services
Author: Convozen
Keywords: tts,stt,speech,voice,convozen
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests <3.0,>=2.28.0
Provides-Extra: async
Requires-Dist: httpx <1.0,>=0.24.0 ; extra == 'async'
Requires-Dist: httpcore[asyncio] ; extra == 'async'
Provides-Extra: dev
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: responses ; extra == 'dev'
Requires-Dist: pytest-asyncio ; extra == 'dev'
Requires-Dist: anyio[trio] ; extra == 'dev'
Requires-Dist: respx ; extra == 'dev'
Requires-Dist: httpx <1.0,>=0.24.0 ; extra == 'dev'

# ConvoZen Voice SDK

Text-to-Speech (TTS) and Speech-to-Text (STT) for Python.

> One API key for both TTS and STT.

## Install

```bash
pip install convozen
```

Requires Python 3.9+

---

## TTS — Convert Text to Speech

Copy and run:

```python
import convozen

client = convozen.Client(api_key="your-api-key")

audio = client.tts.synthesize("नमस्ते… मुझे आपके सर्विस के बारे में थोड़ी जानकारी चाहिए।", language="hi")

with open("output.wav", "wb") as f:
    f.write(audio)
```

With options:

```python
import convozen

client = convozen.Client(api_key="your-api-key")

audio = client.tts.synthesize(
    text="Welcome to Playground.",
    language="en",          # default: "en"
    voice="roohi",          # default: "roohi"
    model="ragini-v1",      # default: "ragini-v1"
    speed=1.2,              # default: 1.0
)

with open("output.wav", "wb") as f:
    f.write(audio)
```

### Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `text` | `str` | *required* | Text to convert to speech |
| `language` | `str` | `"en"` | Language code (see supported languages below) |
| `voice` | `str` | `"roohi"` | Voice ID for synthesis (see available voices below) |
| `model` | `str` | `"ragini-v1"` | TTS model to use. Currently only `ragini-v1` is available |
| `speed` | `float` | `1.0` | Speech speed. `0.5` = half speed, `2.0` = double speed |
| `stream` | `bool` | `False` | If `True`, returns audio chunks as they are generated |
| `format` | `str` | `"wav"` | Audio output format. Currently only `wav` is supported |

### Streaming

```python
import convozen

client = convozen.Client(api_key="your-api-key")

for chunk in client.tts.synthesize("Long text here...", language="en", stream=True):
    audio_player.write(chunk)
```

### Available Voices

| Voice | ID | Default |
|-------|----|---------|
| Roohi | `roohi` | Yes |
| Amaya | `amaya` | |
| Kiyansh | `kiyansh` | |
| Neeraj | `neeraj` | |
| Manya | `manya` | |
| Nidhi | `nidhi` | |
| Ira | `ira` | |
| Trisha | `trisha` | |
| Charvi | `charvi` | |

```python
audio = client.tts.synthesize("Hello", language="en", voice="roohi")
```

---

## STT — Convert Speech to Text

Copy and run:

```python
import convozen

client = convozen.Client(api_key="your-api-key")

result = client.stt.transcribe("recording.wav")
print(result.text)    # "hello how can I help you"
print(result.score)   # -2.45 (confidence — closer to 0 is better)
```

### Specify Languages

If you know which languages are spoken in the audio, pass them in `lang_tags`. This improves accuracy — especially for multilingual audio like Hindi + English call recordings:

```python
result = client.stt.transcribe(
    "recording.wav",
    lang_tags=["hi", "en"],
)
print(result.text)  # "हां मुझे appointment reschedule करना है"
```

### Keyword Boosting

Have domain-specific words that the model keeps getting wrong? Pass them in `keywords` and the model will try harder to recognize them:

```python
# Without keyword boosting: "can you tell me about conversion"
# With keyword boosting:    "can you tell me about convozen"

result = client.stt.transcribe(
    "recording.wav",
    keywords=["convozen", "akshara"],
)
```

### Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `audio` | `str` | *required* | Path to the audio file |
| `lang_tags` | `list[str]` | `None` | Languages in the audio (`"en"`, `"hi"`, `"te"`, etc.) |
| `keywords` | `list[str]` | `None` | Words the model should try harder to recognize |

---

## Supported Languages

| Code | Language | TTS | STT |
|------|----------|:---:|:---:|
| `en` | English | Yes | Yes |
| `hi` | Hindi | Yes | Yes |
| `ta` | Tamil | Yes | Yes |
| `te` | Telugu | Yes | Yes |
| `kn` | Kannada | Yes | Yes |
| `mr` | Marathi | — | Yes |
| `bn` | Bengali | — | Yes |
| `gu` | Gujarati | — | Yes |
| `ml` | Malayalam | — | Yes |

---

## Check Credits

```python
import convozen

client = convozen.Client(api_key="your-api-key")
info = client.account.info()
print(info.credits.tts.balance)
print(info.credits.stt.balance)
```

---

## Error Handling

```python
import convozen
from convozen import AuthenticationError, RateLimitError, APIError

client = convozen.Client(api_key="your-api-key")

try:
    audio = client.tts.synthesize("Hello")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Too many requests")
except APIError as e:
    print(f"Server error: {e}")
```

---

## Standalone Clients

```python
from convozen import TTS, STT

tts = TTS(api_key="your-api-key")
audio = tts.synthesize("Hello", language="hi")

stt = STT(api_key="your-api-key")
result = stt.transcribe("audio.wav")
print(result.text)
```
