From 00e116a3e546074961ca189c789ef461fe455d53 Mon Sep 17 00:00:00 2001 From: tabahi Date: Sun, 29 Nov 2026 12:09:44 +0000 Subject: [PATCH] aligners: BFA 2.1.0, on CUPE-3-en BFA 2.0.0 replaced the 1.x CUPE-2 + CTC aligner with new acoustic models at 5 ms frames and a segmental Viterbi decoder, and renamed PhonemeTimestampAligner to BFA, so the 1.1.5 worker no longer imports. - Pin bournemouth-forced-aligner[ph66]==2.1.0. The ph66 extra brings phonemizer, which CUPE-3-en's espeak-ng G2P needs. The cu128 torch re-pin stays, so the env still runs on a CUDA 12.9 driver. - worker.py uses the 2.x API and takes the model by name. The board row runs CUPE-3-en, BFA's English model. exps/mbfa_latin, off the board, runs the model the en-us preset picks on its own. - 2.1.0 fills gaps the transcript does not cover with SIL/noise entries marked inserted. `nonspeech: drop` (default) removes them, which leaves the transcript's phones plus punctuation SIL. `sil` keeps them as SIL. The two were compared on the dev lists, which disagree: sil has better PER and phone F1 on TIMIT dev, drop on Buckeye dev. Word scores are equal. drop is the author's choice, and BFA's own evaluation does not score inserted entries either. The config comment has the numbers. - requirements.lock regenerated from the env the install script builds. - CHANGELOG entry under Unreleased. --- CHANGELOG.md | 9 ++ evals/aligners/bfa/config.yaml | 13 +- evals/aligners/bfa/download_and_install.sh | 8 +- .../aligners/bfa/exps/mbfa_latin/config.yaml | 16 +++ evals/aligners/bfa/requirements.lock | 135 ++++++++++-------- evals/aligners/bfa/worker.py | 35 ++++- fabench/aligners/bfa/README.md | 23 ++- fabench/aligners/bfa/adapter.py | 15 +- 8 files changed, 172 insertions(+), 82 deletions(-) create mode 100644 evals/aligners/bfa/exps/mbfa_latin/config.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d1c093..78aa3e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,15 @@ be compared only when no such change lies between them. ### Changed +- **BFA moves from 1.1.5 to 2.1.0, and its rows move with it.** 2.0.0 + replaced BFA's acoustic models and decoder, so these are new measurements, + not a rescore. The `bfa` row runs CUPE-3-en, BFA's English model. A recipe + off the board, `evals/aligners/bfa/exps/mbfa_latin/`, runs mbfa-latin, the + model the `en-us` preset picks when no model is named. The + worker uses the 2.x API, takes the model by name, and drops the SIL and + noise entries 2.1.0 inserts over gaps the transcript does not cover + (`nonspeech: drop`; `sil` keeps them as SIL). The `bfa_on_qwen3asr` + recipe is unchanged, and its row is not re-run here. No other row moves. - Olign's dashboard moved to dashboard.olewave.com, and the sign-up links in the README and the Olign adapter's README point there. That README also names Olewave's Python client, `pip install olign`. The `olign_v1` adapter's diff --git a/evals/aligners/bfa/config.yaml b/evals/aligners/bfa/config.yaml index 49fb4bb..ddb99f3 100644 --- a/evals/aligners/bfa/config.yaml +++ b/evals/aligners/bfa/config.yaml @@ -1,4 +1,5 @@ -# BFA -- Bournemouth Forced Aligner (CUPE + CTC). Models auto-download from HF. +# BFA -- Bournemouth Forced Aligner 2.1.0 on CUPE-3-en (ph66, espeak-ng G2P, +# segmental Viterbi). Models auto-download from HF. name: bfa adapter: bfa enabled: true @@ -10,5 +11,15 @@ params: # worker runs there instead of importing torch from the shared .venv. venv: repo/env preset: en-us + # The en-us preset alone picks mbfa-latin (std set); CUPE-3-en is BFA's + # English-only model. exps/mbfa_latin/ runs the preset's default. + model: CUPE-3-en + # 2.1.0's inserted SIL/noise gap fill: drop | sil. See worker.py. + # Compared on the clean dev lists only, phone MAE ms / PER % / phone F1: + # TIMIT dev drop 19.2 / 34.3 / 0.352 sil 20.1 / 28.8 / 0.422 + # Buckeye dev drop 24.8 / 30.6 / 0.435 sil 24.7 / 36.6 / 0.405 + # The lists disagree on PER and F1, and the word scores are equal. drop is + # the author's choice. BFA's own evaluation does not score these entries. + nonspeech: drop python: repo/env/bin/python device: cuda diff --git a/evals/aligners/bfa/download_and_install.sh b/evals/aligners/bfa/download_and_install.sh index c110d0a..d6610e2 100755 --- a/evals/aligners/bfa/download_and_install.sh +++ b/evals/aligners/bfa/download_and_install.sh @@ -5,6 +5,8 @@ # BFA -- self-contained under evals/bfa/repo/ # repo/env/ venv; pip package `bournemouth-forced-aligner`, # imports as `bournemouth_aligner`. Models auto-download from HF. +# The [ph66] extra brings phonemizer, which CUPE-3-en (ph66, +# espeak-ng G2P) needs; the std/mbfa models use a vendored G2P. set -euo pipefail HERE=$(cd "$(dirname "$0")" && pwd) REPO=$HERE/repo; mkdir -p "$REPO" @@ -14,8 +16,8 @@ REPO=$HERE/repo; mkdir -p "$REPO" # table in results/README.md). Bumping it is a deliberate act: change the # pin, re-run the sweep, regenerate provenance -- never let a fresh install # silently measure a different release. -"$REPO/env/bin/pip" install -q bournemouth-forced-aligner==1.1.5 -# torch arrives TRANSITIVELY here and resolves to 2.13.0+cu130 from PyPI, +"$REPO/env/bin/pip" install -q "bournemouth-forced-aligner[ph66]==2.1.0" +# torch arrives TRANSITIVELY here and resolves to a cu13x build from PyPI, # which does not work against this box's CUDA 12.9 driver -- # torch.cuda.is_available() returns False and the aligner silently runs on # CPU. Re-pin it to the cu128 index afterwards; measured 2.8.0+cu128 gives @@ -30,5 +32,5 @@ REPO=$HERE/repo; mkdir -p "$REPO" "$REPO/env/bin/pip" install -q --force-reinstall --index-url https://download.pytorch.org/whl/cu128 \ torch==2.8.0 torchaudio==2.8.0 "$REPO/env/bin/python" -c " -from bournemouth_aligner import PhonemeTimestampAligner +from bournemouth_aligner import BFA import bournemouth_aligner as m; print(' bournemouth_aligner', getattr(m,'__version__','?'))" diff --git a/evals/aligners/bfa/exps/mbfa_latin/config.yaml b/evals/aligners/bfa/exps/mbfa_latin/config.yaml new file mode 100644 index 0000000..37ea24b --- /dev/null +++ b/evals/aligners/bfa/exps/mbfa_latin/config.yaml @@ -0,0 +1,16 @@ +# BFA 2.1.0 on mbfa-latin, the model the en-us preset picks by default (std +# phoneme set, ByT5 G2P, one model for the Latin-script languages). It says +# what a user who only sets the language gets. This recipe is off the board, +# which keeps one row per system: CUPE-3-en, in ../../config.yaml. +name: bfa_mbfa_latin +adapter: bfa +enabled: true +modes: [A] +granularity: [phone] +params: + venv: ../../repo/env + preset: en-us + model: mbfa-latin + nonspeech: drop + python: ../../repo/env/bin/python + device: cuda diff --git a/evals/aligners/bfa/requirements.lock b/evals/aligners/bfa/requirements.lock index 22c26e7..9d8b9c2 100644 --- a/evals/aligners/bfa/requirements.lock +++ b/evals/aligners/bfa/requirements.lock @@ -1,92 +1,107 @@ -anyio==4.14.2 +annotated-doc==0.0.7 +annotated-types==0.8.0 +anyio==4.16.0 attrs==26.1.0 -audioread==3.1.0 -bournemouth-forced-aligner==1.1.5 -certifi==2026.7.22 +bournemouth-forced-aligner==2.1.0 +certifi==2026.11.20 cffi==2.1.1 -charset-normalizer==3.4.9 -click==8.4.2 -contourpy==1.3.3 -cuda-bindings==13.3.1 -cuda-pathfinder==1.6.0 -cuda-toolkit==13.0.3.0 +charset-normalizer==3.5.3 +click==8.5.1 +cloudpickle==3.1.3 +contourpy==1.4.0 +cuda-bindings==13.5.0 +cuda-pathfinder==1.9.1 +cuda-toolkit==13.2.2 cycler==0.12.1 -decorator==5.3.1 +decorator==5.3.2 dlinfo==2.0.0 -filelock==3.32.2 -fonttools==4.63.0 -fsspec==2026.7.0 +filelock==4.2.4 +fonttools==4.69.1 +fsspec==2026.9.0 h11==0.16.0 -hf-xet==1.6.0 -httpcore==1.0.9 -httpx==0.28.1 -huggingface_hub==1.27.0 -idna==3.18 +hf-xet==1.8.0 +httpcore2==2.16.2 +httpx2==2.16.2 +huggingface_hub==2.5.0 +idna==3.20 Jinja2==3.1.6 -joblib==1.5.3 -kiwisolver==1.5.0 -lazy-loader==0.5 -librosa==0.11.0 -llvmlite==0.48.0 +joblib==1.6.0 +kiwisolver==1.5.1 +lazy-loader==0.6 +librosa==1.0.1 +llvmlite==0.50.0 +markdown-it-py==4.3.0 MarkupSafe==3.0.3 -matplotlib==3.11.1 +matplotlib==3.11.2 +mdurl==0.1.2 mpmath==1.3.0 -msgpack==1.2.1 -narwhals==2.24.0 -networkx==3.6.1 -numba==0.66.0 -numpy==2.4.6 -nvidia-cublas==13.1.1.3 +msgpack==1.2.4 +narwhals==2.29.0 +networkx==3.7 +numba==0.68.1 +numpy==2.5.5 nvidia-cublas-cu12==12.8.4.1 -nvidia-cuda-cupti==13.0.85 +nvidia-cublas==13.4.1.3 +nvidia-cuda-cccl==13.3.5.0.6 nvidia-cuda-cupti-cu12==12.8.90 -nvidia-cuda-nvrtc==13.0.88 +nvidia-cuda-cupti==13.2.86 nvidia-cuda-nvrtc-cu12==12.8.93 -nvidia-cuda-runtime==13.0.96 +nvidia-cuda-nvrtc==13.2.86 nvidia-cuda-runtime-cu12==12.8.90 +nvidia-cuda-runtime==13.2.86 nvidia-cudnn-cu12==9.10.2.21 -nvidia-cudnn-cu13==9.20.0.48 -nvidia-cufft==12.0.0.61 +nvidia-cudnn-cu13==9.26.0.51 nvidia-cufft-cu12==11.3.3.83 -nvidia-cufile==1.15.1.6 +nvidia-cufft==12.2.0.57 nvidia-cufile-cu12==1.13.1.3 -nvidia-curand==10.4.0.35 +nvidia-cufile==1.17.1.22 nvidia-curand-cu12==10.3.9.90 -nvidia-cusolver==12.0.4.66 nvidia-cusolver-cu12==11.7.3.90 -nvidia-cusparse==12.6.3.3 +nvidia-cusolver==12.2.0.11 nvidia-cusparse-cu12==12.5.8.93 +nvidia-cusparse==12.7.10.12 nvidia-cusparselt-cu12==0.7.1 nvidia-cusparselt-cu13==0.8.1 nvidia-nccl-cu12==2.27.3 -nvidia-nccl-cu13==2.29.7 -nvidia-nvjitlink==13.3.33 +nvidia-nccl-cu13==2.30.7 nvidia-nvjitlink-cu12==12.8.93 -nvidia-nvshmem-cu13==3.4.5 -nvidia-nvtx==13.0.85 +nvidia-nvjitlink==13.5.37 +nvidia-nvshmem-cu13==3.7.2 nvidia-nvtx-cu12==12.8.90 -packaging==26.3 -phonemizer==3.4.0 -pillow==12.3.0 -platformdirs==4.11.1 +nvidia-nvtx==13.2.86 +packaging==26.4 +phonemizer==3.6.0 +pillow==13.0.0 +platformdirs==4.14.9 pooch==1.9.0 -pycparser==3.0 -pyparsing==3.3.2 -python-dateutil==2.9.0.post0 -PyYAML==6.0.3 +pycparser==3.12 +pydantic==2.14.4 +pydantic_core==2.50.5 +Pygments==2.21.0 +pyparsing==3.3.3 +python-dateutil==4.0.0 +PyYAML==6.0.4 +regex==2026.11.25 requests==2.34.2 -scikit-learn==1.9.0 -scipy==1.18.0 -setuptools==84.0.0 -six==1.17.0 +rich==15.0.0 +safetensors==0.8.0 +scikit-learn==1.9.1 +scipy==1.18.1 +setuptools==78.1.0 +shellingham==1.5.4 soundfile==0.14.0 soxr==1.1.0 sympy==1.14.0 -threadpoolctl==3.6.0 +threadpoolctl==3.8.0 +tokenizers==0.23.3 torch==2.8.0+cu128 torchaudio==2.8.0+cu128 -torchcodec==0.15.0 -tqdm==4.70.0 +tqdm==4.70.1 +transformers==5.24.1 triton==3.4.0 +truststore==0.10.5 +typer==0.29.3 +typing-inspection==0.4.5 typing_extensions==4.16.0 -urllib3==2.7.0 +tzdata==2026.6 +urllib3==2.8.0 diff --git a/evals/aligners/bfa/worker.py b/evals/aligners/bfa/worker.py index 7f7e26d..c80579d 100755 --- a/evals/aligners/bfa/worker.py +++ b/evals/aligners/bfa/worker.py @@ -2,17 +2,29 @@ # Copyright 2026 Olewave, LLC # SPDX-License-Identifier: Apache-2.0 -"""BFA (Bournemouth Forced Aligner) in its OWN interpreter. +"""BFA (Bournemouth Forced Aligner) 2.x in its OWN interpreter. Protocol (fabench/aligners/subprocess_aligner.py): in : {"item_id":…, "audio_path":…, "transcript":…} out: {"item_id":…, "words":[[t,s,e,conf],…], "phones":[[t,s,e,conf],…]} -Mode A only: BFA is text-driven, phonemizing the transcript with espeak itself, -so there is no phone_seq to supply. Phone labels are eSpeak IPA -- the adapter -declares `source = "ipa"` so the scorer canonicalizes them through the right -table. + argv: worker.py [] + +Mode A only: BFA is text-driven and phonemizes the transcript itself (espeak-ng +for the ph66 models such as CUPE-3-en, a ByT5 G2P for the std/mbfa models), so +there is no phone_seq to supply. Phone labels are IPA -- the adapter declares +`source = "ipa"` so the scorer canonicalizes them through that table. + +`model` is a BFA model name (CUPE-3-en, mbfa-latin, ...); "-" takes the one the +preset picks. 2.x defaults the en-us preset to the std set on mbfa-latin. + +`nonspeech` decides what happens to the entries 2.1.0 adds to cover gaps the +text does not (clip edges, pauses between words). They are marked +`inserted: true`, belong to no word and are labelled SIL or noise from the +audio's energy. "drop" (default) removes them, leaving every phone of the +transcript plus the SIL the transcript's punctuation asked for, as 2.0 gave. +"sil" keeps them, all labelled SIL. BFA's own evaluation scores neither kind. The model is loaded ONCE for the batch. """ @@ -41,11 +53,15 @@ def load_resample(path: str, target_sr: int): def main(argv: list[str]) -> int: jobs_path = argv[0] + model = argv[1] if len(argv) > 1 and argv[1] not in ("-", "") else None preset = argv[2] if len(argv) > 2 and argv[2] != "-" else "en-us" device = argv[3] if len(argv) > 3 else "cuda" + nonspeech = argv[4] if len(argv) > 4 else "drop" + if nonspeech not in ("drop", "sil"): + raise SystemExit(f"bfa worker: nonspeech must be drop or sil, got {nonspeech!r}") import torch - from bournemouth_aligner import PhonemeTimestampAligner + from bournemouth_aligner import BFA # `device.startswith` and NOT `device == "cuda"`. The cell runners pin a # card by passing "cuda:0" with CUDA_VISIBLE_DEVICES set, and an exact @@ -54,7 +70,8 @@ def main(argv: list[str]) -> int: # cells took 90 minutes on 32 cores while three Blackwells sat at 0%. device = device if (device.startswith("cuda") and torch.cuda.is_available()) else "cpu" - al = PhonemeTimestampAligner(preset=preset, device=device) + # warn_level=0: BFA prints nothing, so stdout carries only the records. + al = BFA(preset=preset, model_name=model, device=device, warn_level=0) sr = al.sample_rate with open(jobs_path) as f: @@ -73,6 +90,10 @@ def main(argv: list[str]) -> int: for seg in out.get("segments", []): for p in seg.get("phoneme_ts", []): lab = p.get("ipa_label", p.get("phoneme_label", "")) + if p.get("inserted"): + if nonspeech == "drop": + continue + lab = "SIL" s = min(max(p["start_ms"] / 1000.0, 0.0), dur) e = min(max(p["end_ms"] / 1000.0, s), dur) phones.append([lab, s, e, p.get("confidence")]) diff --git a/fabench/aligners/bfa/README.md b/fabench/aligners/bfa/README.md index 19c44ff..69eef55 100644 --- a/fabench/aligners/bfa/README.md +++ b/fabench/aligners/bfa/README.md @@ -1,10 +1,13 @@ # BFA aligner -Bournemouth Forced Aligner, a neural aligner (CUPE + CTC). It is text-driven, -through espeak G2P to IPA phones, and it is one of the MFA-2026 paper's Table -5 baselines. +Bournemouth Forced Aligner, a neural aligner. From 2.0.0 it runs CUPE-3 / mbfa +acoustic models at 5 ms frames with a segmental Viterbi decoder; 1.x was +CUPE-2 + CTC. It is text-driven and phonemizes the transcript itself, with +espeak-ng for the ph66 models and a ByT5 G2P for the std ones. It is one of +the MFA-2026 paper's Table 5 baselines. - **Modes.** A. **Granularity.** Word and phone. **Confidence.** Yes. +- **Version.** 2.1.0, pinned in `evals/aligners/bfa/download_and_install.sh`. ## Install @@ -20,7 +23,17 @@ evals/aligners/bfa/download_and_install.sh # its own environment, pinned enabled: true modes: [A] granularity: [word, phone] - params: { preset: en-us, device: cuda } + params: { preset: en-us, model: CUPE-3-en, nonspeech: drop, device: cuda } ``` -Phones are IPA, so the normalization source is `ipa`. +- `model` is a BFA model name. `CUPE-3-en` is the English-only ph66 model and + the board row. Leaving it out takes the preset's model, which for `en-us` is + `mbfa-latin` (std set). `evals/aligners/bfa/exps/mbfa_latin/` runs that one + as `bfa_mbfa_latin`, off the board. +- `nonspeech` handles the entries 2.1.0 inserts over gaps the transcript does + not cover (clip edges, pauses between words), labelled `SIL` or `noise` and + marked `inserted: true`. `drop` (default) removes them; `sil` keeps them, + all as `SIL`. + +Phones are IPA, so the normalization source is `ipa`. The `-` that espeak +emits between words is deleted by that table. diff --git a/fabench/aligners/bfa/adapter.py b/fabench/aligners/bfa/adapter.py index 1285475..5107ba1 100644 --- a/fabench/aligners/bfa/adapter.py +++ b/fabench/aligners/bfa/adapter.py @@ -3,9 +3,11 @@ """BFA — Bournemouth Forced Aligner (Rehman et al. 2025, arXiv:2509.23147). -Neural CUPE + CTC aligner: given a transcript it phonemizes with espeak and -places per-phone onset/offset boundaries with confidence (and word timings). -Phone labels are eSpeak IPA -> canonical via the `ipa` normalization source. +Neural aligner (2.x: CUPE-3 / mbfa acoustic models at 5 ms frames and a +segmental Viterbi decoder): given a transcript it phonemizes it (espeak-ng for +ph66 models, a ByT5 G2P for std ones) and places per-phone onset/offset +boundaries with confidence (and word timings). Phone labels are IPA -> +canonical via the `ipa` normalization source. Mode A (from text) only: BFA drives itself from the transcript's G2P. @@ -24,9 +26,10 @@ class BFA(SubprocessAligner): source = "ipa" emits_confidence = True granularity = ("word", "phone") - default_model = "en-us" # BFA calls it a preset + default_model = "-" # "-" = the model the preset picks def _extra_argv(self) -> list[str]: - """worker.py .""" + """worker.py .""" return [str(self.params.get("preset", "en-us")), - str(self.params.get("device", "cuda"))] + str(self.params.get("device", "cuda")), + str(self.params.get("nonspeech", "drop"))]