audixa 0.1.0__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.
audixa-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Audixa AI
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.
audixa-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,332 @@
1
+ Metadata-Version: 2.4
2
+ Name: audixa
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for Audixa AI Text-to-Speech API
5
+ Author-email: Audixa AI <support@audixa.ai>, Anurag Sharma <anurag@alactic.net>
6
+ License: MIT
7
+ Project-URL: Homepage, https://audixa.ai
8
+ Project-URL: Documentation, https://docs.audixa.ai
9
+ Project-URL: Repository, https://github.com/audixaAI/audixa-python-sdk
10
+ Project-URL: Issues, https://github.com/audixaAI/audixa-python-sdk/issues
11
+ Keywords: tts,text-to-speech,audixa,ai,voice,audio,speech-synthesis
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: requests>=2.28.0
26
+ Requires-Dist: aiohttp>=3.8.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0; extra == "dev"
29
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
30
+ Requires-Dist: black>=23.0; extra == "dev"
31
+ Requires-Dist: mypy>=1.0; extra == "dev"
32
+ Requires-Dist: ruff>=0.1; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # Audixa Python SDK
36
+
37
+ [![PyPI version](https://badge.fury.io/py/audixa.svg)](https://badge.fury.io/py/audixa)
38
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
40
+
41
+ Official Python SDK for the [Audixa AI](https://audixa.ai) Text-to-Speech API. Production-ready with both synchronous and asynchronous support.
42
+
43
+ ## Features
44
+
45
+ - ✅ **Simple API** - One-line TTS generation
46
+ - ✅ **Sync & Async** - Full support for both paradigms
47
+ - ✅ **Type Hints** - Complete type annotations (Python 3.10+)
48
+ - ✅ **Retry Logic** - Automatic retries with exponential backoff
49
+ - ✅ **Rate Limiting** - Built-in concurrency control for async
50
+ - ✅ **File Downloads** - Download audio directly to disk
51
+ - ✅ **Error Handling** - Comprehensive exception hierarchy
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install audixa
57
+ ```
58
+
59
+ For async file downloads, also install:
60
+ ```bash
61
+ pip install aiofiles
62
+ ```
63
+
64
+ ## Quick Start
65
+
66
+ ### Synchronous Usage
67
+
68
+ ```python
69
+ import audixa
70
+
71
+ # Set your API key
72
+ audixa.set_api_key("your-api-key")
73
+ # Or use environment variable: AUDIXA_API_KEY
74
+
75
+ # Generate TTS and get audio URL
76
+ audio_url = audixa.tts_and_wait("Hello, world!")
77
+ print(f"Audio URL: {audio_url}")
78
+
79
+ # Or save directly to file
80
+ audixa.tts_to_file("Hello, world!", "output.wav")
81
+ ```
82
+
83
+ ### Asynchronous Usage
84
+
85
+ ```python
86
+ import asyncio
87
+ import audixa
88
+
89
+ audixa.set_api_key("your-api-key")
90
+
91
+ async def main():
92
+ # Generate TTS asynchronously
93
+ audio_url = await audixa.atts_and_wait("Hello, world!")
94
+ print(f"Audio URL: {audio_url}")
95
+
96
+ # Save to file
97
+ await audixa.atts_to_file("Hello!", "output.wav")
98
+
99
+ asyncio.run(main())
100
+ ```
101
+
102
+ ### Low-Level API
103
+
104
+ For more control, use the client classes directly:
105
+
106
+ ```python
107
+ from audixa import AudixaClient
108
+
109
+ # Create client with custom settings
110
+ client = AudixaClient(
111
+ api_key="your-api-key",
112
+ timeout=60.0,
113
+ max_retries=5,
114
+ )
115
+
116
+ # Use as context manager
117
+ with client:
118
+ # Start generation (non-blocking)
119
+ gen_id = client.tts("Hello, world!")
120
+
121
+ # Check status manually
122
+ status = client.status(gen_id)
123
+ print(f"Status: {status['status']}")
124
+
125
+ # List available voices
126
+ voices = client.list_voices()
127
+ for voice in voices:
128
+ print(f"{voice['id']}: {voice['name']}")
129
+ ```
130
+
131
+ ### Async Client
132
+
133
+ ```python
134
+ from audixa import AsyncAudixaClient
135
+ import asyncio
136
+
137
+ async def main():
138
+ async with AsyncAudixaClient(
139
+ api_key="your-api-key",
140
+ max_concurrency=10, # Rate limit protection
141
+ ) as client:
142
+ # Concurrent generation
143
+ texts = ["Hello", "World", "How are you?"]
144
+ tasks = [client.tts_and_wait(text) for text in texts]
145
+ urls = await asyncio.gather(*tasks)
146
+ print(urls)
147
+
148
+ asyncio.run(main())
149
+ ```
150
+
151
+ ## API Reference
152
+
153
+ ### Configuration Functions
154
+
155
+ | Function | Description |
156
+ |----------|-------------|
157
+ | `set_api_key(key)` | Set the global API key |
158
+ | `set_base_url(url)` | Set the API base URL |
159
+
160
+ ### Synchronous Functions
161
+
162
+ | Function | Description |
163
+ |----------|-------------|
164
+ | `tts(text, voice_id=None)` | Start TTS generation, returns generation ID |
165
+ | `status(generation_id)` | Check generation status |
166
+ | `tts_and_wait(text, timeout=300)` | Generate and wait, returns audio URL |
167
+ | `tts_to_file(text, filepath)` | Generate and save to file |
168
+ | `list_voices()` | Get available voices |
169
+
170
+ ### Asynchronous Functions
171
+
172
+ | Function | Description |
173
+ |----------|-------------|
174
+ | `atts(text, voice_id=None)` | Async TTS generation |
175
+ | `astatus(generation_id)` | Async status check |
176
+ | `atts_and_wait(text, timeout=300)` | Async generate and wait |
177
+ | `atts_to_file(text, filepath)` | Async generate and save |
178
+ | `alist_voices()` | Async get voices |
179
+
180
+ ## Error Handling
181
+
182
+ The SDK provides a comprehensive exception hierarchy:
183
+
184
+ ```python
185
+ import audixa
186
+
187
+ try:
188
+ audio_url = audixa.tts_and_wait("Hello!")
189
+ except audixa.AuthenticationError:
190
+ print("Invalid API key")
191
+ except audixa.RateLimitError as e:
192
+ print(f"Rate limited. Retry after: {e.retry_after}s")
193
+ except audixa.TimeoutError:
194
+ print("Generation timed out")
195
+ except audixa.GenerationError as e:
196
+ print(f"Generation failed: {e.message}")
197
+ except audixa.NetworkError:
198
+ print("Network error occurred")
199
+ except audixa.AudixaError as e:
200
+ print(f"General error: {e}")
201
+ ```
202
+
203
+ ### Exception Reference
204
+
205
+ | Exception | Description |
206
+ |-----------|-------------|
207
+ | `AudixaError` | Base exception for all SDK errors |
208
+ | `AuthenticationError` | Invalid or missing API key |
209
+ | `RateLimitError` | Rate limit exceeded (429) |
210
+ | `APIError` | General API error (4xx/5xx) |
211
+ | `NetworkError` | Connection/network failure |
212
+ | `TimeoutError` | Request or generation timeout |
213
+ | `GenerationError` | TTS generation failed |
214
+ | `UnsupportedFormatError` | Invalid audio format |
215
+ | `ValidationError` | Invalid input parameters |
216
+
217
+ ## Audio Format
218
+
219
+ > **Note:** Currently, Audixa only supports **WAV** audio output. The SDK is designed for easy extensibility when new formats are added.
220
+
221
+ ```python
222
+ # Correct - WAV format
223
+ audixa.tts_to_file("Hello", "output.wav")
224
+
225
+ # Error - MP3 not yet supported
226
+ audixa.tts_to_file("Hello", "output.mp3") # Raises UnsupportedFormatError
227
+ ```
228
+
229
+ ## Logging
230
+
231
+ Enable debug logging to see SDK activity:
232
+
233
+ ```python
234
+ import logging
235
+
236
+ # Enable debug logging
237
+ logging.basicConfig(level=logging.DEBUG)
238
+
239
+ # Or configure the audixa logger specifically
240
+ logging.getLogger("audixa").setLevel(logging.DEBUG)
241
+ ```
242
+
243
+ ## Production Best Practices
244
+
245
+ ### 1. Use Environment Variables
246
+
247
+ ```bash
248
+ export AUDIXA_API_KEY="your-api-key"
249
+ ```
250
+
251
+ ```python
252
+ import audixa
253
+ # API key is automatically loaded from environment
254
+ audio_url = audixa.tts_and_wait("Hello!")
255
+ ```
256
+
257
+ ### 2. Handle Errors Gracefully
258
+
259
+ ```python
260
+ import audixa
261
+
262
+ def generate_audio(text: str) -> str | None:
263
+ try:
264
+ return audixa.tts_and_wait(text, timeout=120)
265
+ except audixa.RateLimitError:
266
+ time.sleep(60)
267
+ return generate_audio(text) # Retry
268
+ except audixa.AudixaError as e:
269
+ logging.error(f"TTS failed: {e}")
270
+ return None
271
+ ```
272
+
273
+ ### 3. Use Async for High Throughput
274
+
275
+ ```python
276
+ async def batch_generate(texts: list[str]) -> list[str]:
277
+ async with AsyncAudixaClient(max_concurrency=5) as client:
278
+ tasks = [client.tts_and_wait(text) for text in texts]
279
+ return await asyncio.gather(*tasks, return_exceptions=True)
280
+ ```
281
+
282
+ ### 4. Configure Timeouts
283
+
284
+ ```python
285
+ client = AudixaClient(
286
+ api_key="your-key",
287
+ timeout=60.0, # HTTP request timeout
288
+ max_retries=5, # Retry attempts
289
+ )
290
+
291
+ audio_url = client.tts_and_wait(
292
+ "Long text...",
293
+ timeout=300.0, # Wait timeout for generation
294
+ )
295
+ ```
296
+
297
+ ## Building from Source
298
+
299
+ ```bash
300
+ # Clone the repository
301
+ git clone https://github.com/audixa/audixa-python.git
302
+ cd audixa-python
303
+
304
+ # Install in development mode
305
+ pip install -e ".[dev]"
306
+
307
+ # Run tests
308
+ pytest
309
+
310
+ # Build package
311
+ python -m build
312
+ ```
313
+
314
+ ## Publishing to PyPI
315
+
316
+ ```bash
317
+ # Build distribution
318
+ python -m build
319
+
320
+ # Upload to PyPI
321
+ twine upload dist/*
322
+ ```
323
+
324
+ ## License
325
+
326
+ MIT License - see [LICENSE](LICENSE) file.
327
+
328
+ ## Links
329
+
330
+ - 📖 [Documentation](https://docs.audixa.ai)
331
+ - 🐛 [Issue Tracker](https://github.com/audixa/audixa-python/issues)
332
+ - 💬 [Discord](https://discord.gg/audixa)
audixa-0.1.0/README.md ADDED
@@ -0,0 +1,298 @@
1
+ # Audixa Python SDK
2
+
3
+ [![PyPI version](https://badge.fury.io/py/audixa.svg)](https://badge.fury.io/py/audixa)
4
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ Official Python SDK for the [Audixa AI](https://audixa.ai) Text-to-Speech API. Production-ready with both synchronous and asynchronous support.
8
+
9
+ ## Features
10
+
11
+ - ✅ **Simple API** - One-line TTS generation
12
+ - ✅ **Sync & Async** - Full support for both paradigms
13
+ - ✅ **Type Hints** - Complete type annotations (Python 3.10+)
14
+ - ✅ **Retry Logic** - Automatic retries with exponential backoff
15
+ - ✅ **Rate Limiting** - Built-in concurrency control for async
16
+ - ✅ **File Downloads** - Download audio directly to disk
17
+ - ✅ **Error Handling** - Comprehensive exception hierarchy
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install audixa
23
+ ```
24
+
25
+ For async file downloads, also install:
26
+ ```bash
27
+ pip install aiofiles
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ### Synchronous Usage
33
+
34
+ ```python
35
+ import audixa
36
+
37
+ # Set your API key
38
+ audixa.set_api_key("your-api-key")
39
+ # Or use environment variable: AUDIXA_API_KEY
40
+
41
+ # Generate TTS and get audio URL
42
+ audio_url = audixa.tts_and_wait("Hello, world!")
43
+ print(f"Audio URL: {audio_url}")
44
+
45
+ # Or save directly to file
46
+ audixa.tts_to_file("Hello, world!", "output.wav")
47
+ ```
48
+
49
+ ### Asynchronous Usage
50
+
51
+ ```python
52
+ import asyncio
53
+ import audixa
54
+
55
+ audixa.set_api_key("your-api-key")
56
+
57
+ async def main():
58
+ # Generate TTS asynchronously
59
+ audio_url = await audixa.atts_and_wait("Hello, world!")
60
+ print(f"Audio URL: {audio_url}")
61
+
62
+ # Save to file
63
+ await audixa.atts_to_file("Hello!", "output.wav")
64
+
65
+ asyncio.run(main())
66
+ ```
67
+
68
+ ### Low-Level API
69
+
70
+ For more control, use the client classes directly:
71
+
72
+ ```python
73
+ from audixa import AudixaClient
74
+
75
+ # Create client with custom settings
76
+ client = AudixaClient(
77
+ api_key="your-api-key",
78
+ timeout=60.0,
79
+ max_retries=5,
80
+ )
81
+
82
+ # Use as context manager
83
+ with client:
84
+ # Start generation (non-blocking)
85
+ gen_id = client.tts("Hello, world!")
86
+
87
+ # Check status manually
88
+ status = client.status(gen_id)
89
+ print(f"Status: {status['status']}")
90
+
91
+ # List available voices
92
+ voices = client.list_voices()
93
+ for voice in voices:
94
+ print(f"{voice['id']}: {voice['name']}")
95
+ ```
96
+
97
+ ### Async Client
98
+
99
+ ```python
100
+ from audixa import AsyncAudixaClient
101
+ import asyncio
102
+
103
+ async def main():
104
+ async with AsyncAudixaClient(
105
+ api_key="your-api-key",
106
+ max_concurrency=10, # Rate limit protection
107
+ ) as client:
108
+ # Concurrent generation
109
+ texts = ["Hello", "World", "How are you?"]
110
+ tasks = [client.tts_and_wait(text) for text in texts]
111
+ urls = await asyncio.gather(*tasks)
112
+ print(urls)
113
+
114
+ asyncio.run(main())
115
+ ```
116
+
117
+ ## API Reference
118
+
119
+ ### Configuration Functions
120
+
121
+ | Function | Description |
122
+ |----------|-------------|
123
+ | `set_api_key(key)` | Set the global API key |
124
+ | `set_base_url(url)` | Set the API base URL |
125
+
126
+ ### Synchronous Functions
127
+
128
+ | Function | Description |
129
+ |----------|-------------|
130
+ | `tts(text, voice_id=None)` | Start TTS generation, returns generation ID |
131
+ | `status(generation_id)` | Check generation status |
132
+ | `tts_and_wait(text, timeout=300)` | Generate and wait, returns audio URL |
133
+ | `tts_to_file(text, filepath)` | Generate and save to file |
134
+ | `list_voices()` | Get available voices |
135
+
136
+ ### Asynchronous Functions
137
+
138
+ | Function | Description |
139
+ |----------|-------------|
140
+ | `atts(text, voice_id=None)` | Async TTS generation |
141
+ | `astatus(generation_id)` | Async status check |
142
+ | `atts_and_wait(text, timeout=300)` | Async generate and wait |
143
+ | `atts_to_file(text, filepath)` | Async generate and save |
144
+ | `alist_voices()` | Async get voices |
145
+
146
+ ## Error Handling
147
+
148
+ The SDK provides a comprehensive exception hierarchy:
149
+
150
+ ```python
151
+ import audixa
152
+
153
+ try:
154
+ audio_url = audixa.tts_and_wait("Hello!")
155
+ except audixa.AuthenticationError:
156
+ print("Invalid API key")
157
+ except audixa.RateLimitError as e:
158
+ print(f"Rate limited. Retry after: {e.retry_after}s")
159
+ except audixa.TimeoutError:
160
+ print("Generation timed out")
161
+ except audixa.GenerationError as e:
162
+ print(f"Generation failed: {e.message}")
163
+ except audixa.NetworkError:
164
+ print("Network error occurred")
165
+ except audixa.AudixaError as e:
166
+ print(f"General error: {e}")
167
+ ```
168
+
169
+ ### Exception Reference
170
+
171
+ | Exception | Description |
172
+ |-----------|-------------|
173
+ | `AudixaError` | Base exception for all SDK errors |
174
+ | `AuthenticationError` | Invalid or missing API key |
175
+ | `RateLimitError` | Rate limit exceeded (429) |
176
+ | `APIError` | General API error (4xx/5xx) |
177
+ | `NetworkError` | Connection/network failure |
178
+ | `TimeoutError` | Request or generation timeout |
179
+ | `GenerationError` | TTS generation failed |
180
+ | `UnsupportedFormatError` | Invalid audio format |
181
+ | `ValidationError` | Invalid input parameters |
182
+
183
+ ## Audio Format
184
+
185
+ > **Note:** Currently, Audixa only supports **WAV** audio output. The SDK is designed for easy extensibility when new formats are added.
186
+
187
+ ```python
188
+ # Correct - WAV format
189
+ audixa.tts_to_file("Hello", "output.wav")
190
+
191
+ # Error - MP3 not yet supported
192
+ audixa.tts_to_file("Hello", "output.mp3") # Raises UnsupportedFormatError
193
+ ```
194
+
195
+ ## Logging
196
+
197
+ Enable debug logging to see SDK activity:
198
+
199
+ ```python
200
+ import logging
201
+
202
+ # Enable debug logging
203
+ logging.basicConfig(level=logging.DEBUG)
204
+
205
+ # Or configure the audixa logger specifically
206
+ logging.getLogger("audixa").setLevel(logging.DEBUG)
207
+ ```
208
+
209
+ ## Production Best Practices
210
+
211
+ ### 1. Use Environment Variables
212
+
213
+ ```bash
214
+ export AUDIXA_API_KEY="your-api-key"
215
+ ```
216
+
217
+ ```python
218
+ import audixa
219
+ # API key is automatically loaded from environment
220
+ audio_url = audixa.tts_and_wait("Hello!")
221
+ ```
222
+
223
+ ### 2. Handle Errors Gracefully
224
+
225
+ ```python
226
+ import audixa
227
+
228
+ def generate_audio(text: str) -> str | None:
229
+ try:
230
+ return audixa.tts_and_wait(text, timeout=120)
231
+ except audixa.RateLimitError:
232
+ time.sleep(60)
233
+ return generate_audio(text) # Retry
234
+ except audixa.AudixaError as e:
235
+ logging.error(f"TTS failed: {e}")
236
+ return None
237
+ ```
238
+
239
+ ### 3. Use Async for High Throughput
240
+
241
+ ```python
242
+ async def batch_generate(texts: list[str]) -> list[str]:
243
+ async with AsyncAudixaClient(max_concurrency=5) as client:
244
+ tasks = [client.tts_and_wait(text) for text in texts]
245
+ return await asyncio.gather(*tasks, return_exceptions=True)
246
+ ```
247
+
248
+ ### 4. Configure Timeouts
249
+
250
+ ```python
251
+ client = AudixaClient(
252
+ api_key="your-key",
253
+ timeout=60.0, # HTTP request timeout
254
+ max_retries=5, # Retry attempts
255
+ )
256
+
257
+ audio_url = client.tts_and_wait(
258
+ "Long text...",
259
+ timeout=300.0, # Wait timeout for generation
260
+ )
261
+ ```
262
+
263
+ ## Building from Source
264
+
265
+ ```bash
266
+ # Clone the repository
267
+ git clone https://github.com/audixa/audixa-python.git
268
+ cd audixa-python
269
+
270
+ # Install in development mode
271
+ pip install -e ".[dev]"
272
+
273
+ # Run tests
274
+ pytest
275
+
276
+ # Build package
277
+ python -m build
278
+ ```
279
+
280
+ ## Publishing to PyPI
281
+
282
+ ```bash
283
+ # Build distribution
284
+ python -m build
285
+
286
+ # Upload to PyPI
287
+ twine upload dist/*
288
+ ```
289
+
290
+ ## License
291
+
292
+ MIT License - see [LICENSE](LICENSE) file.
293
+
294
+ ## Links
295
+
296
+ - 📖 [Documentation](https://docs.audixa.ai)
297
+ - 🐛 [Issue Tracker](https://github.com/audixa/audixa-python/issues)
298
+ - 💬 [Discord](https://discord.gg/audixa)