convozen 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
convozen-0.3.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Convozen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ recursive-exclude tests *
2
+ exclude *.ipynb
3
+ recursive-exclude dist *
4
+ recursive-exclude build *
5
+ recursive-exclude *.egg-info *
6
+ global-exclude __pycache__ *.py[cod]
@@ -0,0 +1,206 @@
1
+ Metadata-Version: 2.4
2
+ Name: convozen
3
+ Version: 0.3.1
4
+ Summary: Python SDK for ConvoZen TTS and STT services
5
+ Author: Convozen
6
+ License-Expression: MIT
7
+ Keywords: tts,stt,speech,voice,convozen
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: requests<3.0,>=2.28.0
21
+ Provides-Extra: async
22
+ Requires-Dist: httpx<1.0,>=0.24.0; extra == "async"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest; extra == "dev"
25
+ Requires-Dist: responses; extra == "dev"
26
+ Requires-Dist: pytest-asyncio; extra == "dev"
27
+ Requires-Dist: anyio[trio]; extra == "dev"
28
+ Requires-Dist: respx; extra == "dev"
29
+ Requires-Dist: httpx<1.0,>=0.24.0; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # ConvoZen Voice SDK
33
+
34
+ Text-to-Speech (TTS) and Speech-to-Text (STT) for Python.
35
+
36
+ > One API key for both TTS and STT.
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ pip install convozen
42
+ ```
43
+
44
+ Requires Python 3.9+
45
+
46
+ ---
47
+
48
+ ## TTS — Convert Text to Speech
49
+
50
+ Copy and run:
51
+
52
+ ```python
53
+ import convozen
54
+
55
+ client = convozen.Client(api_key="your-api-key")
56
+
57
+ audio = client.tts.synthesize("नमस्ते… मुझे आपके सर्विस के बारे में थोड़ी जानकारी चाहिए।", language="hi")
58
+
59
+ with open("output.wav", "wb") as f:
60
+ f.write(audio)
61
+ ```
62
+
63
+ With options:
64
+
65
+ ```python
66
+ import convozen
67
+
68
+ client = convozen.Client(api_key="your-api-key")
69
+
70
+ audio = client.tts.synthesize(
71
+ text="Welcome to Playground.",
72
+ language="en", # default: "en"
73
+ voice="roohi", # default: "roohi"
74
+ model="ragini-v1", # default: "ragini-v1"
75
+ speed=1.2, # default: 1.0
76
+ )
77
+
78
+ with open("output.wav", "wb") as f:
79
+ f.write(audio)
80
+ ```
81
+
82
+ ### Parameters
83
+
84
+ | Parameter | Type | Default | Description |
85
+ |-----------|------|---------|-------------|
86
+ | `text` | `str` | *required* | Text to convert to speech |
87
+ | `language` | `str` | `"en"` | Language code (see supported languages below) |
88
+ | `voice` | `str` | `"roohi"` | Voice ID for synthesis (see available voices below) |
89
+ | `model` | `str` | `"ragini-v1"` | TTS model to use. Currently only `ragini-v1` is available |
90
+ | `speed` | `float` | `1.0` | Speech speed. `0.5` = half speed, `2.0` = double speed |
91
+ | `stream` | `bool` | `False` | If `True`, returns audio chunks as they are generated |
92
+ | `format` | `str` | `"wav"` | Audio output format. Currently only `wav` is supported |
93
+
94
+ ### Streaming
95
+
96
+ ```python
97
+ import convozen
98
+
99
+ client = convozen.Client(api_key="your-api-key")
100
+
101
+ for chunk in client.tts.synthesize("Long text here...", language="en", stream=True):
102
+ audio_player.write(chunk)
103
+ ```
104
+
105
+ ### Available Voices
106
+
107
+ | Voice | ID | Default |
108
+ |-------|----|---------|
109
+ | Roohi | `roohi` | Yes |
110
+ | Amaya | `amaya` | |
111
+ | Kiyansh | `kiyansh` | |
112
+ | Neeraj | `neeraj` | |
113
+ | Manya | `manya` | |
114
+ | Nidhi | `nidhi` | |
115
+ | Ira | `ira` | |
116
+ | Trisha | `trisha` | |
117
+ | Charvi | `charvi` | |
118
+
119
+ ```python
120
+ audio = client.tts.synthesize("Hello", language="en", voice="roohi")
121
+ ```
122
+
123
+ ---
124
+
125
+ ## STT — Convert Speech to Text
126
+
127
+ Copy and run:
128
+
129
+ ```python
130
+ import convozen
131
+
132
+ client = convozen.Client(api_key="your-api-key")
133
+
134
+ text = client.stt.transcribe("recording.wav")
135
+ print(text)
136
+ ```
137
+
138
+ ### Parameters
139
+
140
+ | Parameter | Type | Default | Description |
141
+ |-----------|------|---------|-------------|
142
+ | `audio` | `str` | *required* | Path to the audio file (WAV format) |
143
+ | `model` | `str` | `"akshara-v1"` | STT model to use. Currently only `akshara-v1` is available |
144
+
145
+ ---
146
+
147
+ ## Supported Languages
148
+
149
+ | Code | Language | TTS | STT |
150
+ |------|----------|:---:|:---:|
151
+ | `en` | English | Yes | Yes |
152
+ | `hi` | Hindi | Yes | Yes |
153
+ | `ta` | Tamil | Yes | Yes |
154
+ | `te` | Telugu | Yes | Yes |
155
+ | `kn` | Kannada | Yes | Yes |
156
+ | `mr` | Marathi | — | Yes |
157
+ | `bn` | Bengali | — | Yes |
158
+ | `gu` | Gujarati | — | Yes |
159
+ | `ml` | Malayalam | — | Yes |
160
+
161
+ ---
162
+
163
+ ## Check Credits
164
+
165
+ ```python
166
+ import convozen
167
+
168
+ client = convozen.Client(api_key="your-api-key")
169
+ info = client.account.info()
170
+ print(info.credits.tts.balance)
171
+ print(info.credits.stt.balance)
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Error Handling
177
+
178
+ ```python
179
+ import convozen
180
+ from convozen import AuthenticationError, RateLimitError, APIError
181
+
182
+ client = convozen.Client(api_key="your-api-key")
183
+
184
+ try:
185
+ audio = client.tts.synthesize("Hello")
186
+ except AuthenticationError:
187
+ print("Invalid API key")
188
+ except RateLimitError:
189
+ print("Too many requests")
190
+ except APIError as e:
191
+ print(f"Server error: {e}")
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Standalone Clients
197
+
198
+ ```python
199
+ from convozen import TTS, STT
200
+
201
+ tts = TTS(api_key="your-api-key")
202
+ audio = tts.synthesize("Hello", language="hi")
203
+
204
+ stt = STT(api_key="your-api-key")
205
+ text = stt.transcribe("audio.wav")
206
+ ```
@@ -0,0 +1,175 @@
1
+ # ConvoZen Voice SDK
2
+
3
+ Text-to-Speech (TTS) and Speech-to-Text (STT) for Python.
4
+
5
+ > One API key for both TTS and STT.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install convozen
11
+ ```
12
+
13
+ Requires Python 3.9+
14
+
15
+ ---
16
+
17
+ ## TTS — Convert Text to Speech
18
+
19
+ Copy and run:
20
+
21
+ ```python
22
+ import convozen
23
+
24
+ client = convozen.Client(api_key="your-api-key")
25
+
26
+ audio = client.tts.synthesize("नमस्ते… मुझे आपके सर्विस के बारे में थोड़ी जानकारी चाहिए।", language="hi")
27
+
28
+ with open("output.wav", "wb") as f:
29
+ f.write(audio)
30
+ ```
31
+
32
+ With options:
33
+
34
+ ```python
35
+ import convozen
36
+
37
+ client = convozen.Client(api_key="your-api-key")
38
+
39
+ audio = client.tts.synthesize(
40
+ text="Welcome to Playground.",
41
+ language="en", # default: "en"
42
+ voice="roohi", # default: "roohi"
43
+ model="ragini-v1", # default: "ragini-v1"
44
+ speed=1.2, # default: 1.0
45
+ )
46
+
47
+ with open("output.wav", "wb") as f:
48
+ f.write(audio)
49
+ ```
50
+
51
+ ### Parameters
52
+
53
+ | Parameter | Type | Default | Description |
54
+ |-----------|------|---------|-------------|
55
+ | `text` | `str` | *required* | Text to convert to speech |
56
+ | `language` | `str` | `"en"` | Language code (see supported languages below) |
57
+ | `voice` | `str` | `"roohi"` | Voice ID for synthesis (see available voices below) |
58
+ | `model` | `str` | `"ragini-v1"` | TTS model to use. Currently only `ragini-v1` is available |
59
+ | `speed` | `float` | `1.0` | Speech speed. `0.5` = half speed, `2.0` = double speed |
60
+ | `stream` | `bool` | `False` | If `True`, returns audio chunks as they are generated |
61
+ | `format` | `str` | `"wav"` | Audio output format. Currently only `wav` is supported |
62
+
63
+ ### Streaming
64
+
65
+ ```python
66
+ import convozen
67
+
68
+ client = convozen.Client(api_key="your-api-key")
69
+
70
+ for chunk in client.tts.synthesize("Long text here...", language="en", stream=True):
71
+ audio_player.write(chunk)
72
+ ```
73
+
74
+ ### Available Voices
75
+
76
+ | Voice | ID | Default |
77
+ |-------|----|---------|
78
+ | Roohi | `roohi` | Yes |
79
+ | Amaya | `amaya` | |
80
+ | Kiyansh | `kiyansh` | |
81
+ | Neeraj | `neeraj` | |
82
+ | Manya | `manya` | |
83
+ | Nidhi | `nidhi` | |
84
+ | Ira | `ira` | |
85
+ | Trisha | `trisha` | |
86
+ | Charvi | `charvi` | |
87
+
88
+ ```python
89
+ audio = client.tts.synthesize("Hello", language="en", voice="roohi")
90
+ ```
91
+
92
+ ---
93
+
94
+ ## STT — Convert Speech to Text
95
+
96
+ Copy and run:
97
+
98
+ ```python
99
+ import convozen
100
+
101
+ client = convozen.Client(api_key="your-api-key")
102
+
103
+ text = client.stt.transcribe("recording.wav")
104
+ print(text)
105
+ ```
106
+
107
+ ### Parameters
108
+
109
+ | Parameter | Type | Default | Description |
110
+ |-----------|------|---------|-------------|
111
+ | `audio` | `str` | *required* | Path to the audio file (WAV format) |
112
+ | `model` | `str` | `"akshara-v1"` | STT model to use. Currently only `akshara-v1` is available |
113
+
114
+ ---
115
+
116
+ ## Supported Languages
117
+
118
+ | Code | Language | TTS | STT |
119
+ |------|----------|:---:|:---:|
120
+ | `en` | English | Yes | Yes |
121
+ | `hi` | Hindi | Yes | Yes |
122
+ | `ta` | Tamil | Yes | Yes |
123
+ | `te` | Telugu | Yes | Yes |
124
+ | `kn` | Kannada | Yes | Yes |
125
+ | `mr` | Marathi | — | Yes |
126
+ | `bn` | Bengali | — | Yes |
127
+ | `gu` | Gujarati | — | Yes |
128
+ | `ml` | Malayalam | — | Yes |
129
+
130
+ ---
131
+
132
+ ## Check Credits
133
+
134
+ ```python
135
+ import convozen
136
+
137
+ client = convozen.Client(api_key="your-api-key")
138
+ info = client.account.info()
139
+ print(info.credits.tts.balance)
140
+ print(info.credits.stt.balance)
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Error Handling
146
+
147
+ ```python
148
+ import convozen
149
+ from convozen import AuthenticationError, RateLimitError, APIError
150
+
151
+ client = convozen.Client(api_key="your-api-key")
152
+
153
+ try:
154
+ audio = client.tts.synthesize("Hello")
155
+ except AuthenticationError:
156
+ print("Invalid API key")
157
+ except RateLimitError:
158
+ print("Too many requests")
159
+ except APIError as e:
160
+ print(f"Server error: {e}")
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Standalone Clients
166
+
167
+ ```python
168
+ from convozen import TTS, STT
169
+
170
+ tts = TTS(api_key="your-api-key")
171
+ audio = tts.synthesize("Hello", language="hi")
172
+
173
+ stt = STT(api_key="your-api-key")
174
+ text = stt.transcribe("audio.wav")
175
+ ```
@@ -0,0 +1,45 @@
1
+ __version__ = "0.3.1"
2
+
3
+ from .client import Client, STT, TTS
4
+
5
+ from convozen._internal.exceptions import (
6
+ ConvozenError,
7
+ AuthenticationError,
8
+ RateLimitError,
9
+ APIError,
10
+ )
11
+ from convozen._internal.enums import Language, AudioFormat, VoiceId
12
+ from convozen._internal.types import (
13
+ TTSResponse,
14
+ STTResponse,
15
+ CreditBalance,
16
+ Credits,
17
+ AccountInfo,
18
+ RateLimitInfo,
19
+ UsageSummary,
20
+ UsageByDay,
21
+ )
22
+
23
+ __all__ = [
24
+ "Client",
25
+ "STT",
26
+ "TTS",
27
+ # Enums
28
+ "Language",
29
+ "AudioFormat",
30
+ "VoiceId",
31
+ # Types
32
+ "TTSResponse",
33
+ "STTResponse",
34
+ "CreditBalance",
35
+ "Credits",
36
+ "AccountInfo",
37
+ "RateLimitInfo",
38
+ "UsageSummary",
39
+ "UsageByDay",
40
+ # Errors
41
+ "ConvozenError",
42
+ "AuthenticationError",
43
+ "RateLimitError",
44
+ "APIError",
45
+ ]
File without changes
@@ -0,0 +1,115 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import List
4
+
5
+ from .config import Config
6
+ from .transport.http import HTTPClient
7
+ from .transport.async_http import AsyncHTTPClient
8
+ from .types import AccountInfo, CreditBalance, Credits, RateLimitInfo, UsageSummary, UsageByDay
9
+
10
+
11
+ class AccountClient:
12
+ """
13
+ HTTP client for account- and usage-related endpoints.
14
+
15
+ Expects the API gateway to expose:
16
+ - GET /v1/account
17
+ - GET /v1/usage?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
18
+ """
19
+
20
+ def __init__(self, config: Config) -> None:
21
+ self._config = config
22
+ self._http = HTTPClient(config)
23
+ self._async_http = AsyncHTTPClient(config)
24
+
25
+ # ---- Synchronous API -------------------------------------------------
26
+
27
+ def info(self) -> AccountInfo:
28
+ response = self._http.get("/v1/account")
29
+ payload = response.json()
30
+
31
+ creds = payload.get("credits") or {}
32
+ tts_creds = creds.get("tts") or {}
33
+ stt_creds = creds.get("stt") or {}
34
+ credits = Credits(
35
+ tts=CreditBalance(balance=tts_creds.get("balance", 0)),
36
+ stt=CreditBalance(balance=stt_creds.get("balance", 0)),
37
+ )
38
+
39
+ rate = payload.get("rate_limit") or {}
40
+ rate_limit = RateLimitInfo(
41
+ requests_per_minute=rate.get("requests_per_minute", 0),
42
+ requests_per_day=rate.get("requests_per_day", 0),
43
+ )
44
+
45
+ return AccountInfo(
46
+ account_id=payload.get("account_id", ""),
47
+ plan=payload.get("plan", ""),
48
+ credits=credits,
49
+ rate_limit=rate_limit,
50
+ )
51
+
52
+ def usage(self, start_date: str, end_date: str) -> UsageSummary:
53
+ response = self._http.get(
54
+ "/v1/usage",
55
+ params={"start_date": start_date, "end_date": end_date},
56
+ )
57
+ payload = response.json()
58
+
59
+ by_day_payload = payload.get("by_day") or []
60
+ by_day: List[UsageByDay] = [
61
+ UsageByDay(date=item.get("date", ""), credits=item.get("credits", 0))
62
+ for item in by_day_payload
63
+ ]
64
+
65
+ return UsageSummary(
66
+ total_credits_used=payload.get("total_credits_used", 0),
67
+ by_model=payload.get("by_model", {}),
68
+ by_day=by_day,
69
+ )
70
+
71
+ # ---- Async API -------------------------------------------------------
72
+
73
+ async def ainfo(self) -> AccountInfo:
74
+ response = await self._async_http.get("/v1/account")
75
+ payload = response.json()
76
+
77
+ creds = payload.get("credits") or {}
78
+ tts_creds = creds.get("tts") or {}
79
+ stt_creds = creds.get("stt") or {}
80
+ credits = Credits(
81
+ tts=CreditBalance(balance=tts_creds.get("balance", 0)),
82
+ stt=CreditBalance(balance=stt_creds.get("balance", 0)),
83
+ )
84
+
85
+ rate = payload.get("rate_limit") or {}
86
+ rate_limit = RateLimitInfo(
87
+ requests_per_minute=rate.get("requests_per_minute", 0),
88
+ requests_per_day=rate.get("requests_per_day", 0),
89
+ )
90
+
91
+ return AccountInfo(
92
+ account_id=payload.get("account_id", ""),
93
+ plan=payload.get("plan", ""),
94
+ credits=credits,
95
+ rate_limit=rate_limit,
96
+ )
97
+
98
+ async def ausage(self, start_date: str, end_date: str) -> UsageSummary:
99
+ response = await self._async_http.get(
100
+ "/v1/usage",
101
+ params={"start_date": start_date, "end_date": end_date},
102
+ )
103
+ payload = response.json()
104
+
105
+ by_day_payload = payload.get("by_day") or []
106
+ by_day: List[UsageByDay] = [
107
+ UsageByDay(date=item.get("date", ""), credits=item.get("credits", 0))
108
+ for item in by_day_payload
109
+ ]
110
+
111
+ return UsageSummary(
112
+ total_credits_used=payload.get("total_credits_used", 0),
113
+ by_model=payload.get("by_model", {}),
114
+ by_day=by_day,
115
+ )
@@ -0,0 +1 @@
1
+ from .client import STT
@@ -0,0 +1,52 @@
1
+ import logging
2
+
3
+ from ..transport.http import HTTPClient
4
+ from ..transport.async_http import AsyncHTTPClient
5
+ from ..config import Config
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+
10
+ class STT:
11
+
12
+ def __init__(self, config: Config) -> None:
13
+ self.http = HTTPClient(config)
14
+ self.async_http = AsyncHTTPClient(config)
15
+
16
+ def transcribe(
17
+ self,
18
+ audio: str,
19
+ model: str = "akshara-v1",
20
+ ) -> str:
21
+ logger.debug("STT request: audio=%s model=%s", audio, model)
22
+
23
+ with open(audio, "rb") as f:
24
+ response = self.http.post(
25
+ "/v1/akshara/transcribe",
26
+ files={"file": f},
27
+ data={"model": model},
28
+ )
29
+
30
+ text: str = response.json()["text"]
31
+ logger.debug("STT response: text_length=%d", len(text))
32
+ return text
33
+
34
+ async def atranscribe(
35
+ self,
36
+ audio: str,
37
+ model: str = "akshara-v1",
38
+ ) -> str:
39
+ logger.debug("async STT request: audio=%s model=%s", audio, model)
40
+
41
+ with open(audio, "rb") as f:
42
+ audio_bytes = f.read()
43
+
44
+ response = await self.async_http.post(
45
+ "/v1/akshara/transcribe",
46
+ files={"file": ("audio", audio_bytes)},
47
+ data={"model": model},
48
+ )
49
+
50
+ text: str = response.json()["text"]
51
+ logger.debug("async STT response: text_length=%d", len(text))
52
+ return text
@@ -0,0 +1,36 @@
1
+ import os
2
+ from dataclasses import dataclass, field
3
+ from urllib.parse import urlparse
4
+
5
+
6
+ @dataclass
7
+ class Config:
8
+ api_key: str = field(default_factory=lambda: os.environ.get("CONVOZEN_API_KEY", ""))
9
+ base_url: str = field(
10
+ default_factory=lambda: os.environ.get("CONVOZEN_BASE_URL", "https://voice.convozen.ai/sdk-models/developer-api/api")
11
+ )
12
+ timeout: int = 60
13
+
14
+ def __post_init__(self) -> None:
15
+ if not self.api_key:
16
+ raise ValueError(
17
+ "api_key is required. Pass it explicitly or set the "
18
+ "CONVOZEN_API_KEY environment variable."
19
+ )
20
+ if not self.base_url:
21
+ raise ValueError(
22
+ "base_url is required. Pass it explicitly or set the "
23
+ "CONVOZEN_BASE_URL environment variable."
24
+ )
25
+
26
+ parsed = urlparse(self.base_url)
27
+ if parsed.scheme not in ("http", "https"):
28
+ raise ValueError(
29
+ f"base_url must start with http:// or https://, got: {self.base_url}"
30
+ )
31
+
32
+ if self.timeout <= 0:
33
+ raise ValueError(f"timeout must be positive, got: {self.timeout}")
34
+
35
+ # Strip trailing slash for consistent URL joining
36
+ self.base_url = self.base_url.rstrip("/")