Skip to content

Filter lyricsalign

Phillippe Pelzer edited this page Nov 15, 2026 · 2 revisions

lyricsalign

lyricsalign places known lyric text on a vocal stem. It does not transcribe. It is an audio filter, available since v1.0.46. The current version is 1.1.0 (v1.0.47).

How it works, in short:

  1. espeak-ng turns every lyric line into IPA phones.
  2. A wav2vec2 phoneme model on ggml (facebook/wav2vec2-xlsr-53-espeak-cv-ft, Apache-2.0) gives per-frame phone probabilities.
  3. A Viterbi search over the phone chain places every phone. A "star" absorbs ad-libs and backing vocals between lines.
  4. The filter aligns a second time on vocals + blend x backing. It writes a line only when both alignments agree.

A line that fails any test is skipped, with the reason. The filter never invents a time.

It is an offline filter. It buffers both inputs to the end, aligns once, writes the result, then forwards the end of the stream. The output is input 0, unchanged, so -f null - works and chaining works.

Quick example

The stems come from stemsplit. The lyrics are a text file. The JSON Lines go to stdout.

ffmpeg -i song.flac -filter_complex \
  "[0:a]stemsplit=model=spleeter-2stems-f16.gguf:stem=all[v][a];[v][a]lyricsalign=model=wav2vec2-xlsr-53-espeak-cv-ft-f16.gguf:text_file=lyrics.txt:language=en-us:destination=-" \
  -f null - > lyrics.jsonl

Without a stem split, feed silence as the backing. Every line then passes the agreement check:

ffmpeg -i vocals.wav -filter_complex \
  "anullsrc=r=16000:cl=mono[b];[0:a][b]lyricsalign=model=wav2vec2-xlsr-53-espeak-cv-ft-f16.gguf:text_file=lyrics.txt:language=nl:destination=-" \
  -f null - > lyrics.jsonl

There are two audio inputs and one output.

Pad Name Use
Input 0 vocals The stem the lines are placed on.
Input 1 backing The accompaniment the check listens to as well. An endless backing such as anullsrc ends with the vocals.
Output 0 default Input 0, unchanged.

Options

The table is copied from ffmpeg -h filter=lyricsalign of v1.0.47.

Option Type Default Range What it does
model string none, required Path to the GGUF phoneme model, wav2vec2-xlsr-53-espeak-cv-ft-f16.gguf.
text_file string none, required UTF-8 lyric text, one lyric line per text line. An empty line is an instrumental marker.
language string none, required The espeak-ng voice name of the lyrics: en-us, en-gb, nl, de, fr, ja and others.
espeak_data string empty Path to espeak-ng-data. Empty means the directory next to the ffmpeg binary.
blend float 0.5 0 to 1 Share of the backing mixed into the check signal. 0 disables the agreement check.
destination string empty Where the JSON Lines go. - is stdout. Empty logs the lines.
threads int 0 0 to INT_MAX ggml CPU threads. 0 is half the physical cores, capped by -filter_threads. It never changes the output.
use_gpu boolean false Allow the ggml GPU backend (Vulkan, Metal). Off by default: the acceptance numbers were measured on the CPU.
gpu_device int 0 0 to INT_MAX GPU device to use.
soft_walkback float 0.1 0 to 0.8 Seconds a line that begins on a vowel or sonorant may start before its first phone. 0 disables it. Since 1.1.0.
unheard_island int 1 0 to 1 Start a line whose first word was not heard on the sound that no word claims before it. 0 disables it. Since 1.1.0.

Notes on the three required options:

  • text_file: a UTF-8 BOM, CRLF line endings and trailing blanks are ignored. A file with no non-blank line fails at start.
  • language: an unknown voice fails at start and names it. The filter never guesses.
  • espeak_data: every platform archive carries espeak-ng-data next to the binary. Missing data fails at start with the path.

With use_gpu=1 the same GPU guard and the NOMERCY_GGML_GPU=0 override apply as for stemsplit. See GPU-Acceleration.

Output: JSON Lines

First comes a header line. Then one line per text line, in text order. Times are in seconds with 3 decimals.

{"model":"wav2vec2-xlsr-53-espeak-cv-ft","language":"en-us","lines":42,"written":39,"mapping_misses":0,"check":"backing"}
{"index":5,"text":"ask not what your country can do for you","start":3.360,"end":7.860,"score":0.740,"lead_in":0.000,"words":[{"text":"ask","start":3.360,"end":4.020,"score":0.870},{"text":"not","start":4.020,"end":5.420,"score":0.810}]}
{"index":6,"text":"...","start":null,"end":null,"score":0,"reason":"disagree","vocals_start":12.340,"check_start":14.020,"words":[]}

Header fields:

Field Meaning
lines Number of text lines.
written Number of lines that were written.
mapping_misses Number of espeak phones that the model's vocabulary does not have. They are dropped, never replaced by <unk>. It is 0 for English and Dutch.
check backing, none (blend=0) or failed (the second alignment found no path).

