autolrc-tools 0.1.1__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.
- autolrc_tools-0.1.1/.github/workflows/ci.yml +86 -0
- autolrc_tools-0.1.1/.gitignore +13 -0
- autolrc_tools-0.1.1/.pre-commit-config.yaml +12 -0
- autolrc_tools-0.1.1/LICENSE +21 -0
- autolrc_tools-0.1.1/PKG-INFO +219 -0
- autolrc_tools-0.1.1/README.md +183 -0
- autolrc_tools-0.1.1/bench/manifest.yaml +9 -0
- autolrc_tools-0.1.1/docs/architecture.md +107 -0
- autolrc_tools-0.1.1/pyproject.toml +73 -0
- autolrc_tools-0.1.1/scripts/eval.py +95 -0
- autolrc_tools-0.1.1/src/autolrc/__init__.py +10 -0
- autolrc_tools-0.1.1/src/autolrc/__main__.py +4 -0
- autolrc_tools-0.1.1/src/autolrc/aligner.py +668 -0
- autolrc_tools-0.1.1/src/autolrc/cli.py +407 -0
- autolrc_tools-0.1.1/src/autolrc/lrc.py +37 -0
- autolrc_tools-0.1.1/src/autolrc/models.py +83 -0
- autolrc_tools-0.1.1/src/autolrc/pipeline.py +485 -0
- autolrc_tools-0.1.1/src/autolrc/repair.py +18 -0
- autolrc_tools-0.1.1/src/autolrc/separator.py +226 -0
- autolrc_tools-0.1.1/src/autolrc/srt.py +54 -0
- autolrc_tools-0.1.1/tests/conftest.py +9 -0
- autolrc_tools-0.1.1/tests/test_cli.py +551 -0
- autolrc_tools-0.1.1/tests/test_core.py +110 -0
- autolrc_tools-0.1.1/tests/test_pipeline.py +380 -0
- autolrc_tools-0.1.1/tests/test_stable_ts.py +385 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
quality:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
cache: pip
|
|
23
|
+
cache-dependency-path: pyproject.toml
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip
|
|
28
|
+
python -m pip install -e .[dev]
|
|
29
|
+
|
|
30
|
+
- name: Pre-commit
|
|
31
|
+
run: pre-commit run --all-files
|
|
32
|
+
|
|
33
|
+
- name: CLI smoke
|
|
34
|
+
run: |
|
|
35
|
+
autolrc --help
|
|
36
|
+
autolrc align --help
|
|
37
|
+
autolrc benchmark --manifest bench/manifest.yaml
|
|
38
|
+
|
|
39
|
+
tests:
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
strategy:
|
|
42
|
+
fail-fast: false
|
|
43
|
+
matrix:
|
|
44
|
+
python-version: ["3.11", "3.12"]
|
|
45
|
+
steps:
|
|
46
|
+
- name: Checkout
|
|
47
|
+
uses: actions/checkout@v4
|
|
48
|
+
|
|
49
|
+
- name: Set up Python
|
|
50
|
+
uses: actions/setup-python@v5
|
|
51
|
+
with:
|
|
52
|
+
python-version: ${{ matrix.python-version }}
|
|
53
|
+
cache: pip
|
|
54
|
+
cache-dependency-path: pyproject.toml
|
|
55
|
+
|
|
56
|
+
- name: Install dependencies
|
|
57
|
+
run: |
|
|
58
|
+
python -m pip install --upgrade pip
|
|
59
|
+
python -m pip install -e .[dev]
|
|
60
|
+
|
|
61
|
+
- name: Test
|
|
62
|
+
run: python -m pytest -q
|
|
63
|
+
|
|
64
|
+
build:
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
steps:
|
|
67
|
+
- name: Checkout
|
|
68
|
+
uses: actions/checkout@v4
|
|
69
|
+
|
|
70
|
+
- name: Set up Python
|
|
71
|
+
uses: actions/setup-python@v5
|
|
72
|
+
with:
|
|
73
|
+
python-version: "3.12"
|
|
74
|
+
cache: pip
|
|
75
|
+
cache-dependency-path: pyproject.toml
|
|
76
|
+
|
|
77
|
+
- name: Install dependencies
|
|
78
|
+
run: |
|
|
79
|
+
python -m pip install --upgrade pip
|
|
80
|
+
python -m pip install -e .[dev]
|
|
81
|
+
|
|
82
|
+
- name: Build package
|
|
83
|
+
run: python -m build
|
|
84
|
+
|
|
85
|
+
- name: Twine check
|
|
86
|
+
run: python -m twine check dist/*
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v5.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: check-yaml
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: trailing-whitespace
|
|
8
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
9
|
+
rev: v0.11.4
|
|
10
|
+
hooks:
|
|
11
|
+
- id: ruff
|
|
12
|
+
- id: ruff-format
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PiPi
|
|
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,219 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autolrc-tools
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Generate line-level .lrc and .srt lyric files from audio and reference lyrics
|
|
5
|
+
Author: PiPi
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: alignment,lrc,lyrics,srt,whisper
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: <3.13,>=3.11
|
|
19
|
+
Requires-Dist: pyyaml<7.0.0,>=6.0.1
|
|
20
|
+
Requires-Dist: typer<1.0.0,>=0.12.3
|
|
21
|
+
Provides-Extra: cpu
|
|
22
|
+
Requires-Dist: audio-separator[cpu]>=0.26.0; extra == 'cpu'
|
|
23
|
+
Requires-Dist: rapidfuzz>=3.9.0; extra == 'cpu'
|
|
24
|
+
Requires-Dist: stable-ts>=2.17.0; extra == 'cpu'
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: build>=1.2.2; extra == 'dev'
|
|
27
|
+
Requires-Dist: pre-commit>=4.0.1; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=8.3.4; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.11.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: twine>=6.1.0; extra == 'dev'
|
|
31
|
+
Provides-Extra: gpu
|
|
32
|
+
Requires-Dist: audio-separator[gpu]>=0.26.0; extra == 'gpu'
|
|
33
|
+
Requires-Dist: rapidfuzz>=3.9.0; extra == 'gpu'
|
|
34
|
+
Requires-Dist: stable-ts>=2.17.0; extra == 'gpu'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# AutoLRC
|
|
38
|
+
|
|
39
|
+
AutoLRC generates line-level `.lrc` and `.srt` lyric files from an audio file and a
|
|
40
|
+
reference lyrics text file. The default path uses `stable-ts`, writes a sibling `.json`
|
|
41
|
+
report, and preserves the cleaned lyric line order from the input text file.
|
|
42
|
+
|
|
43
|
+
The primary release fixture pair is:
|
|
44
|
+
|
|
45
|
+
- audio: `tests/fixtures/Major Revision.wav`
|
|
46
|
+
- lyrics: `tests/fixtures/Major Revision.txt`
|
|
47
|
+
|
|
48
|
+
## Current Scope
|
|
49
|
+
|
|
50
|
+
- `autolrc align` supports single-file alignment and same-directory batch alignment
|
|
51
|
+
- `autolrc inspect` shows cleaned lyric lines before alignment
|
|
52
|
+
- `autolrc benchmark` validates the benchmark manifest and prints a summary
|
|
53
|
+
- `autolrc doctor` reports `ffmpeg`, `stable-ts`, `torch`, CUDA, and optional dependency
|
|
54
|
+
health
|
|
55
|
+
- `autolrc cache clear` removes local working files
|
|
56
|
+
|
|
57
|
+
The baseline aligner still exists as an explicit debug fallback with `--engine baseline`.
|
|
58
|
+
|
|
59
|
+
## Runtime Setup
|
|
60
|
+
|
|
61
|
+
Recreate the local virtual environment before using the ML-backed path.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
py -3.12 -m venv .venv
|
|
65
|
+
.venv\Scripts\python -m pip install --upgrade pip
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Install `ffmpeg` so it is available on `PATH`, then install PyTorch before AutoLRC.
|
|
69
|
+
|
|
70
|
+
GPU-first setup:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
.venv\Scripts\python -m pip install torch --index-url https://download.pytorch.org/whl/cu128
|
|
74
|
+
.venv\Scripts\python -m pip install -e .[gpu,dev]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
CPU fallback:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
.venv\Scripts\python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
|
|
81
|
+
.venv\Scripts\python -m pip install -e .[cpu,dev]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Use `autolrc doctor` before a long run:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
.venv\Scripts\autolrc doctor
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Single-File Usage
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
.venv\Scripts\autolrc align --audio "tests/fixtures/Major Revision.wav" --lyrics "tests/fixtures/Major Revision.txt"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Default behavior:
|
|
97
|
+
|
|
98
|
+
- engine: `stable-ts`
|
|
99
|
+
- model: `medium`
|
|
100
|
+
- device: `auto` (`cuda` first, `cpu` fallback)
|
|
101
|
+
- separator: `none`
|
|
102
|
+
- outputs: sibling `.lrc`, `.srt`, and `.json` files using the audio stem
|
|
103
|
+
- lyric preprocessing: trim lines, remove `()`, `{}`, and `[]` spans, strip emoji, and
|
|
104
|
+
drop empty lines
|
|
105
|
+
- language resolution order: explicit `--lang`, lyric-script inference, then multi-window
|
|
106
|
+
audio vote
|
|
107
|
+
|
|
108
|
+
Useful overrides:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
.venv\Scripts\autolrc align --audio "tests/fixtures/Major Revision.wav" --lyrics "tests/fixtures/Major Revision.txt" --device cpu
|
|
112
|
+
.venv\Scripts\autolrc align --audio "tests/fixtures/Major Revision.wav" --lyrics "tests/fixtures/Major Revision.txt" --engine baseline
|
|
113
|
+
.venv\Scripts\autolrc align --audio "tests/fixtures/Major Revision.wav" --lyrics "tests/fixtures/Major Revision.txt" --separator-boost --save-vocals
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
When a `stable-ts` run finishes with `average_confidence < 0.5`, AutoLRC does not retry
|
|
117
|
+
automatically. It tells you to inspect the generated files first and suggests
|
|
118
|
+
`--separator-boost` as a manual follow-up when appropriate.
|
|
119
|
+
|
|
120
|
+
## Batch Directory Mode
|
|
121
|
+
|
|
122
|
+
If `--audio` points to a directory, AutoLRC switches into batch mode.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
.venv\Scripts\autolrc align --audio tests/fixtures --engine baseline
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Batch mode rules:
|
|
129
|
+
|
|
130
|
+
- search only the given directory, not subdirectories
|
|
131
|
+
- match only same-stem `.wav` or `.mp3` files with a sibling `.txt`
|
|
132
|
+
- if both `.wav` and `.mp3` exist for one stem, `.wav` wins and `.mp3` is reported as
|
|
133
|
+
skipped
|
|
134
|
+
- continue after per-track failures
|
|
135
|
+
- exit with code `1` if any matched track fails, or if no valid pairs are found
|
|
136
|
+
|
|
137
|
+
Batch mode forbids per-track flags that do not scale cleanly:
|
|
138
|
+
|
|
139
|
+
- `--lyrics`
|
|
140
|
+
- `--output`
|
|
141
|
+
- `--json-report`
|
|
142
|
+
- `--title`
|
|
143
|
+
- `--artist`
|
|
144
|
+
- `--lang`
|
|
145
|
+
|
|
146
|
+
Allowed batch-wide flags include `--engine`, `--model`, `--device`, `--separator`,
|
|
147
|
+
`--separator-boost`, `--save-vocals`, and `--keep-temp`.
|
|
148
|
+
|
|
149
|
+
Per-track outputs still use the audio stem in the same directory:
|
|
150
|
+
|
|
151
|
+
- `song.wav` + `song.txt` -> `song.lrc`, `song.srt`, `song.json`
|
|
152
|
+
- `song.wav` + `song.txt` + `--save-vocals` -> also `song.vocals.wav`
|
|
153
|
+
|
|
154
|
+
The batch summary reports:
|
|
155
|
+
|
|
156
|
+
- matched tracks
|
|
157
|
+
- succeeded tracks
|
|
158
|
+
- low-confidence tracks
|
|
159
|
+
- failed tracks
|
|
160
|
+
- skipped files
|
|
161
|
+
|
|
162
|
+
## Benchmark Fixture
|
|
163
|
+
|
|
164
|
+
`bench/manifest.yaml` currently points to the `Major Revision` release fixture:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
.venv\Scripts\autolrc benchmark --manifest bench/manifest.yaml
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Separator Troubleshooting
|
|
171
|
+
|
|
172
|
+
`--separator-boost` enables the `audio-separator` backend and aligns against the separated
|
|
173
|
+
vocal stem. This can improve difficult tracks, but it uses more time, memory, and disk than
|
|
174
|
+
the default path.
|
|
175
|
+
|
|
176
|
+
If `audio-separator` shows up as installed but not runnable, the most common cause is an
|
|
177
|
+
older virtual environment that predates the current extras definition. Changing
|
|
178
|
+
`pyproject.toml` extras is normal packaging work, but existing environments do not
|
|
179
|
+
automatically gain those new optional dependencies.
|
|
180
|
+
|
|
181
|
+
After pulling this repo update, refresh the environment:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
.venv\Scripts\python -m pip install -e .[gpu,dev]
|
|
185
|
+
.venv\Scripts\python -m pip install -e .[cpu,dev]
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Use only one of those reinstall commands for the environment you want. The GPU command is
|
|
189
|
+
for CUDA-capable machines; the CPU command is the fallback.
|
|
190
|
+
|
|
191
|
+
## Release Checks
|
|
192
|
+
|
|
193
|
+
The manual release-prep flow is:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
.venv\Scripts\python -m pytest -q
|
|
197
|
+
.venv\Scripts\python -m ruff check src tests
|
|
198
|
+
.venv\Scripts\python -m pre_commit run --all-files
|
|
199
|
+
.venv\Scripts\python -m build
|
|
200
|
+
.venv\Scripts\python -m twine check dist/*
|
|
201
|
+
.venv\Scripts\python -m autolrc benchmark --manifest bench/manifest.yaml
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Repo Layout
|
|
205
|
+
|
|
206
|
+
```text
|
|
207
|
+
src/autolrc/
|
|
208
|
+
aligner.py
|
|
209
|
+
cli.py
|
|
210
|
+
lrc.py
|
|
211
|
+
models.py
|
|
212
|
+
pipeline.py
|
|
213
|
+
repair.py
|
|
214
|
+
separator.py
|
|
215
|
+
srt.py
|
|
216
|
+
tests/
|
|
217
|
+
bench/
|
|
218
|
+
docs/
|
|
219
|
+
```
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# AutoLRC
|
|
2
|
+
|
|
3
|
+
AutoLRC generates line-level `.lrc` and `.srt` lyric files from an audio file and a
|
|
4
|
+
reference lyrics text file. The default path uses `stable-ts`, writes a sibling `.json`
|
|
5
|
+
report, and preserves the cleaned lyric line order from the input text file.
|
|
6
|
+
|
|
7
|
+
The primary release fixture pair is:
|
|
8
|
+
|
|
9
|
+
- audio: `tests/fixtures/Major Revision.wav`
|
|
10
|
+
- lyrics: `tests/fixtures/Major Revision.txt`
|
|
11
|
+
|
|
12
|
+
## Current Scope
|
|
13
|
+
|
|
14
|
+
- `autolrc align` supports single-file alignment and same-directory batch alignment
|
|
15
|
+
- `autolrc inspect` shows cleaned lyric lines before alignment
|
|
16
|
+
- `autolrc benchmark` validates the benchmark manifest and prints a summary
|
|
17
|
+
- `autolrc doctor` reports `ffmpeg`, `stable-ts`, `torch`, CUDA, and optional dependency
|
|
18
|
+
health
|
|
19
|
+
- `autolrc cache clear` removes local working files
|
|
20
|
+
|
|
21
|
+
The baseline aligner still exists as an explicit debug fallback with `--engine baseline`.
|
|
22
|
+
|
|
23
|
+
## Runtime Setup
|
|
24
|
+
|
|
25
|
+
Recreate the local virtual environment before using the ML-backed path.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
py -3.12 -m venv .venv
|
|
29
|
+
.venv\Scripts\python -m pip install --upgrade pip
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Install `ffmpeg` so it is available on `PATH`, then install PyTorch before AutoLRC.
|
|
33
|
+
|
|
34
|
+
GPU-first setup:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
.venv\Scripts\python -m pip install torch --index-url https://download.pytorch.org/whl/cu128
|
|
38
|
+
.venv\Scripts\python -m pip install -e .[gpu,dev]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
CPU fallback:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
.venv\Scripts\python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
|
|
45
|
+
.venv\Scripts\python -m pip install -e .[cpu,dev]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Use `autolrc doctor` before a long run:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
.venv\Scripts\autolrc doctor
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Single-File Usage
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
.venv\Scripts\autolrc align --audio "tests/fixtures/Major Revision.wav" --lyrics "tests/fixtures/Major Revision.txt"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Default behavior:
|
|
61
|
+
|
|
62
|
+
- engine: `stable-ts`
|
|
63
|
+
- model: `medium`
|
|
64
|
+
- device: `auto` (`cuda` first, `cpu` fallback)
|
|
65
|
+
- separator: `none`
|
|
66
|
+
- outputs: sibling `.lrc`, `.srt`, and `.json` files using the audio stem
|
|
67
|
+
- lyric preprocessing: trim lines, remove `()`, `{}`, and `[]` spans, strip emoji, and
|
|
68
|
+
drop empty lines
|
|
69
|
+
- language resolution order: explicit `--lang`, lyric-script inference, then multi-window
|
|
70
|
+
audio vote
|
|
71
|
+
|
|
72
|
+
Useful overrides:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
.venv\Scripts\autolrc align --audio "tests/fixtures/Major Revision.wav" --lyrics "tests/fixtures/Major Revision.txt" --device cpu
|
|
76
|
+
.venv\Scripts\autolrc align --audio "tests/fixtures/Major Revision.wav" --lyrics "tests/fixtures/Major Revision.txt" --engine baseline
|
|
77
|
+
.venv\Scripts\autolrc align --audio "tests/fixtures/Major Revision.wav" --lyrics "tests/fixtures/Major Revision.txt" --separator-boost --save-vocals
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
When a `stable-ts` run finishes with `average_confidence < 0.5`, AutoLRC does not retry
|
|
81
|
+
automatically. It tells you to inspect the generated files first and suggests
|
|
82
|
+
`--separator-boost` as a manual follow-up when appropriate.
|
|
83
|
+
|
|
84
|
+
## Batch Directory Mode
|
|
85
|
+
|
|
86
|
+
If `--audio` points to a directory, AutoLRC switches into batch mode.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
.venv\Scripts\autolrc align --audio tests/fixtures --engine baseline
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Batch mode rules:
|
|
93
|
+
|
|
94
|
+
- search only the given directory, not subdirectories
|
|
95
|
+
- match only same-stem `.wav` or `.mp3` files with a sibling `.txt`
|
|
96
|
+
- if both `.wav` and `.mp3` exist for one stem, `.wav` wins and `.mp3` is reported as
|
|
97
|
+
skipped
|
|
98
|
+
- continue after per-track failures
|
|
99
|
+
- exit with code `1` if any matched track fails, or if no valid pairs are found
|
|
100
|
+
|
|
101
|
+
Batch mode forbids per-track flags that do not scale cleanly:
|
|
102
|
+
|
|
103
|
+
- `--lyrics`
|
|
104
|
+
- `--output`
|
|
105
|
+
- `--json-report`
|
|
106
|
+
- `--title`
|
|
107
|
+
- `--artist`
|
|
108
|
+
- `--lang`
|
|
109
|
+
|
|
110
|
+
Allowed batch-wide flags include `--engine`, `--model`, `--device`, `--separator`,
|
|
111
|
+
`--separator-boost`, `--save-vocals`, and `--keep-temp`.
|
|
112
|
+
|
|
113
|
+
Per-track outputs still use the audio stem in the same directory:
|
|
114
|
+
|
|
115
|
+
- `song.wav` + `song.txt` -> `song.lrc`, `song.srt`, `song.json`
|
|
116
|
+
- `song.wav` + `song.txt` + `--save-vocals` -> also `song.vocals.wav`
|
|
117
|
+
|
|
118
|
+
The batch summary reports:
|
|
119
|
+
|
|
120
|
+
- matched tracks
|
|
121
|
+
- succeeded tracks
|
|
122
|
+
- low-confidence tracks
|
|
123
|
+
- failed tracks
|
|
124
|
+
- skipped files
|
|
125
|
+
|
|
126
|
+
## Benchmark Fixture
|
|
127
|
+
|
|
128
|
+
`bench/manifest.yaml` currently points to the `Major Revision` release fixture:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
.venv\Scripts\autolrc benchmark --manifest bench/manifest.yaml
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Separator Troubleshooting
|
|
135
|
+
|
|
136
|
+
`--separator-boost` enables the `audio-separator` backend and aligns against the separated
|
|
137
|
+
vocal stem. This can improve difficult tracks, but it uses more time, memory, and disk than
|
|
138
|
+
the default path.
|
|
139
|
+
|
|
140
|
+
If `audio-separator` shows up as installed but not runnable, the most common cause is an
|
|
141
|
+
older virtual environment that predates the current extras definition. Changing
|
|
142
|
+
`pyproject.toml` extras is normal packaging work, but existing environments do not
|
|
143
|
+
automatically gain those new optional dependencies.
|
|
144
|
+
|
|
145
|
+
After pulling this repo update, refresh the environment:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
.venv\Scripts\python -m pip install -e .[gpu,dev]
|
|
149
|
+
.venv\Scripts\python -m pip install -e .[cpu,dev]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Use only one of those reinstall commands for the environment you want. The GPU command is
|
|
153
|
+
for CUDA-capable machines; the CPU command is the fallback.
|
|
154
|
+
|
|
155
|
+
## Release Checks
|
|
156
|
+
|
|
157
|
+
The manual release-prep flow is:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
.venv\Scripts\python -m pytest -q
|
|
161
|
+
.venv\Scripts\python -m ruff check src tests
|
|
162
|
+
.venv\Scripts\python -m pre_commit run --all-files
|
|
163
|
+
.venv\Scripts\python -m build
|
|
164
|
+
.venv\Scripts\python -m twine check dist/*
|
|
165
|
+
.venv\Scripts\python -m autolrc benchmark --manifest bench/manifest.yaml
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Repo Layout
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
src/autolrc/
|
|
172
|
+
aligner.py
|
|
173
|
+
cli.py
|
|
174
|
+
lrc.py
|
|
175
|
+
models.py
|
|
176
|
+
pipeline.py
|
|
177
|
+
repair.py
|
|
178
|
+
separator.py
|
|
179
|
+
srt.py
|
|
180
|
+
tests/
|
|
181
|
+
bench/
|
|
182
|
+
docs/
|
|
183
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
tracks:
|
|
2
|
+
- track_id: major_revision
|
|
3
|
+
audio_path: tests/fixtures/Major Revision.wav
|
|
4
|
+
lyrics_path: tests/fixtures/Major Revision.txt
|
|
5
|
+
languages: [en]
|
|
6
|
+
is_mixed_language: false
|
|
7
|
+
has_long_intro: true
|
|
8
|
+
has_repeated_chorus: true
|
|
9
|
+
notes: Primary English release fixture for benchmark and smoke validation.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
AutoLRC is split into a few small layers so the CLI can stay simple while the alignment and
|
|
4
|
+
separation backends evolve. The current benchmark manifest and release smoke workflow are
|
|
5
|
+
centered on `tests/fixtures/Major Revision.wav` plus `tests/fixtures/Major Revision.txt`.
|
|
6
|
+
|
|
7
|
+
## Main Modules
|
|
8
|
+
|
|
9
|
+
- `cli.py`: public command surface, single-file mode, batch directory mode, benchmark
|
|
10
|
+
summary, and doctor output
|
|
11
|
+
- `pipeline.py`: orchestration for one alignment run plus batch discovery and execution
|
|
12
|
+
- `aligner.py`: lyric preprocessing, language resolution, runtime checks, and alignment
|
|
13
|
+
backends
|
|
14
|
+
- `separator.py`: passthrough separation, `audio-separator` integration, and separator
|
|
15
|
+
runtime diagnostics
|
|
16
|
+
- `repair.py`: post-alignment repair hook
|
|
17
|
+
- `lrc.py`: `.lrc` rendering
|
|
18
|
+
- `srt.py`: `.srt` rendering
|
|
19
|
+
- `models.py`: shared dataclasses for lyrics, alignments, and batch results
|
|
20
|
+
|
|
21
|
+
## Single-File Flow
|
|
22
|
+
|
|
23
|
+
1. `cli.align` validates the file-oriented flags and builds an `AlignRequest`.
|
|
24
|
+
2. `AutoLRCService.align` normalizes paths, derives sibling output locations, and creates a
|
|
25
|
+
per-run work directory under `.autolrc-cache`.
|
|
26
|
+
3. `LyricsNormalizer.read` loads the raw `.txt`, strips bracketed notes and emoji, collapses
|
|
27
|
+
whitespace, drops empty lines, and keeps the cleaned line order as canonical.
|
|
28
|
+
4. `get_separator(...)` resolves the requested separation backend.
|
|
29
|
+
5. `get_aligner(...)` resolves the requested alignment backend.
|
|
30
|
+
6. The aligner returns `LineAlignment` objects, which are rendered into `.lrc`, `.srt`, and a
|
|
31
|
+
`.json` report.
|
|
32
|
+
|
|
33
|
+
The default path is `stable-ts` with model `medium`, device `auto`, and separator `none`.
|
|
34
|
+
|
|
35
|
+
## Batch Directory Flow
|
|
36
|
+
|
|
37
|
+
Batch mode is a CLI orchestration layer over repeated single-track runs, not a separate
|
|
38
|
+
alignment backend.
|
|
39
|
+
|
|
40
|
+
1. `cli.align` switches into batch mode when `--audio` points to a directory.
|
|
41
|
+
2. Batch mode rejects flags that do not scale cleanly across multiple tracks:
|
|
42
|
+
`--lyrics`, `--output`, `--json-report`, `--title`, `--artist`, and `--lang`.
|
|
43
|
+
3. `AutoLRCService.batch_align` scans only the given directory for same-stem `.wav` or `.mp3`
|
|
44
|
+
files with a sibling `.txt`.
|
|
45
|
+
4. If both `.wav` and `.mp3` exist for one stem, `.wav` is selected and `.mp3` is recorded as
|
|
46
|
+
skipped.
|
|
47
|
+
5. Each discovered pair is turned into a normal `AlignRequest` and processed through the
|
|
48
|
+
single-file pipeline.
|
|
49
|
+
6. Failures are collected per track, later tracks still run, and the CLI prints a final
|
|
50
|
+
summary of matched, succeeded, low-confidence, failed, and skipped entries.
|
|
51
|
+
|
|
52
|
+
## Language Resolution
|
|
53
|
+
|
|
54
|
+
`stable-ts` alignment resolves language in this order:
|
|
55
|
+
|
|
56
|
+
1. explicit `--lang`
|
|
57
|
+
2. lyric-script inference from the cleaned text
|
|
58
|
+
3. multi-window audio vote using `ffprobe` plus `stable-ts` transcription samples
|
|
59
|
+
4. fail with an actionable message if the vote is inconclusive
|
|
60
|
+
|
|
61
|
+
The current script inference is intentionally opinionated for common CJK workflows:
|
|
62
|
+
|
|
63
|
+
- Kana presence resolves to `ja`
|
|
64
|
+
- Hangul-majority text resolves to `ko`
|
|
65
|
+
- Han-majority text without Kana or Hangul resolves to `zh`
|
|
66
|
+
|
|
67
|
+
Latin-script lyrics do not force `en`; they fall through to the audio vote. The current
|
|
68
|
+
primary fixture resolves to `en` via the audio-vote path on a healthy runtime.
|
|
69
|
+
|
|
70
|
+
## Separation and Boost Mode
|
|
71
|
+
|
|
72
|
+
`separator.py` currently exposes two modes:
|
|
73
|
+
|
|
74
|
+
- `none`: passthrough, align directly on the original mix
|
|
75
|
+
- `audio-separator`: generate a vocal stem before alignment
|
|
76
|
+
|
|
77
|
+
`--separator-boost` is a convenience flag that selects `audio-separator`. If `--save-vocals`
|
|
78
|
+
is also enabled, the separated vocal stem is copied or converted into a sibling
|
|
79
|
+
`<stem>.vocals.wav`.
|
|
80
|
+
|
|
81
|
+
AutoLRC does not automatically retry low-confidence runs. Instead, the report includes
|
|
82
|
+
`low_confidence`, `low_confidence_threshold`, and `recommended_action`, and the CLI suggests a
|
|
83
|
+
manual `--separator-boost` rerun when the average confidence is below `0.5` and the run did
|
|
84
|
+
not already use real separation.
|
|
85
|
+
|
|
86
|
+
## Runtime and Release Diagnostics
|
|
87
|
+
|
|
88
|
+
`doctor` combines:
|
|
89
|
+
|
|
90
|
+
- `aligner.py` runtime checks for `ffmpeg`, `stable-ts`, `torch`, and CUDA
|
|
91
|
+
- `separator.py` importability checks for `audio-separator`
|
|
92
|
+
|
|
93
|
+
The separator check goes beyond `find_spec`: it attempts to import the runtime entry point so
|
|
94
|
+
environments that still miss `onnxruntime`, `onnxruntime-gpu`, or other transitive pieces are
|
|
95
|
+
reported as broken instead of merely installed.
|
|
96
|
+
|
|
97
|
+
That matters because extras changes in `pyproject.toml` do not retrofit existing virtual
|
|
98
|
+
environments. After pulling dependency changes, users may need to refresh the environment with
|
|
99
|
+
`python -m pip install -e .[gpu,dev]` or `python -m pip install -e .[cpu,dev]`.
|
|
100
|
+
|
|
101
|
+
The manual release-prep loop is:
|
|
102
|
+
|
|
103
|
+
1. run lint, tests, and pre-commit
|
|
104
|
+
2. build wheel and sdist
|
|
105
|
+
3. run `twine check dist/*`
|
|
106
|
+
4. run `autolrc benchmark --manifest bench/manifest.yaml`
|
|
107
|
+
5. run a real alignment smoke test against `tests/fixtures/Major Revision.*`
|