lattifai 0.1.4__py3-none-any.whl

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.
@@ -0,0 +1,467 @@
1
+ Metadata-Version: 2.4
2
+ Name: lattifai
3
+ Version: 0.1.4
4
+ Summary: Lattifai Python SDK: Seamless Integration with Lattifai's Speech and Video AI Services
5
+ Author-email: Lattifai Technologies <tech@lattifai.com>
6
+ Maintainer-email: Lattice <tech@lattifai.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2025 Lattifai.
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Project-URL: Homepage, https://github.com/lattifai/lattifai-python
29
+ Project-URL: Documentation, https://github.com/lattifai/lattifai-python/api.md
30
+ Project-URL: Bug Tracker, https://github.com/lattifai/lattifai-python/issues
31
+ Project-URL: Discussions, https://github.com/lattifai/lattifai-python/discussions
32
+ Project-URL: Changelog, https://github.com/lattifai/lattifai-python/CHANGELOG
33
+ Keywords: lattifai,speech recognition,video analysis,ai,sdk,api client
34
+ Classifier: Development Status :: 5 - Production/Stable
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: Intended Audience :: Science/Research
37
+ Classifier: License :: OSI Approved :: Apache Software License
38
+ Classifier: Programming Language :: Python :: 3.9
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Programming Language :: Python :: 3.12
42
+ Classifier: Programming Language :: Python :: 3.13
43
+ Classifier: Operating System :: MacOS :: MacOS X
44
+ Classifier: Operating System :: POSIX :: Linux
45
+ Classifier: Operating System :: Microsoft :: Windows
46
+ Classifier: Topic :: Multimedia :: Sound/Audio
47
+ Classifier: Topic :: Multimedia :: Video
48
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
49
+ Requires-Python: >=3.9
50
+ Description-Content-Type: text/markdown
51
+ License-File: LICENSE
52
+ Requires-Dist: httpx
53
+ Requires-Dist: python-dotenv
54
+ Requires-Dist: lhotse>=1.26.0
55
+ Requires-Dist: colorful>=0.5.6
56
+ Requires-Dist: lattifai-core>=0.1.4
57
+ Provides-Extra: numpy
58
+ Requires-Dist: numpy; extra == "numpy"
59
+ Provides-Extra: test
60
+ Requires-Dist: pytest; extra == "test"
61
+ Requires-Dist: pytest-cov; extra == "test"
62
+ Requires-Dist: ruff; extra == "test"
63
+ Requires-Dist: numpy; extra == "test"
64
+ Provides-Extra: all
65
+ Requires-Dist: numpy; extra == "all"
66
+ Requires-Dist: pytest; extra == "all"
67
+ Requires-Dist: pytest-cov; extra == "all"
68
+ Requires-Dist: ruff; extra == "all"
69
+ Dynamic: license-file
70
+
71
+ # LattifAI Python
72
+
73
+ > ⚠️ **Under Active Development** - Official release scheduled for October 18, 2025
74
+
75
+ [![PyPI version](https://badge.fury.io/py/lattifai.svg)](https://badge.fury.io/py/lattifai)
76
+
77
+ The official Python library for the LattifAI API - Advanced forced alignment and subtitle generation powered by `Lattice-1-Alpha` model.
78
+
79
+ ## Installation
80
+
81
+ ```bash
82
+ pip install lattifai
83
+ ```
84
+
85
+ ## GPU Support Status
86
+
87
+ > **🚧 GPU Support Coming Soon**: CUDA/GPU acceleration is currently under active development. The current version supports CPU-only processing. GPU support will be available in an upcoming release, providing significant performance improvements for large audio files.
88
+
89
+ ## Quick Start
90
+
91
+ ### Python API
92
+
93
+ ```python
94
+ import os
95
+ from lattifai import LattifAI
96
+
97
+ # Initialize client
98
+ client = LattifAI(
99
+ api_key=os.environ.get("LATTIFAI_API_KEY"), # Optional if set in environment
100
+ device='cpu', # Currently only CPU is supported, GPU support coming soon
101
+ )
102
+
103
+ # Perform alignment
104
+ result = client.alignment(
105
+ audio="path/to/audio.wav",
106
+ subtitle="path/to/subtitle.srt", # or .txt, .vtt, .ass
107
+ format="srt", # auto-detect if not specified
108
+ output_subtitle_path="output.srt"
109
+ )
110
+
111
+ print(f"Alignment complete! Output saved to: {result}")
112
+ ```
113
+
114
+ ### Command Line Interface
115
+
116
+ The library provides powerful command-line tools for batch processing and automation.
117
+
118
+ #### Basic Alignment
119
+
120
+ ```bash
121
+ # Align audio with subtitle file
122
+ lattifai-align input_audio.wav input_subtitle.srt output_aligned.srt
123
+
124
+ # Specify input format explicitly
125
+ lattifai-align -F srt input_audio.wav transcript.txt output.srt
126
+
127
+ # Auto-detect input format (default)
128
+ lattifai-align input_audio.wav subtitle_file.vtt output.vtt
129
+ ```
130
+
131
+ #### Using the Main CLI
132
+
133
+ ```bash
134
+ # Show available commands
135
+ lattifai --help
136
+
137
+ # Perform alignment (same as lattifai-align)
138
+ lattifai align input_audio.wav input_subtitle.srt output.srt
139
+
140
+ # Subtitle format conversion
141
+ lattifai subtitle convert input.srt output.vtt
142
+ ```
143
+
144
+ #### Supported Input Formats
145
+
146
+ - **SRT**: SubRip Subtitle format (`.srt`)
147
+ - **VTT**: WebVTT format (`.vtt`)
148
+ - **ASS**: Advanced SubStation Alpha format (`.ass`)
149
+ - **TXT**: Plain text format (`.txt`)
150
+ - **AUTO**: Automatic format detection (default)
151
+
152
+ #### Command Line Options
153
+
154
+ - `-F, --input_format`: Specify input subtitle format (`srt`, `vtt`, `ass`, `txt`, `auto`)
155
+ - `--help`: Show help message and available options
156
+
157
+ ## API Reference
158
+
159
+ ### LattifAI Class
160
+
161
+ #### Constructor Parameters
162
+
163
+ ```python
164
+ LattifAI(
165
+ api_key: Optional[str] = None, # API key (or set LATTIFAI_API_KEY env var)
166
+ base_url: Optional[str] = None, # API base URL (or set LATTIFAI_BASE_URL env var)
167
+ device: str = 'cpu', # Device for processing (currently only 'cpu' supported)
168
+ )
169
+ ```
170
+
171
+ > **Note**: The `device` parameter currently only supports `'cpu'`. GPU support (`'cuda'`) is under active development and will be available in future releases.
172
+
173
+ #### Methods
174
+
175
+ ##### `alignment()`
176
+
177
+ Perform forced alignment between audio and text/subtitles.
178
+
179
+ ```python
180
+ def alignment(
181
+ audio: Pathlike, # Path to audio file
182
+ subtitle: Pathlike, # Path to subtitle/text file
183
+ format: Optional[SubtitleFormat] = None, # Input format (auto-detect if None)
184
+ output_subtitle_path: Optional[Pathlike] = None # Output file path
185
+ ) -> str:
186
+ ```
187
+
188
+ **Parameters:**
189
+ - `audio`: Path to the audio file (WAV, MP3, etc.)
190
+ - `subtitle`: Path to subtitle or text file
191
+ - `format`: Input format (`'srt'`, `'vtt'`, `'ass'`, `'txt'`, or `None` for auto-detection)
192
+ - `output_subtitle_path`: Path where aligned subtitle will be saved
193
+
194
+ **Returns:**
195
+ - Path to output file (if `output_subtitle_path` specified) or alignment results
196
+
197
+ **Example:**
198
+ ```python
199
+ # Basic usage
200
+ result = client.alignment("audio.wav", "subtitle.srt")
201
+
202
+ # With explicit format and output path
203
+ result = client.alignment(
204
+ audio="interview.mp3",
205
+ subtitle="transcript.txt",
206
+ format="txt",
207
+ output_subtitle_path="aligned_interview.srt"
208
+ )
209
+ ```
210
+
211
+
212
+ ## Configuration
213
+
214
+ ### Environment Variables
215
+
216
+ - `LATTIFAI_API_KEY`: Your LattifAI API key (required)
217
+ - `LATTIFAI_BASE_URL`: Base URL for the API (default: `https://api.lattifai.com/v1`)
218
+
219
+ ### Device Configuration
220
+
221
+ > **Note**: GPU/CUDA support is currently under development and will be available in a future release. Currently, only CPU processing is supported.
222
+
223
+ The library is designed to support both CPU and GPU processing:
224
+
225
+ ```python
226
+ # CPU processing (currently supported)
227
+ client = LattifAI(device='cpu')
228
+
229
+ # GPU processing (coming soon)
230
+ # client = LattifAI(device='cuda') # Will be available in future releases
231
+ ```
232
+
233
+ ### Performance Tuning
234
+
235
+ For better performance with large files:
236
+
237
+ ```python
238
+ client = LattifAI(
239
+ device='cpu', # Currently only CPU is supported
240
+ )
241
+ ```
242
+
243
+ > **GPU Acceleration**: CUDA support is in active development and will significantly improve processing speed for large audio files. Expected in upcoming releases.
244
+
245
+ ## Examples
246
+
247
+ ### Basic Text Alignment
248
+
249
+ ```python
250
+ from lattifai import LattifAI
251
+
252
+ client = LattifAI()
253
+
254
+ # Align plain text with audio
255
+ result = client.alignment(
256
+ audio="speech.wav",
257
+ subtitle="Hello world. This is a test.",
258
+ format="txt",
259
+ output_subtitle_path="aligned.srt"
260
+ )
261
+ ```
262
+
263
+ ### Subtitle Refinement
264
+
265
+ ```python
266
+ # Improve existing subtitle timing
267
+ result = client.alignment(
268
+ audio="movie.mp4",
269
+ subtitle="rough_subtitles.srt",
270
+ output_subtitle_path="precise_subtitles.srt"
271
+ )
272
+ ```
273
+
274
+ ### Batch Processing
275
+
276
+ ```python
277
+ import os
278
+ from pathlib import Path
279
+
280
+ client = LattifAI()
281
+
282
+ # Process multiple files
283
+ audio_dir = Path("audio_files")
284
+ subtitle_dir = Path("subtitles")
285
+ output_dir = Path("aligned_output")
286
+
287
+ for audio_file in audio_dir.glob("*.wav"):
288
+ subtitle_file = subtitle_dir / f"{audio_file.stem}.srt"
289
+ output_file = output_dir / f"{audio_file.stem}_aligned.srt"
290
+
291
+ if subtitle_file.exists():
292
+ client.alignment(
293
+ audio=audio_file,
294
+ subtitle=subtitle_file,
295
+ output_subtitle_path=output_file
296
+ )
297
+ ```
298
+
299
+ ## Supported Formats
300
+
301
+ ### Audio Formats
302
+ - **WAV**: Recommended for best quality
303
+ - **MP3**: Widely supported compressed format
304
+ - **FLAC**: Lossless compression
305
+ - **M4A**: Apple audio format
306
+ - **OGG**: Open source audio format
307
+
308
+ ### Subtitle Formats
309
+ - **SRT**: SubRip Subtitle format (most common)
310
+ - **VTT**: WebVTT format (web standard)
311
+ - **ASS**: Advanced SubStation Alpha format (advanced styling)
312
+ - **TXT**: Plain text format (one sentence per line)
313
+
314
+ ## Error Handling
315
+
316
+ ```python
317
+ from lattifai import LattifAI, LattifAIError
318
+
319
+ try:
320
+ client = LattifAI()
321
+ result = client.alignment(
322
+ audio="audio.wav",
323
+ subtitle="subtitle.srt"
324
+ )
325
+ except LattifAIError as e:
326
+ print(f"LattifAI error: {e}")
327
+ except FileNotFoundError as e:
328
+ print(f"File not found: {e}")
329
+ except Exception as e:
330
+ print(f"Unexpected error: {e}")
331
+ ```
332
+
333
+ ### Common Error Scenarios
334
+
335
+ - **Missing API Key**: Set `LATTIFAI_API_KEY` environment variable
336
+ - **File Not Found**: Verify input file paths exist
337
+ - **Unsupported Format**: Check supported audio/subtitle formats
338
+ - **Network Issues**: Check internet connection and API endpoint
339
+ - **Device Configuration**: Currently only `device='cpu'` is supported (GPU support coming soon)
340
+
341
+ ## Model Information
342
+
343
+ This library uses the **Lattice-1-Alpha** model for high-quality forced alignment and subtitle generation.
344
+
345
+ ### Model Features
346
+ - **High Accuracy**: State-of-the-art alignment precision
347
+ - **Multi-language Support**: Supports various languages and accents
348
+ - **Robust Processing**: Handles noisy audio and imperfect transcripts
349
+ - **Fast Processing**: Optimized for both CPU and GPU execution
350
+
351
+ ### Model Requirements
352
+ - **Minimum Python**: 3.9+
353
+ - **Memory**: 4GB RAM recommended
354
+ - **Storage**: ~2GB for model files
355
+ - **GPU**: CUDA support coming soon (currently CPU-only)
356
+
357
+ ## Requirements
358
+
359
+ - **Python**: 3.9-3.13
360
+ - **Core Dependencies**:
361
+ - httpx (HTTP client)
362
+ - lhotse (audio processing)
363
+ - colorful (colored output)
364
+ - python-dotenv (environment management)
365
+ - click (command line interface)
366
+
367
+ ## Development
368
+
369
+ ### Setting Up Development Environment
370
+
371
+ 1. **Clone the repository:**
372
+ ```bash
373
+ git clone https://github.com/lattifai/lattifai-python.git
374
+ cd lattifai-python
375
+ ```
376
+
377
+ 2. **Install development dependencies:**
378
+ ```bash
379
+ pip install -e ".[test]"
380
+ ```
381
+
382
+ 3. **Install Git hooks (recommended):**
383
+ ```bash
384
+ ./scripts/install-hooks.sh
385
+ ```
386
+
387
+ This will install pre-commit hooks that automatically run `isort` and `ruff` checks before each commit to ensure code quality.
388
+
389
+ ### Code Quality Tools
390
+
391
+ We use the following tools to maintain code quality:
392
+
393
+ - **isort**: Automatically sorts and organizes imports
394
+ - **ruff**: Fast Python linter and formatter
395
+
396
+ To manually run these tools:
397
+
398
+ ```bash
399
+ # Sort imports
400
+ isort src/ tests/
401
+
402
+ # Run linter
403
+ ruff check src/ tests/
404
+
405
+ # Run formatter
406
+ ruff format src/ tests/
407
+
408
+ # Fix issues automatically
409
+ ruff check --fix src/ tests/
410
+ ```
411
+
412
+ ### Running Tests
413
+
414
+ ```bash
415
+ # Run all tests
416
+ pytest
417
+
418
+ # Run with coverage
419
+ pytest --cov=src --cov-report=html
420
+
421
+ # Run specific test file
422
+ pytest tests/test_basic.py -v
423
+ ```
424
+
425
+ ### Building and Testing Locally
426
+
427
+ ```bash
428
+ # Build package
429
+ python -m build
430
+
431
+ # Install locally
432
+ pip install -e .
433
+
434
+ # Test CLI commands
435
+ lattifai --help
436
+ lattifai-align --help
437
+ ```
438
+
439
+ ### Contributing
440
+
441
+ 1. Fork the repository
442
+ 2. Create a feature branch: `git checkout -b feature-name`
443
+ 3. Make your changes and add tests
444
+ 4. Run the test suite: `pytest`
445
+ 5. Run code quality checks: `ruff check src/ tests/`
446
+ 6. Commit your changes: `git commit -am 'Add some feature'`
447
+ 7. Push to the branch: `git push origin feature-name`
448
+ 8. Submit a pull request
449
+
450
+ ### Bypassing Pre-commit Hooks
451
+
452
+ If you need to commit without running the hooks (not recommended):
453
+
454
+ ```bash
455
+ git commit --no-verify
456
+ ```
457
+
458
+ ## License
459
+
460
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
461
+
462
+ ## Support
463
+
464
+ - **Documentation**: [API Documentation](https://github.com/lattifai/lattifai-python/api.md)
465
+ - **Issues**: [GitHub Issues](https://github.com/lattifai/lattifai-python/issues)
466
+ - **Discussions**: [GitHub Discussions](https://github.com/lattifai/lattifai-python/discussions)
467
+ - **Changelog**: [CHANGELOG.md](https://github.com/lattifai/lattifai-python/CHANGELOG)
@@ -0,0 +1,22 @@
1
+ lattifai/__init__.py,sha256=8vZF9_yObaoDZ6sUaJBuQqUp5mGBRfD4z0SdTY_8BcQ,672
2
+ lattifai/base_client.py,sha256=ktFtATjL9pLSJUD-VqeJKA1FHkrsGHX7Uq_x00H7gO8,3322
3
+ lattifai/client.py,sha256=szz9aT_GTa5JKA2ZGsd7XHr56aG_H-nf83yqRcPUVxs,4664
4
+ lattifai/bin/__init__.py,sha256=7YhmtEM8kbxJtz2-KIskvpLKBZAvkMSceVx8z4fkgQ4,61
5
+ lattifai/bin/align.py,sha256=uX8VaATzn8CgdHUtry1ZGhXiz0Jr89ELdfRK6GWC1t8,989
6
+ lattifai/bin/cli_base.py,sha256=4xlN4cnJZh54ErhHUHgJpyVsrcB-ftwniFzRQL_7SlU,289
7
+ lattifai/bin/subtitle.py,sha256=bUWImAHpvyY59Vskqb5loQiD5ytQOxR8lTQRiQ4LyNA,647
8
+ lattifai/io/__init__.py,sha256=vHWRN7MvAch-GUeFqqO-gM57SM-4YOpGUjIxFJdjfPA,671
9
+ lattifai/io/reader.py,sha256=ErPnPMUvYQpjZ7Vd86EsHUkOcEfKdoI8iM3yKHRzSOQ,2576
10
+ lattifai/io/supervision.py,sha256=5UfSsgBhXoDU3-6drDtoD7y8HIiA4xRKZnbOKgeejwM,354
11
+ lattifai/io/writer.py,sha256=1eAEFLlL8kricxRDPFBtVmeC4IiFyFnjbWXvw0VU-q4,2036
12
+ lattifai/tokenizers/__init__.py,sha256=aqv44PDtq6g3oFFKW_l4HSR5ywT5W8eP1dHHywIvBfs,72
13
+ lattifai/tokenizers/phonemizer.py,sha256=Q5Z-4rbT3AjAPLNPnyvWGcEaJuKXRudgeIK6tUhVsJs,1741
14
+ lattifai/tokenizers/tokenizer.py,sha256=Qqg12zihl192Tlax6plVyxthrnzBciGLSRuzFQRgOdc,5663
15
+ lattifai/workers/__init__.py,sha256=s6YfkIq4FDIAzY9sPjRpXnJfszj2repqnMTqydRM5Zw,83
16
+ lattifai/workers/lattice1_alpha.py,sha256=kR5wNLMn1qN14PvRA6RlWjQUGblYrJ636ILC-XkvS0s,4770
17
+ lattifai-0.1.4.dist-info/licenses/LICENSE,sha256=LNuoH5jpXXNKgjQ3XLwztFq8D3O7kZI-LSg81o4ym2M,1065
18
+ lattifai-0.1.4.dist-info/METADATA,sha256=HEsoKRRfjRoeNwUff7Cx44sYP9trid_bdtX3j5WqK6o,13628
19
+ lattifai-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ lattifai-0.1.4.dist-info/entry_points.txt,sha256=BaixG8HYzE3Ff0QDAmsbX8cjsxZSLwUv5u4cnIpunr0,88
21
+ lattifai-0.1.4.dist-info/top_level.txt,sha256=tHSoXF26r-IGfbIP_JoYATqbmf14h5NrnNJGH4j5reI,9
22
+ lattifai-0.1.4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ lattifai = lattifai.bin:cli
3
+ lattifai-align = lattifai.bin.align:align
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lattifai.
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 @@
1
+ lattifai