lattifai 0.1.5__py3-none-any.whl → 0.2.2__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.
@@ -1,444 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: lattifai
3
- Version: 0.1.5
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/README.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.md
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
- Requires-Dist: pysubs2
58
- Requires-Dist: praatio
59
- Requires-Dist: tgt
60
- Requires-Dist: onnxruntime
61
- Requires-Dist: resampy
62
- Requires-Dist: g2p-phonemizer>=0.1.1
63
- Provides-Extra: numpy
64
- Requires-Dist: numpy; extra == "numpy"
65
- Provides-Extra: test
66
- Requires-Dist: pytest; extra == "test"
67
- Requires-Dist: pytest-cov; extra == "test"
68
- Requires-Dist: ruff; extra == "test"
69
- Requires-Dist: numpy; extra == "test"
70
- Provides-Extra: all
71
- Requires-Dist: numpy; extra == "all"
72
- Requires-Dist: pytest; extra == "all"
73
- Requires-Dist: pytest-cov; extra == "all"
74
- Requires-Dist: ruff; extra == "all"
75
- Dynamic: license-file
76
-
77
- # LattifAI Python
78
-
79
- <!-- <p align="center">
80
- <a href="https://badge.fury.io/py/lattifai"><img src="https://badge.fury.io/py/lattifai.svg" alt="PyPI version"></a>
81
- </p> -->
82
-
83
- [![PyPI version](https://badge.fury.io/py/lattifai.svg)](https://badge.fury.io/py/lattifai)
84
-
85
- <p align="center">
86
- &nbsp&nbsp 🖥️ <a href="https://github.com/lattifai/lattifai-python">GitHub</a> &nbsp&nbsp | &nbsp&nbsp🤗 <a href="https://huggingface.co/Lattifai/Lattice-1-Alpha">Lattifai/Lattice-1-Alpha</a>&nbsp&nbsp | &nbsp&nbsp 📑 <a href="https://lattifai.com/blogs">Blog</a> &nbsp&nbsp | &nbsp&nbsp <a href="https://discord.gg/gTZqdaBJ"><img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" alt="Discord" style="vertical-align: middle;"></a>&nbsp&nbsp
87
- </p>
88
-
89
- The official Python library for the LattifAI API - Advanced forced alignment and subtitle generation powered by `[Lattifai/Lattice-1-Alpha](https://huggingface.co/Lattifai/Lattice-1-Alpha)` model.
90
-
91
- ## Installation
92
-
93
- ```bash
94
- pip install lattifai
95
-
96
- install-k2 # Required: This step must be executed to install k2 dependencies
97
- ```
98
-
99
- > **⚠️ Important**: After installing `lattifai`, you **must** run `install-k2` to install the required k2 library. The library will not function properly without this step.
100
-
101
- ## GPU Support Status
102
-
103
- > **🚧 GPU Support Coming Soon**: The current version supports CPU-only processing. NVIDIA GPU and Apple Silicon acceleration will be available in an upcoming release, providing significant performance improvements for large audio files.
104
-
105
- ## Quick Start
106
-
107
- ### Command Line Interface
108
-
109
- The library provides powerful command-line tools for batch processing and automation.
110
-
111
- #### Using the Main CLI
112
-
113
- ```bash
114
- # Show available commands
115
- lattifai --help
116
-
117
- # Perform alignment (same as lattifai-align)
118
- lattifai align input_audio.wav input_subtitle.srt output.srt
119
-
120
- # Subtitle format conversion
121
- lattifai subtitle convert input.srt output.vtt
122
- ```
123
-
124
- ### Python API
125
-
126
- ```python
127
- import os
128
- from lattifai import LattifAI
129
-
130
- # Initialize client
131
- client = LattifAI(
132
- api_key=os.environ.get("LATTIFAI_API_KEY"), # Optional if set in environment
133
- model_name_or_path='Lattifai/Lattice-1-Alpha',
134
- device='cpu', # Currently only CPU is supported, GPU support coming soon
135
- )
136
-
137
- # Perform alignment
138
- result = client.alignment(
139
- audio="path/to/audio.wav",
140
- subtitle="path/to/subtitle.srt", # or .txt, .vtt, .ass
141
- format="srt", # auto-detect if not specified
142
- output_subtitle_path="output.srt"
143
- )
144
-
145
- print(f"Alignment complete! Output saved to: {result}")
146
- ```
147
-
148
-
149
- #### Supported Input Formats
150
-
151
- - **SRT**: SubRip Subtitle format (`.srt`)
152
- - **VTT**: WebVTT format (`.vtt`)
153
- - **ASS**: Advanced SubStation Alpha format (`.ass`)
154
- - **TXT**: Plain text format (`.txt`)
155
- - **AUTO**: Automatic format detection (default)
156
-
157
- #### Command Line Options
158
-
159
- - `-F, --input_format`: Specify input subtitle format (`srt`, `vtt`, `ass`, `txt`, `auto`)
160
- - `--help`: Show help message and available options
161
-
162
- ## API Reference
163
-
164
- ### LattifAI Class
165
-
166
- #### Constructor Parameters
167
-
168
- ```python
169
- LattifAI(
170
- api_key: Optional[str] = None, # API key (or set LATTIFAI_API_KEY env var)
171
- device: str = 'cpu', # Device for processing (currently only 'cpu' supported)
172
- )
173
- ```
174
-
175
- > **Note**: The `device` parameter currently only supports `'cpu'`. GPU support will be available in future releases.
176
-
177
- #### Methods
178
-
179
- ##### `alignment()`
180
-
181
- Perform forced alignment between audio and text/subtitles.
182
-
183
- ```python
184
- def alignment(
185
- audio: Pathlike, # Path to audio file
186
- subtitle: Pathlike, # Path to subtitle/text file
187
- format: Optional[SubtitleFormat] = None, # Input format (auto-detect if None)
188
- output_subtitle_path: Optional[Pathlike] = None # Output file path
189
- ) -> str:
190
- ```
191
-
192
- **Parameters:**
193
- - `audio`: Path to the audio file (WAV, MP3, etc.)
194
- - `subtitle`: Path to subtitle or text file
195
- - `format`: Input format (`'srt'`, `'vtt'`, `'ass'`, `'txt'`, or `None` for auto-detection)
196
- - `output_subtitle_path`: Path where aligned subtitle will be saved
197
-
198
- **Returns:**
199
- - Path to output file (if `output_subtitle_path` specified) or alignment results
200
-
201
- ## Configuration
202
-
203
- ### Environment Variables
204
-
205
- - `LATTIFAI_API_KEY`: Your LattifAI API key (required)
206
-
207
- ### Performance Tuning
208
-
209
- For better performance with large files:
210
-
211
- ```python
212
- client = LattifAI(
213
- device='cpu', # Currently only CPU is supported, cuda/mps will be supported in upcoming releases.
214
- )
215
- ```
216
-
217
- > **GPU Acceleration**: CUDA and Apple Silicon(MPS) support is in active development and will significantly improve processing speed for large audio files. Expected in upcoming releases.
218
-
219
- ## Examples
220
-
221
- ### Basic Text Alignment
222
-
223
- ```python
224
- from lattifai import LattifAI
225
-
226
- client = LattifAI()
227
-
228
- # Align plain text with audio
229
- result = client.alignment(
230
- audio="speech.wav",
231
- subtitle="Hello world. This is a test.",
232
- format="txt",
233
- output_subtitle_path="aligned.srt"
234
- )
235
- ```
236
-
237
- ### Subtitle Refinement
238
-
239
- ```python
240
- # Improve existing subtitle timing
241
- result = client.alignment(
242
- audio="movie.mp4",
243
- subtitle="rough_subtitles.srt",
244
- output_subtitle_path="precise_subtitles.srt"
245
- )
246
- ```
247
-
248
- ### Batch Processing
249
-
250
- ```python
251
- import os
252
- from pathlib import Path
253
-
254
- client = LattifAI()
255
-
256
- # Process multiple files
257
- audio_dir = Path("audio_files")
258
- subtitle_dir = Path("subtitles")
259
- output_dir = Path("aligned_output")
260
-
261
- for audio_file in audio_dir.glob("*.wav"):
262
- subtitle_file = subtitle_dir / f"{audio_file.stem}.srt"
263
- output_file = output_dir / f"{audio_file.stem}_aligned.srt"
264
-
265
- if subtitle_file.exists():
266
- client.alignment(
267
- audio=audio_file,
268
- subtitle=subtitle_file,
269
- output_subtitle_path=output_file
270
- )
271
- ```
272
-
273
- ## Supported Formats
274
-
275
- ### Audio Formats
276
- - **WAV**: Recommended for best quality
277
- - **MP3**: Widely supported compressed format
278
- - **FLAC**: Lossless compression
279
- - **M4A**: Apple audio format
280
- - **OGG**: Open source audio format
281
-
282
- ### Subtitle Formats
283
- - **SRT**: SubRip Subtitle format (most common)
284
- - **VTT**: WebVTT format (web standard)
285
- - **ASS**: Advanced SubStation Alpha format (advanced styling)
286
- - **TXT**: Plain text format (one sentence per line)
287
-
288
- ## Error Handling
289
-
290
- ```python
291
- from lattifai import LattifAI, LattifAIError
292
-
293
- try:
294
- client = LattifAI()
295
- result = client.alignment(
296
- audio="audio.wav",
297
- subtitle="subtitle.srt"
298
- )
299
- except LattifAIError as e:
300
- print(f"LattifAI error: {e}")
301
- except FileNotFoundError as e:
302
- print(f"File not found: {e}")
303
- except Exception as e:
304
- print(f"Unexpected error: {e}")
305
- ```
306
-
307
- ### Common Error Scenarios
308
-
309
- - **Missing API Key**: Set `LATTIFAI_API_KEY` environment variable
310
- - **File Not Found**: Verify input file paths exist
311
- - **Unsupported Format**: Check supported audio/subtitle formats
312
- - **Network Issues**: Check internet connection and API endpoint
313
- - **Device Configuration**: Currently only `device='cpu'` is supported (GPU support coming soon)
314
-
315
- ## Model Information
316
-
317
- This library uses the **[Lattice-1-Alpha](https://huggingface.co/Lattifai/Lattice-1-Alpha)** model for high-quality forced alignment and subtitle generation.
318
-
319
- ### Model Features
320
- - **High Accuracy**: State-of-the-art alignment precision
321
- - **Multi-language Support**: Supports various languages and accents
322
- - **Robust Processing**: Handles noisy audio and imperfect transcripts
323
- - **Fast Processing**: Optimized for both CPU and GPU execution
324
-
325
- ### Model Requirements
326
- - **Minimum Python**: 3.9+
327
- - **Memory**: 4GB RAM recommended
328
- - **Storage**: ~2GB for model files
329
- - **GPU**: CUDA support coming soon (currently CPU-only)
330
-
331
- ## Requirements
332
-
333
- - **Python**: 3.9-3.13
334
- - **Core Dependencies**:
335
- - httpx (HTTP client)
336
- - lhotse (audio processing)
337
- - k2 (audio computation)
338
- - python-dotenv (environment management)
339
- - click (command line interface)
340
-
341
- ## Development
342
-
343
- ### Setting Up Development Environment
344
-
345
- 1. **Clone the repository:**
346
- ```bash
347
- git clone https://github.com/lattifai/lattifai-python.git
348
- cd lattifai-python
349
- ```
350
-
351
- 2. **Install development dependencies:**
352
- ```bash
353
- pip install -e ".[test]"
354
- ```
355
-
356
- 3. **Install Git hooks (recommended):**
357
- ```bash
358
- ./scripts/install-hooks.sh
359
- ```
360
-
361
- This will install pre-commit hooks that automatically run `isort` and `ruff` checks before each commit to ensure code quality.
362
-
363
- ### Code Quality Tools
364
-
365
- We use the following tools to maintain code quality:
366
-
367
- - **isort**: Automatically sorts and organizes imports
368
- - **ruff**: Fast Python linter and formatter
369
-
370
- To manually run these tools:
371
-
372
- ```bash
373
- # Sort imports
374
- isort src/ tests/ scripts/
375
-
376
- # Run linter
377
- ruff check src/ tests/ scripts/
378
-
379
- # Run formatter
380
- ruff format src/ tests/ scripts/
381
-
382
- # Fix issues automatically
383
- ruff check --fix src/ tests/ scripts/
384
- ```
385
-
386
- ### Running Tests
387
-
388
- ```bash
389
- # Install test dependencies first
390
- pip install -e ".[test]"
391
-
392
- # Run all tests
393
- pytest
394
-
395
- # Run with coverage
396
- pytest --cov=src --cov-report=html
397
-
398
- # Run specific test file
399
- pytest tests/test_basic.py -v
400
- ```
401
-
402
- ### Building and Testing Locally
403
-
404
- ```bash
405
- # Build package
406
- python -m build
407
-
408
- # Install locally
409
- pip install -e .
410
-
411
- # Test CLI commands
412
- lattifai --help
413
- lattifai-align --help
414
- ```
415
-
416
- ### Contributing
417
-
418
- 1. Fork the repository
419
- 2. Create a feature branch: `git checkout -b feature-name`
420
- 3. Make your changes and add tests
421
- 4. Run the test suite: `pytest`
422
- 5. Run code quality checks: `ruff check src/ tests/`
423
- 6. Commit your changes: `git commit -am 'Add some feature'`
424
- 7. Push to the branch: `git push origin feature-name`
425
- 8. Submit a pull request
426
-
427
- ### Bypassing Pre-commit Hooks
428
-
429
- If you need to commit without running the hooks (not recommended):
430
-
431
- ```bash
432
- git commit --no-verify
433
- ```
434
-
435
- ## License
436
-
437
- This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
438
-
439
- ## Support
440
-
441
- - **Documentation**: [API Documentation](https://github.com/lattifai/lattifai-python/README.md)
442
- - **Issues**: [GitHub Issues](https://github.com/lattifai/lattifai-python/issues)
443
- - **Discussions**: [GitHub Discussions](https://github.com/lattifai/lattifai-python/discussions)
444
- - **Changelog**: [CHANGELOG.md](https://github.com/lattifai/lattifai-python/CHANGELOG.md)
@@ -1,24 +0,0 @@
1
- lattifai/__init__.py,sha256=wPE3D03AK8Ktu2WFXqJ6rx6jvPVWKstFQgyPq0tndUU,2324
2
- lattifai/base_client.py,sha256=ktFtATjL9pLSJUD-VqeJKA1FHkrsGHX7Uq_x00H7gO8,3322
3
- lattifai/client.py,sha256=p9mFkyOINKBGB87TE6P4y6Z3fPOPSqi6HAyz00TMuag,4520
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=SfRi1KIMpmaao6OVmR1h_I_3QU-vrE6D5bh72Afg5XM,1759
14
- lattifai/tokenizers/tokenizer.py,sha256=u4lgS6-jN9cLuMNIojA4Swfsqb1EcyI7Bh_iw7tuL-s,5818
15
- lattifai/workers/__init__.py,sha256=s6YfkIq4FDIAzY9sPjRpXnJfszj2repqnMTqydRM5Zw,83
16
- lattifai/workers/lattice1_alpha.py,sha256=5OJ6APnFpWvi1azKlkbJqF85e2n5JyZ_m8L1XQ2r3qg,4862
17
- lattifai-0.1.5.dist-info/licenses/LICENSE,sha256=LNuoH5jpXXNKgjQ3XLwztFq8D3O7kZI-LSg81o4ym2M,1065
18
- scripts/__init__.py,sha256=4nwVNeJeEuGiWGBACgySViLlm5DrqcvFOWpo7Ds8MUA,49
19
- scripts/install_k2.py,sha256=iGdy_VZrwaBJfdKy5EDvPX0x5V4dH_lm3f8DEiVWcOQ,21166
20
- lattifai-0.1.5.dist-info/METADATA,sha256=LsJCRZPTmnuF279cKjO6jtK1ZzG8JrL0sEnOfjvoNxk,13644
21
- lattifai-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- lattifai-0.1.5.dist-info/entry_points.txt,sha256=CwTI2NbJvF9msIHboAfTA99cmDr_HOWoODjS8R64JOw,131
23
- lattifai-0.1.5.dist-info/top_level.txt,sha256=-OVWZ68YYFcTN13ARkLasp2OUappe9wEVq-CKes7jM4,17
24
- lattifai-0.1.5.dist-info/RECORD,,
scripts/__init__.py DELETED
@@ -1 +0,0 @@
1
- """Scripts for lattifai package installation."""