Forced Alignment Evaluation Metrics: PCMI and WACS
This repository implements two reference-free forced alignment evaluation metrics from this paper:
- PCMI (Phoneme-Cluster Mutual Information)
- WACS (Word Acoustic Consistency Score)
It also contains CTCAligner, a GPU implementation of CTC-Segmentation whose output plugs directly into the metrics.
Public API
pip install forced-aligner-metrics
Usage
from forced_aligner_metrics import ForcedAlignEval, ForcedAlignEvalConfig
evaluator = ForcedAlignEval(ForcedAlignEvalConfig()) # defaults in the config dataclass
metrics = evaluator.compute_metrics(audios=audios, intervals_iter=intervals_iter)
# metrics["pcmi_score"] with a phones tier, metrics["wacs_score"] with a words tier
audios: iterator of mono numpy arrays sampled at 16 kHzintervals_iter: iterator of interval dicts (either tier optional), each entry{"text": str, "start": float, "end": float}in seconds:
{
"phones": [{"text": "", "start": 0.0, "end": 0.2}, {"text": "h", "start": 0.2, "end": 0.5}, ...],
"words": [{"text": "", "start": 0.0, "end": 0.2}, {"text": "Hi", "start": 0.2, "end": 1.0}, ...],
}
compute_aas gives the Average Accumulated Shift (AAS) scores defined in this paper, in ms, for two alignments in the same interval-dict format (silence spans — empty labels and gaps between adjacent intervals — become <SIL> entries that are scored like any other interval):
from forced_aligner_metrics import compute_aas
aas = compute_aas(gold_intervals, pred_intervals)
# aas["word_aas_ms"], aas["phone_aas_ms"]
GPU CTC aligner
CTCAligner is a GPU implementation of CTC-Segmentation (arXiv:2007.09127). It takes the loaded model and processor, so model-specific loading (language adapters, dtype, ...) stays with the user:
from transformers import AutoModelForCTC, AutoProcessor
from forced_aligner_metrics import CTCAligner, ForcedAlignEval, ForcedAlignEvalConfig
processor = AutoProcessor.from_pretrained("mahesh27/mms-300m-ipa-fleurs")
model = AutoModelForCTC.from_pretrained("mahesh27/mms-300m-ipa-fleurs")
model.load_adapter("te_in") # adapters etc.: load BEFORE passing the model in
aligner = CTCAligner(model, processor, device="cuda")
result = aligner.align(audio, "ellaɾuku namaskaːɾam") # one audio, one IPA transcription string
intervals = result.intervals() # {"phones": [...], "words": [...]} -> ForcedAlignEval input
Batched alignment:
audios = [audio1_16k, audio2_16k]
texts = ["ellaɾuku namaskaːɾam", "sɐrʋeːʂaːm sʋɐsti"] # IPA transcriptions
results = aligner.align_batch(audios, texts, batch_size=8)
intervals_list = aligner.intervals_batch(results) # one intervals dict per result
# optional: pass the orthographic word-segmented text per audio; when its
# words correspond 1:1 to the IPA words, the words tier carries those words
word_segmented = ["ఎల్లరుకు నమస్కారం", "సర్వేషాం స్వస్తి"]
results = aligner.align_batch(audios, texts, word_texts=word_segmented, batch_size=8)
intervals_list = aligner.intervals_batch(results)
Silence trimming is optional — off by default; it runs at align time (batched) and the trimmed intervals are stored on every result:
aligner = CTCAligner(model, processor, device="cuda", trim_silence=True)
results = aligner.align_batch(audios, texts, batch_size=8)
intervals_list = aligner.intervals_batch(results) # trimmed; result.segments trimmed too
Performance Benchmarks
PCMI/WACS computed with mms-300m embeddings on GPU; AAS = absolute boundary deviation vs gold (ms). -SIL = silence-trimmed (trim_silence=True).
FLEURS (85 languages):
| Model | PCMI (mms) | WACS (mms) |
|---|---|---|
| mfa (83/85 langs) | 0.247 ± 0.106 | 0.143 ± 0.078 (82/85) |
| mms-300m-ipa (v0.1.0) | 0.248 ± 0.030 | 0.194 ± 0.023 |
| mms-300m-ipa-FAM (v2.1.0) | 0.370 ± 0.032 | 0.219 ± 0.025 |
| mms-300m-ipa-FAM-SIL (v2.1.0) | 0.382 ± 0.033 | 0.224 ± 0.026 |
DORECO (45 langauges):
| Model | PCMI (mms) | WACS (mms) | Phone AAS (ms) | Word AAS (ms) |
|---|---|---|---|---|
| gold_doreco | 0.334 ± 0.040 | 0.131 ± 0.029 | 0.0 ± 0.0 (self) | 0.0 ± 0.0 (self) |
| mms-300m-ipa-doreco (v0.1.0) | 0.207 ± 0.033 | 0.112 ± 0.024 | 89.4 ± 34.6 | 114.5 ± 51.9 |
| mms-300m-ipa-doreco-SIL (v0.1.0) | 0.203 ± 0.033 | 0.114 ± 0.026 | 88.1 ± 32.6 | 106.5 ± 44.1 |
| mms-300m-ipa-doreco-FAM (v2.1.0) | 0.309 ± 0.037 | 0.124 ± 0.024 | 59.0 ± 34.0 | 87.4 ± 42.0 |
| mms-300m-ipa-doreco-FAM-SIL (v2.1.0) | 0.317 ± 0.038 | 0.129 ± 0.026 | 57.5 ± 34.0 | 80.3 ± 36.1 |
With v2.1.0, -FAM-SIL gives the best PCMI/WACS and also the lowest AAS on DORECO. On FLEURS, -FAM-SIL beats MFA in 71/82 languages in both PCMI and WACS.
Installation for development
git clone https://github.com/mahesh-ak/forced-aligner-metrics.git
cd forced-aligner-metrics
python -m pip install -e '.[test]'
Tests
python -m pytest
tests/test_aligner_vs_reference.py aligns the FLEURS de_de test split and the DORECO anal1239 validation split with CTCAligner and checks the output against external reference alignments (MFA TextGrids in tests/data/alignments/mfa/de_de, DORECO parquet in tests/data/alignments/doreco/anal1239): the phone and word symbol sequences must match exactly at the tokenizer's granularity (spn ignored, <unk> excused); timestamps are scored with compute_aas on DORECO only (mean AAS < 60 ms). MFA_REF_ITEMS=<n> / DORECO_REF_ITEMS=<n> limit the item counts. GPU + dataset required (-m integration). tests/test_aas.py unit-tests compute_aas (self-comparison on DORECO is exactly 0.0/0.0).
Version Release Notes
- v2.1.0:
CTCAligneraligns the model tokenizer's token ids, not characters — each word is tokenized withprocessor.tokenizer(multi-character vocab symbols such as affricates stay single tokens; symbols unknown to the vocab map to<unk>), and the word delimiter is taken only fromtokenizer.word_delimiter_token. New shipped metriccompute_aas(gold, pred)giving the Average Accumulated Shift (AAS) scores.tests/test_aligner_vs_reference.pynow regression-tests against external references only (MFA TextGrids for FLEURSde_de, DORECOanal1239validation): exact phone/word sequence match (spnignored,<unk>excused), timing scored viacompute_aason DORECO only. - v2.0.0:
CTCAlignertakes a loaded CTC model + processor instead of a model id. - v1.1.1: silence trimming runs at align time and is stored on every result (
result.trimmed_intervals,result.segments); opt-in, off by default. Word-boundary symbol auto-detection incl.#-style tokenizers. - v1.1.0: GPU silence-trimming pipeline for
CTCAlignerinterval outputs. - v1.0.0: all evaluation kernels (DTW, k-means, NMI, cosine) as batched GPU operations; added the GPU CTC aligner.
- v0.1.0: initial release.
Citation
@inproceedings{akavarapu-etal-2026-phoneme,
title = "Phoneme- and Word-Level Metrics Using Self-Supervised Speech Representations for Forced Alignment Evaluation",
author = "Akavarapu, V.S.D.S.Mahesh and
Daniel, Michael and
J{\"a}ger, Gerhard",
editor = "Lee, Hung-Yi and
Dev, Sunipa and
Li, Jessy and
Elliott, Desmond",
booktitle = "Findings of the {A}ssociation for {C}omputational {L}inguistics: EMNLP 2026",
month = oct,
year = "2026",
address = "Budapest, Hungary",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2026.findings-emnlp.279/",
pages = "5865--5892",
ISBN = "979-8-89176-462-0",
}
Metadata
Release files for forced-aligner-metrics 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| forced_aligner_metrics-2.1.0.tar.gz | 35.9 MB | Without provenance | Details for forced_aligner_metrics-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| forced_aligner_metrics-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for forced_aligner_metrics-2.1.0-py3-none-any.whl |
Total release size: 35.9 MB
Release files / forced_aligner_metrics-2.1.0.tar.gz
| Download URL | forced_aligner_metrics-2.1.0.tar.gz |
|---|---|
| Size | 35.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
799c1f241a933f6ca0106fdd2561e3b8184c872e2e90ecd210951dcff1adc279
|
|
BLAKE2b-256 checksum How to use checksums |
3ee6a6cd0dd4078aef9a3f51fabc1455595961169b7dc3746ace0f746a69a9b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Release files / forced_aligner_metrics-2.1.0-py3-none-any.whl
| Download URL | forced_aligner_metrics-2.1.0-py3-none-any.whl |
|---|---|
| Size | 37.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d040829af458d1012a6609e309c578e50e154695663406eef306e3633234fde8
|
|
BLAKE2b-256 checksum How to use checksums |
8626d76683efda67a5f4f3505bc50097dd6c932dad4e9ab48bf01397eca80e56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Security for forced-aligner-metrics 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.