fonadalabs 1.0.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.
- fonadalabs-1.0.0/LICENSE +22 -0
- fonadalabs-1.0.0/MANIFEST.in +25 -0
- fonadalabs-1.0.0/PKG-INFO +598 -0
- fonadalabs-1.0.0/README.md +541 -0
- fonadalabs-1.0.0/fonadalabs/__init__.py +100 -0
- fonadalabs-1.0.0/fonadalabs/asr/__init__.py +42 -0
- fonadalabs-1.0.0/fonadalabs/asr/client.py +401 -0
- fonadalabs-1.0.0/fonadalabs/asr/concurrency.py +57 -0
- fonadalabs-1.0.0/fonadalabs/asr/config.py +46 -0
- fonadalabs-1.0.0/fonadalabs/asr/exceptions.py +54 -0
- fonadalabs-1.0.0/fonadalabs/asr/languages.py +88 -0
- fonadalabs-1.0.0/fonadalabs/asr/models/__init__.py +4 -0
- fonadalabs-1.0.0/fonadalabs/asr/models/types.py +24 -0
- fonadalabs-1.0.0/fonadalabs/asr/utils.py +83 -0
- fonadalabs-1.0.0/fonadalabs/asr/ws_client.py +118 -0
- fonadalabs-1.0.0/fonadalabs/denoise/__init__.py +15 -0
- fonadalabs-1.0.0/fonadalabs/denoise/exceptions.py +41 -0
- fonadalabs-1.0.0/fonadalabs/denoise/http_client.py +290 -0
- fonadalabs-1.0.0/fonadalabs/denoise/streaming_client.py +466 -0
- fonadalabs-1.0.0/fonadalabs/tts/__init__.py +9 -0
- fonadalabs-1.0.0/fonadalabs/tts/client.py +649 -0
- fonadalabs-1.0.0/fonadalabs.egg-info/PKG-INFO +598 -0
- fonadalabs-1.0.0/fonadalabs.egg-info/SOURCES.txt +27 -0
- fonadalabs-1.0.0/fonadalabs.egg-info/dependency_links.txt +1 -0
- fonadalabs-1.0.0/fonadalabs.egg-info/requires.txt +28 -0
- fonadalabs-1.0.0/fonadalabs.egg-info/top_level.txt +1 -0
- fonadalabs-1.0.0/pyproject.toml +96 -0
- fonadalabs-1.0.0/setup.cfg +4 -0
- fonadalabs-1.0.0/setup.py +65 -0
fonadalabs-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 FonadaLabs
|
|
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.
|
|
22
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Include the license and readme
|
|
2
|
+
include LICENSE
|
|
3
|
+
include README.md
|
|
4
|
+
|
|
5
|
+
# Include all Python files
|
|
6
|
+
recursive-include fonadalabs *.py
|
|
7
|
+
recursive-include fonadalabs *.pyi
|
|
8
|
+
|
|
9
|
+
# Exclude unnecessary files
|
|
10
|
+
global-exclude __pycache__
|
|
11
|
+
global-exclude *.py[co]
|
|
12
|
+
global-exclude .DS_Store
|
|
13
|
+
global-exclude *.so
|
|
14
|
+
global-exclude *.dylib
|
|
15
|
+
|
|
16
|
+
# Exclude development and testing files
|
|
17
|
+
exclude .gitignore
|
|
18
|
+
exclude .env
|
|
19
|
+
exclude .env.*
|
|
20
|
+
prune tests
|
|
21
|
+
prune examples
|
|
22
|
+
prune tts_sdk
|
|
23
|
+
prune asr_sdk
|
|
24
|
+
prune denoise_sdk
|
|
25
|
+
|
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fonadalabs
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Unified Python SDK for FonadaLabs Text-to-Speech, Automatic Speech Recognition, and Audio Denoising APIs
|
|
5
|
+
Home-page: https://github.com/fonadalabs/fonadalabs-sdk
|
|
6
|
+
Author: FonadaLabs
|
|
7
|
+
Author-email: FonadaLabs <support@fonadalabs.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/fonadalabs/fonadalabs-sdk
|
|
10
|
+
Project-URL: Documentation, https://github.com/fonadalabs/fonadalabs-sdk#readme
|
|
11
|
+
Project-URL: Repository, https://github.com/fonadalabs/fonadalabs-sdk
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/fonadalabs/fonadalabs-sdk/issues
|
|
13
|
+
Keywords: text-to-speech,speech-recognition,audio-denoising,tts,asr,denoise,fonadalabs,speech,audio,ai,machine-learning
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: httpx<1.0,>=0.24
|
|
30
|
+
Requires-Dist: websockets<13,>=11
|
|
31
|
+
Requires-Dist: loguru<1.0,>=0.7
|
|
32
|
+
Requires-Dist: requests<3.0,>=2.28
|
|
33
|
+
Requires-Dist: numpy<2.0,>=1.21
|
|
34
|
+
Provides-Extra: ws
|
|
35
|
+
Requires-Dist: soundfile<0.14,>=0.12; extra == "ws"
|
|
36
|
+
Requires-Dist: websocket-client<2.0,>=1.5; extra == "ws"
|
|
37
|
+
Provides-Extra: denoise
|
|
38
|
+
Requires-Dist: soundfile<0.14,>=0.12; extra == "denoise"
|
|
39
|
+
Requires-Dist: librosa<1.0,>=0.10; extra == "denoise"
|
|
40
|
+
Requires-Dist: websocket-client<2.0,>=1.5; extra == "denoise"
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Requires-Dist: pytest<8.0,>=7.0; extra == "dev"
|
|
43
|
+
Requires-Dist: black<24.0,>=23.0; extra == "dev"
|
|
44
|
+
Requires-Dist: isort<6.0,>=5.0; extra == "dev"
|
|
45
|
+
Requires-Dist: python-dotenv<2.0,>=1.0; extra == "dev"
|
|
46
|
+
Requires-Dist: nest-asyncio<2.0,>=1.5; extra == "dev"
|
|
47
|
+
Requires-Dist: build>=0.10.0; extra == "dev"
|
|
48
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
49
|
+
Provides-Extra: all
|
|
50
|
+
Requires-Dist: soundfile<0.14,>=0.12; extra == "all"
|
|
51
|
+
Requires-Dist: librosa<1.0,>=0.10; extra == "all"
|
|
52
|
+
Requires-Dist: websocket-client<2.0,>=1.5; extra == "all"
|
|
53
|
+
Dynamic: author
|
|
54
|
+
Dynamic: home-page
|
|
55
|
+
Dynamic: license-file
|
|
56
|
+
Dynamic: requires-python
|
|
57
|
+
|
|
58
|
+
# FonadaLabs SDK
|
|
59
|
+
|
|
60
|
+
[](https://opensource.org/licenses/MIT)
|
|
61
|
+
[](https://www.python.org/downloads/)
|
|
62
|
+
[](https://github.com/fonadalabs/fonadalabs-sdk)
|
|
63
|
+
|
|
64
|
+
Unified Python SDK for FonadaLabs **Text-to-Speech (TTS)**, **Automatic Speech Recognition (ASR)**, and **Audio Denoising** APIs.
|
|
65
|
+
|
|
66
|
+
## Table of Contents
|
|
67
|
+
|
|
68
|
+
- [Features](#features)
|
|
69
|
+
- [Installation](#installation)
|
|
70
|
+
- [Quick Start](#quick-start)
|
|
71
|
+
- [Text-to-Speech (TTS)](#text-to-speech-tts)
|
|
72
|
+
- [Automatic Speech Recognition (ASR)](#automatic-speech-recognition-asr)
|
|
73
|
+
- [Audio Denoising](#audio-denoising)
|
|
74
|
+
- [Authentication](#authentication)
|
|
75
|
+
- [Advanced Features](#advanced-features)
|
|
76
|
+
- [Error Handling](#error-handling)
|
|
77
|
+
- [Security Features](#security-features)
|
|
78
|
+
- [Documentation](#documentation)
|
|
79
|
+
- [Examples](#examples)
|
|
80
|
+
- [Package Structure](#package-structure)
|
|
81
|
+
- [Importing](#importing)
|
|
82
|
+
- [Requirements](#requirements)
|
|
83
|
+
- [License](#license)
|
|
84
|
+
- [Support](#support)
|
|
85
|
+
|
|
86
|
+
## Features
|
|
87
|
+
|
|
88
|
+
### Text-to-Speech (TTS)
|
|
89
|
+
- 🎙️ High-quality text-to-speech generation with multiple voices
|
|
90
|
+
- 🚀 HTTP POST and WebSocket support
|
|
91
|
+
- 📊 Real-time progress tracking
|
|
92
|
+
- ⚡ Async support for concurrent requests
|
|
93
|
+
- 🎵 Audio streaming with chunk callbacks
|
|
94
|
+
- 🔒 Secure API key authentication
|
|
95
|
+
- ⚠️ Built-in error handling for rate limits and credit exhaustion
|
|
96
|
+
|
|
97
|
+
### Automatic Speech Recognition (ASR)
|
|
98
|
+
- 🎤 Audio file transcription
|
|
99
|
+
- 🌐 WebSocket streaming for real-time transcription
|
|
100
|
+
- 🔄 Concurrent batch processing
|
|
101
|
+
- 🌍 Multi-language support (50+ languages)
|
|
102
|
+
- 🔒 Secure API key authentication
|
|
103
|
+
- ⚠️ Comprehensive error handling
|
|
104
|
+
|
|
105
|
+
### Audio Denoising
|
|
106
|
+
- 🔇 High-quality audio denoising (DeepFilterNet + CMGAN)
|
|
107
|
+
- 🎯 Full audio and streaming chunk processing
|
|
108
|
+
- ⚡ Real-time WebSocket streaming with progress callbacks
|
|
109
|
+
- 📦 Batch processing support
|
|
110
|
+
- 🔒 Secure API key authentication
|
|
111
|
+
- ⚠️ Built-in rate limit and credit management
|
|
112
|
+
|
|
113
|
+
## Installation
|
|
114
|
+
|
|
115
|
+
### From PyPI (Recommended)
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pip install fonadalabs
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### From Source (Development)
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
git clone https://github.com/fonadalabs/fonadalabs-sdk.git
|
|
125
|
+
cd fonadalabs-sdk
|
|
126
|
+
pip install -e .
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### With Optional Dependencies
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# For WebSocket support (TTS + ASR streaming)
|
|
133
|
+
pip install fonadalabs[ws]
|
|
134
|
+
|
|
135
|
+
# For audio denoising features
|
|
136
|
+
pip install fonadalabs[denoise]
|
|
137
|
+
|
|
138
|
+
# Install everything
|
|
139
|
+
pip install fonadalabs[all]
|
|
140
|
+
|
|
141
|
+
# For development
|
|
142
|
+
pip install fonadalabs[dev]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Quick Start
|
|
146
|
+
|
|
147
|
+
### Text-to-Speech (TTS)
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from fonadalabs import TTSClient, TTSError, TTSCreditsExhaustedError, TTSRateLimitError
|
|
151
|
+
|
|
152
|
+
# Initialize with API key (or set FONADALABS_API_KEY env variable)
|
|
153
|
+
client = TTSClient(api_key="your-api-key-here")
|
|
154
|
+
|
|
155
|
+
try:
|
|
156
|
+
# Generate audio
|
|
157
|
+
audio_data = client.generate_audio(
|
|
158
|
+
text="Hello! Welcome to FonadaLabs TTS.",
|
|
159
|
+
voice="Anuradha",
|
|
160
|
+
output_file="output.mp3"
|
|
161
|
+
)
|
|
162
|
+
print(f"✓ Generated {len(audio_data)} bytes")
|
|
163
|
+
|
|
164
|
+
except TTSCreditsExhaustedError:
|
|
165
|
+
print("⚠️ API credits exhausted. Please add more credits.")
|
|
166
|
+
except TTSRateLimitError:
|
|
167
|
+
print("⚠️ Rate limit exceeded. Please try again later.")
|
|
168
|
+
except TTSError as e:
|
|
169
|
+
print(f"❌ TTS Error: {e}")
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Automatic Speech Recognition (ASR)
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from fonadalabs import ASRClient, ASRCreditsExhaustedError, ASRRateLimitError
|
|
176
|
+
|
|
177
|
+
# Initialize with API key (or set FONADALABS_API_KEY env variable)
|
|
178
|
+
asr_client = ASRClient(api_key="your-api-key-here")
|
|
179
|
+
|
|
180
|
+
try:
|
|
181
|
+
# Transcribe audio file
|
|
182
|
+
result = asr_client.transcribe(
|
|
183
|
+
audio_path="audio.wav",
|
|
184
|
+
language="en"
|
|
185
|
+
)
|
|
186
|
+
print(f"✓ Transcription: {result.text}")
|
|
187
|
+
|
|
188
|
+
except ASRCreditsExhaustedError:
|
|
189
|
+
print("⚠️ API credits exhausted. Please add more credits.")
|
|
190
|
+
except ASRRateLimitError:
|
|
191
|
+
print("⚠️ Rate limit exceeded. Please try again later.")
|
|
192
|
+
except Exception as e:
|
|
193
|
+
print(f"❌ ASR Error: {e}")
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Audio Denoising
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from fonadalabs import (
|
|
200
|
+
DenoiseHttpClient,
|
|
201
|
+
DenoiseStreamingClient,
|
|
202
|
+
DenoiseCreditsExhaustedError,
|
|
203
|
+
DenoiseRateLimitError
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
try:
|
|
207
|
+
# Full audio denoising (HTTP)
|
|
208
|
+
http_client = DenoiseHttpClient(api_key="your-api-key-here")
|
|
209
|
+
denoised = http_client.denoise_file("noisy.wav", "clean.wav")
|
|
210
|
+
print("✓ Denoised audio saved to clean.wav")
|
|
211
|
+
|
|
212
|
+
# Streaming denoising with progress
|
|
213
|
+
streaming_client = DenoiseStreamingClient(api_key="your-api-key-here")
|
|
214
|
+
|
|
215
|
+
def progress_callback(current, total):
|
|
216
|
+
percent = (current / total) * 100
|
|
217
|
+
print(f"Progress: {current}/{total} chunks ({percent:.1f}%)")
|
|
218
|
+
|
|
219
|
+
denoised = streaming_client.denoise_file(
|
|
220
|
+
"noisy.wav",
|
|
221
|
+
"clean.wav",
|
|
222
|
+
progress_callback=progress_callback
|
|
223
|
+
)
|
|
224
|
+
print("✓ Streaming denoising complete!")
|
|
225
|
+
|
|
226
|
+
except DenoiseCreditsExhaustedError:
|
|
227
|
+
print("⚠️ API credits exhausted. Please add more credits.")
|
|
228
|
+
except DenoiseRateLimitError:
|
|
229
|
+
print("⚠️ Rate limit exceeded. Please try again later.")
|
|
230
|
+
except Exception as e:
|
|
231
|
+
print(f"❌ Denoise Error: {e}")
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Authentication
|
|
235
|
+
|
|
236
|
+
All FonadaLabs APIs require API key authentication. You can obtain your API key from the [FonadaLabs Dashboard](https://fonadalabs.com/dashboard).
|
|
237
|
+
|
|
238
|
+
### Method 1: Environment Variable (Recommended)
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Set environment variable
|
|
242
|
+
export FONADALABS_API_KEY=your-api-key-here
|
|
243
|
+
|
|
244
|
+
# Or add to .env file
|
|
245
|
+
echo "FONADALABS_API_KEY=your-api-key-here" >> .env
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Then use the SDK without passing the key:
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
from fonadalabs import TTSClient, ASRClient, DenoiseHttpClient
|
|
252
|
+
|
|
253
|
+
# API key is automatically loaded from environment
|
|
254
|
+
tts_client = TTSClient()
|
|
255
|
+
asr_client = ASRClient()
|
|
256
|
+
denoise_client = DenoiseHttpClient()
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Method 2: Pass Directly in Code
|
|
260
|
+
|
|
261
|
+
```python
|
|
262
|
+
from fonadalabs import TTSClient, ASRClient, DenoiseHttpClient
|
|
263
|
+
|
|
264
|
+
tts_client = TTSClient(api_key="your-api-key")
|
|
265
|
+
asr_client = ASRClient(api_key="your-api-key")
|
|
266
|
+
denoise_client = DenoiseHttpClient(api_key="your-api-key")
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**⚠️ Security Note:** Never hardcode API keys in your source code. Always use environment variables or secure key management systems.
|
|
270
|
+
|
|
271
|
+
## Advanced Features
|
|
272
|
+
|
|
273
|
+
### WebSocket Streaming (TTS)
|
|
274
|
+
|
|
275
|
+
Stream audio with real-time progress updates:
|
|
276
|
+
|
|
277
|
+
```python
|
|
278
|
+
from fonadalabs import TTSClient
|
|
279
|
+
|
|
280
|
+
client = TTSClient(api_key="your-api-key")
|
|
281
|
+
|
|
282
|
+
def on_progress(progress_data):
|
|
283
|
+
print(f"Progress: {progress_data['percent']}%")
|
|
284
|
+
|
|
285
|
+
def on_chunk(audio_chunk):
|
|
286
|
+
print(f"Received chunk: {len(audio_chunk)} bytes")
|
|
287
|
+
|
|
288
|
+
audio = client.generate_audio_ws(
|
|
289
|
+
text="Long text for streaming...",
|
|
290
|
+
voice="Anuradha",
|
|
291
|
+
output_file="output.wav",
|
|
292
|
+
on_progress=on_progress,
|
|
293
|
+
on_chunk=on_chunk
|
|
294
|
+
)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Async Operations (TTS)
|
|
298
|
+
|
|
299
|
+
Use async methods for concurrent requests:
|
|
300
|
+
|
|
301
|
+
```python
|
|
302
|
+
import asyncio
|
|
303
|
+
from fonadalabs import TTSClient
|
|
304
|
+
|
|
305
|
+
client = TTSClient(api_key="your-api-key")
|
|
306
|
+
|
|
307
|
+
async def generate_multiple():
|
|
308
|
+
tasks = [
|
|
309
|
+
client.generate_audio_async("Text 1", "Anuradha", "output1.mp3"),
|
|
310
|
+
client.generate_audio_async("Text 2", "Ravi", "output2.mp3"),
|
|
311
|
+
client.generate_audio_async("Text 3", "Anuradha", "output3.mp3"),
|
|
312
|
+
]
|
|
313
|
+
results = await asyncio.gather(*tasks)
|
|
314
|
+
return results
|
|
315
|
+
|
|
316
|
+
audio_files = asyncio.run(generate_multiple())
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### WebSocket Streaming (ASR)
|
|
320
|
+
|
|
321
|
+
Real-time transcription with WebSocket:
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
import asyncio
|
|
325
|
+
from fonadalabs import ASRWebSocketClient
|
|
326
|
+
|
|
327
|
+
# Initialize with token (or set FONADALABS_API_KEY env variable)
|
|
328
|
+
ws_client = ASRWebSocketClient(
|
|
329
|
+
url="wss://your-websocket-endpoint/v1/asr/stream",
|
|
330
|
+
token="your-api-key",
|
|
331
|
+
use_ssl=True
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
# Transcribe using async method
|
|
335
|
+
async def transcribe():
|
|
336
|
+
result = await ws_client.transcribe_file(
|
|
337
|
+
file_path="audio.wav",
|
|
338
|
+
language_id="en"
|
|
339
|
+
)
|
|
340
|
+
print(f"Transcription: {result}")
|
|
341
|
+
|
|
342
|
+
asyncio.run(transcribe())
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Batch Processing (ASR)
|
|
346
|
+
|
|
347
|
+
Process multiple audio files concurrently:
|
|
348
|
+
|
|
349
|
+
```python
|
|
350
|
+
from fonadalabs import ASRClient
|
|
351
|
+
|
|
352
|
+
client = ASRClient(api_key="your-api-key")
|
|
353
|
+
|
|
354
|
+
# List of audio files to transcribe
|
|
355
|
+
file_paths = ["audio1.wav", "audio2.wav", "audio3.wav"]
|
|
356
|
+
|
|
357
|
+
# Batch transcribe with custom concurrency
|
|
358
|
+
results = client.batch_transcribe(
|
|
359
|
+
file_paths=file_paths,
|
|
360
|
+
language_id="en",
|
|
361
|
+
concurrency=3
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
# Process successful transcriptions
|
|
365
|
+
for result in results.successful:
|
|
366
|
+
print(f"✓ {result.file_path}: {result.text}")
|
|
367
|
+
|
|
368
|
+
# Handle failed transcriptions
|
|
369
|
+
for failed in results.failed:
|
|
370
|
+
print(f"✗ {failed.file_path}: {failed.error}")
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## Error Handling
|
|
374
|
+
|
|
375
|
+
The SDK provides specific exception types for different error scenarios:
|
|
376
|
+
|
|
377
|
+
### TTS Exceptions
|
|
378
|
+
|
|
379
|
+
```python
|
|
380
|
+
from fonadalabs import (
|
|
381
|
+
TTSError, # Base exception
|
|
382
|
+
TTSCreditsExhaustedError, # Credits exhausted (402)
|
|
383
|
+
TTSRateLimitError # Rate limit exceeded (429)
|
|
384
|
+
)
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### ASR Exceptions
|
|
388
|
+
|
|
389
|
+
```python
|
|
390
|
+
from fonadalabs import (
|
|
391
|
+
ASRSDKError, # Base exception
|
|
392
|
+
AuthenticationError, # Invalid API key
|
|
393
|
+
ValidationError, # Invalid parameters
|
|
394
|
+
HTTPRequestError, # HTTP request failed
|
|
395
|
+
ServerError, # Server error (500+)
|
|
396
|
+
ASRRateLimitError, # Rate limit exceeded
|
|
397
|
+
ASRTimeoutError, # Request timeout
|
|
398
|
+
ASRCreditsExhaustedError # Credits exhausted
|
|
399
|
+
)
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Denoise Exceptions
|
|
403
|
+
|
|
404
|
+
```python
|
|
405
|
+
from fonadalabs import (
|
|
406
|
+
DenoiseError, # Base exception
|
|
407
|
+
DenoiseCreditsExhaustedError, # Credits exhausted
|
|
408
|
+
DenoiseRateLimitError # Rate limit exceeded
|
|
409
|
+
)
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Security Features
|
|
413
|
+
|
|
414
|
+
### 🔒 Base URL Lockdown
|
|
415
|
+
|
|
416
|
+
All SDK clients use **hardcoded, secure base URLs** that cannot be overridden. This prevents:
|
|
417
|
+
- URL injection attacks
|
|
418
|
+
- Data exfiltration attempts
|
|
419
|
+
- Man-in-the-middle attacks
|
|
420
|
+
|
|
421
|
+
```python
|
|
422
|
+
# ✅ SECURE: Base URLs are locked
|
|
423
|
+
client = TTSClient(api_key="your-key")
|
|
424
|
+
|
|
425
|
+
# ❌ PREVENTED: Cannot override base URL
|
|
426
|
+
# client = TTSClient(api_key="key", base_url="http://malicious.com") # Not allowed
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
Base URLs can only be configured via environment variables by authorized administrators:
|
|
430
|
+
```bash
|
|
431
|
+
export FONADALABS_API_URL=https://your-secure-endpoint.com
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### 🔐 API Key Validation
|
|
435
|
+
|
|
436
|
+
All API requests are validated:
|
|
437
|
+
- API keys are required for all endpoints
|
|
438
|
+
- Invalid keys return `401 Unauthorized`
|
|
439
|
+
- Keys are transmitted securely via HTTPS
|
|
440
|
+
- Never logged or exposed in error messages
|
|
441
|
+
|
|
442
|
+
## Documentation
|
|
443
|
+
|
|
444
|
+
- **TTS Documentation:** See [TEXT_TO_SPEECH_QUICKSTART.md](tts_sdk/TEXT_TO_SPEECH_QUICKSTART.md)
|
|
445
|
+
- **ASR Documentation:** See [ASR_AUTHENTICATION.md](ASR_AUTHENTICATION.md)
|
|
446
|
+
- **Denoise Documentation:** See [denoise_sdk/README.md](denoise_sdk/README.md)
|
|
447
|
+
- **Security Audit:** See [SECURITY_AUDIT_REPORT.md](SECURITY_AUDIT_REPORT.md)
|
|
448
|
+
|
|
449
|
+
## Examples
|
|
450
|
+
|
|
451
|
+
### TTS Examples
|
|
452
|
+
Located in `tts_sdk/examples/`:
|
|
453
|
+
- `basic_usage.py` - Simple HTTP generation
|
|
454
|
+
- `websocket_usage.py` - WebSocket with progress tracking
|
|
455
|
+
- `async_usage.py` - Concurrent requests
|
|
456
|
+
- `streaming_usage.py` - Audio chunk streaming
|
|
457
|
+
- `auth_usage.py` - Authentication examples
|
|
458
|
+
|
|
459
|
+
### ASR Examples
|
|
460
|
+
Located in `asr_sdk/examples/`:
|
|
461
|
+
- `single_transcribe.py` - Single file transcription
|
|
462
|
+
- `concurrent_transcribe.py` - Batch processing
|
|
463
|
+
- `ws_transcribe.py` - WebSocket streaming
|
|
464
|
+
- `cli.py` - Command-line interface
|
|
465
|
+
|
|
466
|
+
### Denoise Examples
|
|
467
|
+
Located in `denoise_sdk/`:
|
|
468
|
+
- `sdk_test.py` - Quick start examples for HTTP and WebSocket denoising
|
|
469
|
+
|
|
470
|
+
## Package Structure
|
|
471
|
+
|
|
472
|
+
```
|
|
473
|
+
fonadalabs/
|
|
474
|
+
├── __init__.py # Unified package exports
|
|
475
|
+
├── tts/ # TTS submodule
|
|
476
|
+
│ ├── __init__.py
|
|
477
|
+
│ └── client.py # TTSClient
|
|
478
|
+
├── asr/ # ASR submodule
|
|
479
|
+
│ ├── __init__.py
|
|
480
|
+
│ ├── client.py # ASRClient
|
|
481
|
+
│ ├── ws_client.py # ASRWebSocketClient
|
|
482
|
+
│ ├── config.py # Configuration
|
|
483
|
+
│ ├── exceptions.py # ASR exceptions
|
|
484
|
+
│ ├── languages.py # Language utilities
|
|
485
|
+
│ ├── utils.py # Utility functions
|
|
486
|
+
│ └── models/ # Data models
|
|
487
|
+
│ └── types.py
|
|
488
|
+
└── denoise/ # Denoise submodule
|
|
489
|
+
├── __init__.py
|
|
490
|
+
├── http_client.py # DenoiseHttpClient
|
|
491
|
+
├── streaming_client.py # DenoiseStreamingClient
|
|
492
|
+
└── exceptions.py # Denoise exceptions
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
## Importing
|
|
496
|
+
|
|
497
|
+
### All Three SDKs
|
|
498
|
+
```python
|
|
499
|
+
from fonadalabs import (
|
|
500
|
+
TTSClient,
|
|
501
|
+
ASRClient,
|
|
502
|
+
DenoiseHttpClient,
|
|
503
|
+
DenoiseStreamingClient
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
tts = TTSClient(api_key="your-key")
|
|
507
|
+
asr = ASRClient(api_key="your-key")
|
|
508
|
+
denoise = DenoiseHttpClient(api_key="your-key")
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### TTS Only
|
|
512
|
+
```python
|
|
513
|
+
from fonadalabs import TTSClient, TTSError, TTSCreditsExhaustedError
|
|
514
|
+
# or explicitly from submodule
|
|
515
|
+
from fonadalabs.tts import TTSClient, TTSError
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### ASR Only
|
|
519
|
+
```python
|
|
520
|
+
from fonadalabs import ASRClient, ASRWebSocketClient
|
|
521
|
+
# or explicitly from submodule
|
|
522
|
+
from fonadalabs.asr import ASRClient, ASRWebSocketClient
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### Denoise Only
|
|
526
|
+
```python
|
|
527
|
+
from fonadalabs import DenoiseHttpClient, DenoiseStreamingClient
|
|
528
|
+
# or explicitly from submodule
|
|
529
|
+
from fonadalabs.denoise import DenoiseHttpClient, DenoiseStreamingClient
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
## Requirements
|
|
533
|
+
|
|
534
|
+
### Core Dependencies
|
|
535
|
+
- **Python** >= 3.9
|
|
536
|
+
- **httpx** >= 0.24, < 1.0 (HTTP client)
|
|
537
|
+
- **websockets** >= 11, < 13 (WebSocket support)
|
|
538
|
+
- **loguru** >= 0.7, < 1.0 (Logging)
|
|
539
|
+
- **requests** >= 2.28, < 3.0 (HTTP requests)
|
|
540
|
+
- **numpy** >= 1.21, < 2.0 (Audio processing)
|
|
541
|
+
|
|
542
|
+
### Optional Dependencies
|
|
543
|
+
|
|
544
|
+
**For WebSocket features (`pip install fonadalabs[ws]`):**
|
|
545
|
+
- soundfile >= 0.12, < 0.14
|
|
546
|
+
- websocket-client >= 1.5, < 2.0
|
|
547
|
+
|
|
548
|
+
**For Audio Denoising (`pip install fonadalabs[denoise]`):**
|
|
549
|
+
- soundfile >= 0.12, < 0.14
|
|
550
|
+
- librosa >= 0.10, < 1.0
|
|
551
|
+
- websocket-client >= 1.5, < 2.0
|
|
552
|
+
|
|
553
|
+
**For Development (`pip install fonadalabs[dev]`):**
|
|
554
|
+
- pytest >= 7.0, < 8.0
|
|
555
|
+
- black >= 23.0, < 24.0
|
|
556
|
+
- isort >= 5.0, < 6.0
|
|
557
|
+
- python-dotenv >= 1.0, < 2.0
|
|
558
|
+
- nest-asyncio >= 1.5, < 2.0
|
|
559
|
+
|
|
560
|
+
## Contributing
|
|
561
|
+
|
|
562
|
+
We welcome contributions! Please see our contributing guidelines and feel free to submit pull requests.
|
|
563
|
+
|
|
564
|
+
## License
|
|
565
|
+
|
|
566
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
567
|
+
|
|
568
|
+
Copyright (c) 2025 FonadaLabs
|
|
569
|
+
|
|
570
|
+
## Support
|
|
571
|
+
|
|
572
|
+
- 📧 **Email:** support@fonadalabs.com
|
|
573
|
+
- 🐛 **Issues:** [GitHub Issues](https://github.com/fonadalabs/fonadalabs-sdk/issues)
|
|
574
|
+
- 📖 **Documentation:**
|
|
575
|
+
- [TTS Quickstart](tts_sdk/TEXT_TO_SPEECH_QUICKSTART.md)
|
|
576
|
+
- [ASR Authentication](ASR_AUTHENTICATION.md)
|
|
577
|
+
- [Denoise SDK](denoise_sdk/README.md)
|
|
578
|
+
- 🌐 **Website:** https://fonadalabs.com
|
|
579
|
+
- 💬 **Community:** [Discord](https://discord.gg/fonadalabs) (if available)
|
|
580
|
+
|
|
581
|
+
## Version
|
|
582
|
+
|
|
583
|
+
**Current version:** 1.0.0 (Unified SDK)
|
|
584
|
+
|
|
585
|
+
### Version History
|
|
586
|
+
- **v1.0.0** (2025-10-16): Unified package with TTS, ASR, and Denoise
|
|
587
|
+
- Base URL security lockdown
|
|
588
|
+
- Required API key authentication for all endpoints
|
|
589
|
+
- Comprehensive error handling with specific exception types
|
|
590
|
+
- WebSocket streaming support for all services
|
|
591
|
+
- Async/await support
|
|
592
|
+
- Batch processing capabilities
|
|
593
|
+
|
|
594
|
+
---
|
|
595
|
+
|
|
596
|
+
**Made with ❤️ by FonadaLabs**
|
|
597
|
+
|
|
598
|
+
|