A skipped line still reports the two candidate starts (vocals_start, check_start), so a review tool can show them.

If the graph ends before the vocals do (an output -t, for example), the audio received so far is aligned and written, with a warning. A destination that cannot be written fails the run.

Skipped lines

reason Meaning
empty The text line is empty (an instrumental marker). It is kept with start:null.
no_phones Nothing of the line maps onto the model's vocabulary, for example punctuation only.
disagree The vocals and the check placed the line more than 0.3 s apart.
first_gap The line's first phone sits more than 0.5 s before its second.
stray_prefix A few unheard first phones were dumped more than 0.8 s early.
check_failed The check alignment had no path at all.
no_alignment The whole track has no path: the text is longer than the audio can hold, or there is no voice. The header says written:0 and the filter still exits 0.

The filter exits non-zero only on bad input: a missing model, an unknown voice, missing espeak data, an unreadable or empty text_file.

The written start

The model fires on a line's first phone a little after the voice begins. So the written start can lie before that phone. lead_in is how far: the first phone is at start + lead_in. words[0].start stays on the phone.

Three rules apply. Each only moves a start earlier. None moves it before the previous line's end plus 0.05 s.

  • After a pause of 1 s or more, and on the first line: the start walks back through the vocal's level to the onset, by at most 0.8 s.
  • A soft first sound (soft_walkback, since 1.1.0). A line that follows another without a pause stays on its first phone. The exception is a vowel or a sonorant (m, n, l, r, j, w and their kin). Those rise slowly. Such a line walks back by at most soft_walkback seconds. Plosives, fricatives and h are left alone.
  • An unheard first word (unheard_island, since 1.1.0). A line has two words or more and its first word scores below 0.01. The model did not hear it. If the vocal has a stretch of sound of 0.3 s or longer (at or above -35 dB) after 0.3 s of quiet (below -45 dB), and it starts more than 0.2 s before the start, looking back 2 s at most, the line starts there. A breath is too short to count.

soft_walkback=0:unheard_island=0 writes every line exactly as v1.0.46 did.

Words

words[] has one entry per whitespace token of the text line. A token that espeak does not speak (-, ...) gets no entry. A token such as 1999 is one entry that covers the several words espeak says ("nineteen ninety nine").

espeak-ng sometimes writes two tokens as one word. For example en-us says "of the" as one word. Since 1.1.0:

  • If the joined word is exactly the two tokens' own phones one after the other, it is cut where the first token ends. Each token gets its own entry.
  • If it sounds different joined than apart ("to be"), the tokens share one entry. Its text holds both, with a space: "text":"to be".
  • A word that neither rule can give to a token keeps an entry with "text":null. Only that word is affected.

A caller that shows words can treat an entry as one unit, whatever its text holds. The line's start, end and score do not depend on this.

Frame metadata

Every forwarded frame carries lavfi.lyricsalign.backend, lavfi.lyricsalign.cpu_variant and lavfi.lyricsalign.version.

Model and assets

Asset Where
wav2vec2-xlsr-53-espeak-cv-ft-f16.gguf, about 630 MB nomercy-lyricsalign-models, release v2026.11.05
espeak-ng-data, every voice, about 18 MB In every platform archive, next to the binary.

The model file is not in a platform archive. Download it:

https://github.com/NoMercy-Entertainment/nomercy-lyricsalign-models/releases/download/v2026.11.05/wav2vec2-xlsr-53-espeak-cv-ft-f16.gguf
sha256 b1474de65e4a966046d390f191af092e718e5e773dcedc5398f31057ee2d38b4

espeak-ng 1.52.0 (GPL-3.0-or-later) is linked statically. See License and Codecs-and-Libraries.

The repository has tools/wav2vec2-gguf. It converts the wav2vec2 checkpoint to GGUF and checks the result. The filter reads the vocabulary and the layer sizes from the file.

Speed

lyricsalign is an offline filter. It has no speed gate. These are measurements, not promises. A run with a real backing makes two model passes.

Machine Input Result
A test CPU 11 s JFK clip, model load included 29.9 s with one thread, 12.4 s with four, per model pass
i7-10700K, Windows build, vocals doubling as backing 11 s JFK clip 15.3 s with threads=0 (four threads), 9.2 s with threads=8
i7-10700K, Windows build 253 s stereo track 304 s and 194 s, about 1.2 and 0.8 times its own length

Accuracy

On a hand-verified reference set (12 tracks, 627 verified written lines), 591 lines (94.3 %) are within 0.2 s of the verified time with 1.1.0. v1.0.46 had 586 (93.5 %). No track got worse.

Since

Version Change
v1.0.46 The filter is new.
v1.0.47 (lyricsalign 1.1.0) soft_walkback and unheard_island for line starts. words[] keeps its texts when espeak-ng joins two tokens.

Clone this wiki locally