easyaligner 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.
- easyaligner-0.1.0/PKG-INFO +93 -0
- easyaligner-0.1.0/README.md +75 -0
- easyaligner-0.1.0/pyproject.toml +56 -0
- easyaligner-0.1.0/setup.cfg +4 -0
- easyaligner-0.1.0/src/easyalign/__init__.py +0 -0
- easyaligner-0.1.0/src/easyalign/alignment/__init__.py +0 -0
- easyaligner-0.1.0/src/easyalign/alignment/pytorch.py +1019 -0
- easyaligner-0.1.0/src/easyalign/alignment/utils.py +247 -0
- easyaligner-0.1.0/src/easyalign/data/__init__.py +1 -0
- easyaligner-0.1.0/src/easyalign/data/collators.py +170 -0
- easyaligner-0.1.0/src/easyalign/data/datamodel.py +214 -0
- easyaligner-0.1.0/src/easyalign/data/dataset.py +577 -0
- easyaligner-0.1.0/src/easyalign/data/utils.py +70 -0
- easyaligner-0.1.0/src/easyalign/pipelines.py +957 -0
- easyaligner-0.1.0/src/easyalign/text/__init__.py +0 -0
- easyaligner-0.1.0/src/easyalign/text/languages/sv.py +55 -0
- easyaligner-0.1.0/src/easyalign/text/normalization.py +271 -0
- easyaligner-0.1.0/src/easyalign/text/tokenizer.py +25 -0
- easyaligner-0.1.0/src/easyalign/utils.py +188 -0
- easyaligner-0.1.0/src/easyalign/vad/pyannote.py +476 -0
- easyaligner-0.1.0/src/easyalign/vad/silero.py +135 -0
- easyaligner-0.1.0/src/easyalign/vad/utils.py +174 -0
- easyaligner-0.1.0/src/easyalign/vad/vad.py +267 -0
- easyaligner-0.1.0/src/easyaligner.egg-info/PKG-INFO +93 -0
- easyaligner-0.1.0/src/easyaligner.egg-info/SOURCES.txt +26 -0
- easyaligner-0.1.0/src/easyaligner.egg-info/dependency_links.txt +1 -0
- easyaligner-0.1.0/src/easyaligner.egg-info/requires.txt +9 -0
- easyaligner-0.1.0/src/easyaligner.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: easyaligner
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Forced alignment pipeline designed for efficiency and ease of use.
|
|
5
|
+
Author: Faton Rekathati
|
|
6
|
+
Project-URL: Repository, https://github.com/kb-labb/easyaligner
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: transformers>=4.45.0
|
|
10
|
+
Requires-Dist: torch!=2.9.*,>=2.7.0
|
|
11
|
+
Requires-Dist: torchaudio!=2.9.*,>=2.7.0
|
|
12
|
+
Requires-Dist: tqdm>=4.66.1
|
|
13
|
+
Requires-Dist: soundfile>=0.12.1
|
|
14
|
+
Requires-Dist: nltk>=3.8.2
|
|
15
|
+
Requires-Dist: pyannote-audio>=3.3.1
|
|
16
|
+
Requires-Dist: silero-vad~=6.0
|
|
17
|
+
Requires-Dist: msgspec
|
|
18
|
+
|
|
19
|
+
# Easier forced alignment with `easyaligner`
|
|
20
|
+
|
|
21
|
+
`easyaligner` is a fast and memory efficient forced alignment pipeline for aligning speech and text. It is designed with ease of use in mind, supporting alignment both from ground-truth transcripts, as well as from ASR-generated transcripts. `easyaligner` acts as the backend that powers alignment in [`easywhisper`](https://github.com/kb-labb/easywhisper). Some notable features of `easyaligner` include:
|
|
22
|
+
|
|
23
|
+
* Uses [Pytorch's forced alignment API](https://docs.pytorch.org/audio/main/tutorials/ctc_forced_alignment_api_tutorial.html) with support for efficient GPU accelerated forced alignment. Enables aligning long audio segments fast and memory-efficiently ([Pratap et al., 2024](https://jmlr.org/papers/volume25/23-1318/23-1318.pdf)).
|
|
24
|
+
* Supports **custom regex-based text normalization** functionality to preprocess transcripts before alignment, in order to improve alignment quality. Maintains a mapping from original to normalized text, meaning the **normalizations and transformations are non-destructive** and reversible after alignment.
|
|
25
|
+
* Separates VAD, emission extraction (emissions are written to disk), and alignment into modular pipeline stages. Allows users to run everything end-to-end, or to run the separate stages individually (better flexibility for parallelization).
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
### With GPU support (recommended)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install easyaligner --extra-index-url https://download.pytorch.org/whl/cu128
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> [!TIP]
|
|
36
|
+
> Remove `--extra-index-url` if you want CPU-only installation.
|
|
37
|
+
|
|
38
|
+
### Using uv
|
|
39
|
+
|
|
40
|
+
When installing with [uv](https://docs.astral.sh/uv/), it will select the appropriate PyTorch version automatically (CPU for macOS, CUDA for Linux/Windows/ARM):
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv pip install easyaligner
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### For development
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/kb-labb/easyaligner.git
|
|
50
|
+
cd easyaligner
|
|
51
|
+
|
|
52
|
+
pip install -e . --extra-index-url https://download.pytorch.org/whl/cu128
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Logging and Error Handling
|
|
56
|
+
|
|
57
|
+
### Enabling Logging
|
|
58
|
+
|
|
59
|
+
To see progress and error messages one can add the following logging configuration at the start of a script:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import logging
|
|
63
|
+
|
|
64
|
+
logging.basicConfig(
|
|
65
|
+
level=logging.INFO,
|
|
66
|
+
format='%(asctime)s | %(name)s | %(levelname)s | %(message)s'
|
|
67
|
+
# handlers=[
|
|
68
|
+
# logging.FileHandler('easyalign.log'), # Log to a file
|
|
69
|
+
# logging.StreamHandler() # Also print to console
|
|
70
|
+
# ]
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Error Handling
|
|
75
|
+
|
|
76
|
+
`easyaligner` pipelines use PyTorch DataLoaders for efficient parallel processing and prefetching of data. During processing, the library silently skips files that fail to load (corrupted audio, missing file, etc.). The errors are logged with full traceback, the pipeline however continues processing the remaining files.
|
|
77
|
+
|
|
78
|
+
`easyaligner` leaves it up the user to decide how to handle failed files (retry, validate inputs, etc.).
|
|
79
|
+
|
|
80
|
+
> [!TIP]
|
|
81
|
+
> Track which files failed after processing completes by comparing output:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from pathlib import Path
|
|
85
|
+
|
|
86
|
+
# After pipeline completes, check which files produced output
|
|
87
|
+
output_files = list(Path("output/vad").rglob("*.json"))
|
|
88
|
+
output_stems = {f.stem for f in output_files}
|
|
89
|
+
|
|
90
|
+
# Find files that failed (no output produced)
|
|
91
|
+
failed = [p for p in audio_paths if Path(p).stem not in output_stems]
|
|
92
|
+
```
|
|
93
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Easier forced alignment with `easyaligner`
|
|
2
|
+
|
|
3
|
+
`easyaligner` is a fast and memory efficient forced alignment pipeline for aligning speech and text. It is designed with ease of use in mind, supporting alignment both from ground-truth transcripts, as well as from ASR-generated transcripts. `easyaligner` acts as the backend that powers alignment in [`easywhisper`](https://github.com/kb-labb/easywhisper). Some notable features of `easyaligner` include:
|
|
4
|
+
|
|
5
|
+
* Uses [Pytorch's forced alignment API](https://docs.pytorch.org/audio/main/tutorials/ctc_forced_alignment_api_tutorial.html) with support for efficient GPU accelerated forced alignment. Enables aligning long audio segments fast and memory-efficiently ([Pratap et al., 2024](https://jmlr.org/papers/volume25/23-1318/23-1318.pdf)).
|
|
6
|
+
* Supports **custom regex-based text normalization** functionality to preprocess transcripts before alignment, in order to improve alignment quality. Maintains a mapping from original to normalized text, meaning the **normalizations and transformations are non-destructive** and reversible after alignment.
|
|
7
|
+
* Separates VAD, emission extraction (emissions are written to disk), and alignment into modular pipeline stages. Allows users to run everything end-to-end, or to run the separate stages individually (better flexibility for parallelization).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### With GPU support (recommended)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install easyaligner --extra-index-url https://download.pytorch.org/whl/cu128
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
> [!TIP]
|
|
18
|
+
> Remove `--extra-index-url` if you want CPU-only installation.
|
|
19
|
+
|
|
20
|
+
### Using uv
|
|
21
|
+
|
|
22
|
+
When installing with [uv](https://docs.astral.sh/uv/), it will select the appropriate PyTorch version automatically (CPU for macOS, CUDA for Linux/Windows/ARM):
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv pip install easyaligner
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### For development
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/kb-labb/easyaligner.git
|
|
32
|
+
cd easyaligner
|
|
33
|
+
|
|
34
|
+
pip install -e . --extra-index-url https://download.pytorch.org/whl/cu128
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Logging and Error Handling
|
|
38
|
+
|
|
39
|
+
### Enabling Logging
|
|
40
|
+
|
|
41
|
+
To see progress and error messages one can add the following logging configuration at the start of a script:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import logging
|
|
45
|
+
|
|
46
|
+
logging.basicConfig(
|
|
47
|
+
level=logging.INFO,
|
|
48
|
+
format='%(asctime)s | %(name)s | %(levelname)s | %(message)s'
|
|
49
|
+
# handlers=[
|
|
50
|
+
# logging.FileHandler('easyalign.log'), # Log to a file
|
|
51
|
+
# logging.StreamHandler() # Also print to console
|
|
52
|
+
# ]
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Error Handling
|
|
57
|
+
|
|
58
|
+
`easyaligner` pipelines use PyTorch DataLoaders for efficient parallel processing and prefetching of data. During processing, the library silently skips files that fail to load (corrupted audio, missing file, etc.). The errors are logged with full traceback, the pipeline however continues processing the remaining files.
|
|
59
|
+
|
|
60
|
+
`easyaligner` leaves it up the user to decide how to handle failed files (retry, validate inputs, etc.).
|
|
61
|
+
|
|
62
|
+
> [!TIP]
|
|
63
|
+
> Track which files failed after processing completes by comparing output:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from pathlib import Path
|
|
67
|
+
|
|
68
|
+
# After pipeline completes, check which files produced output
|
|
69
|
+
output_files = list(Path("output/vad").rglob("*.json"))
|
|
70
|
+
output_stems = {f.stem for f in output_files}
|
|
71
|
+
|
|
72
|
+
# Find files that failed (no output produced)
|
|
73
|
+
failed = [p for p in audio_paths if Path(p).stem not in output_stems]
|
|
74
|
+
```
|
|
75
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=67.0.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
name = "easyaligner"
|
|
8
|
+
requires-python = ">= 3.10"
|
|
9
|
+
description = "Forced alignment pipeline designed for efficiency and ease of use."
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
authors = [{ name = "Faton Rekathati" }]
|
|
12
|
+
|
|
13
|
+
dependencies = [
|
|
14
|
+
"transformers>=4.45.0",
|
|
15
|
+
"torch>=2.7.0,!=2.9.*",
|
|
16
|
+
"torchaudio>=2.7.0,!=2.9.*",
|
|
17
|
+
"tqdm>=4.66.1",
|
|
18
|
+
"soundfile>=0.12.1",
|
|
19
|
+
"nltk>=3.8.2",
|
|
20
|
+
"pyannote-audio>=3.3.1",
|
|
21
|
+
"silero-vad~=6.0",
|
|
22
|
+
"msgspec"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Repository = "https://github.com/kb-labb/easyaligner"
|
|
27
|
+
|
|
28
|
+
[tool.uv.sources]
|
|
29
|
+
torch = [
|
|
30
|
+
{ index = "pytorch-cpu", marker = "sys_platform == 'darwin'" },
|
|
31
|
+
{ index = "pytorch-cuda", marker = "sys_platform != 'darwin'" },
|
|
32
|
+
]
|
|
33
|
+
torchaudio = [
|
|
34
|
+
{ index = "pytorch-cpu", marker = "sys_platform == 'darwin'" },
|
|
35
|
+
{ index = "pytorch-cuda", marker = "sys_platform != 'darwin'" },
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[[tool.uv.index]]
|
|
39
|
+
name = "pytorch-cuda"
|
|
40
|
+
url = "https://download.pytorch.org/whl/cu128"
|
|
41
|
+
explicit = true
|
|
42
|
+
|
|
43
|
+
[[tool.uv.index]]
|
|
44
|
+
name = "pytorch-cpu"
|
|
45
|
+
url = "https://download.pytorch.org/whl/cpu"
|
|
46
|
+
explicit = true
|
|
47
|
+
|
|
48
|
+
#### Linting ####
|
|
49
|
+
[tool.ruff]
|
|
50
|
+
line-length = 99
|
|
51
|
+
indent-width = 4
|
|
52
|
+
target-version = "py310"
|
|
53
|
+
|
|
54
|
+
[tool.ruff.lint]
|
|
55
|
+
# Disable fix for unused imports (`F401`).
|
|
56
|
+
unfixable = ["F401"]
|
|
File without changes
|
|
File without changes
|