Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 66 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@ scriptrs = { version = "0.5", features = ["vad"] }
`TranscriptionError::Control(TranscriptionControlError::Cancelled)` instead of
`TranscriptionError::Cancelled`, and likewise for the other two.
- `VadConfig` is gone. The speech threshold is now
`VadSegmentationConfig::threshold`, still 0.5 by default: set
`config.segmentation.threshold` instead of `config.vad.default_threshold`.
`VadSegmentationConfig::threshold`: set `config.segmentation.threshold`
instead of `config.vad.default_threshold`.
- VAD mode defaults to Silero fusion (`VadModel::SileroFusion`): it scores each
window with both Silero VAD v5 and v6 and keeps the higher probability, at a 0.6 threshold, in place of v5 alone at 0.5. Set
`config.segmentation = VadSegmentationConfig::for_model(VadModel::SileroV5)`
to keep v5-only planning. `VadSegmentationConfig` has a new `model` field, so
struct literals that list every field need it. VAD bundles need both models
(see [Local model layout](#local-model-layout)), and
`ModelBundle::validate_long_form` checks for both.
- `Vocabulary` loads only through a deployment, with
`Vocabulary::load(path, &deployment)` or
`Vocabulary::from_bytes(bytes, &deployment)`. `load` takes the deployment in
Expand Down Expand Up @@ -132,15 +139,16 @@ With the default `online` feature, `scriptrs` can resolve models automatically:
- native CUDA weights come from
[`avencera/parakeet-tdt-0.6b-v2-cuda`](https://huggingface.co/avencera/parakeet-tdt-0.6b-v2-cuda)
and [`avencera/parakeet-tdt-0.6b-v3-cuda`](https://huggingface.co/avencera/parakeet-tdt-0.6b-v3-cuda),
and the native Silero VAD from
and the native Silero VAD models from
[`avencera/silero-vad-v5-safetensors`](https://huggingface.co/avencera/silero-vad-v5-safetensors)
and [`avencera/silero-vad-v6-safetensors`](https://huggingface.co/avencera/silero-vad-v6-safetensors)

You can force a local bundle when needed:

- `SCRIPTRS_MODELS_DIR=/path/to/models` forces a local bundle

Each download uses an immutable snapshot pinned in the release, such as
`63f6f9cbce43e5561c219229896f86f20c0eb660` of `avencera/scriptrs-models`.
`54f3f976b63bf5d5fe9927363d259cffa1c23a89` of `avencera/scriptrs-models`.

## Local model layout

Expand All @@ -162,12 +170,13 @@ models/

Use `ParakeetDeployment::v2()` or `ParakeetDeployment::v3()` to select a layout. v2 remains the default for `from_dir` and `from_pretrained`.

With `vad`, add:
With `vad`, add both Silero VAD models:

```text
models/
vad/
silero-vad.mlmodelc/
silero-vad.mlmodelc/ # Silero VAD 5.1.2
silero-vad-v6.mlmodelc/ # Silero VAD 6.2.3
```


Expand All @@ -193,7 +202,8 @@ let result = pipeline.run(&audio)?;

With `vad`, `from_pretrained_native_long_form` also downloads the Silero VAD
weights from
[`avencera/silero-vad-v5-safetensors`](https://huggingface.co/avencera/silero-vad-v5-safetensors).
[`avencera/silero-vad-v5-safetensors`](https://huggingface.co/avencera/silero-vad-v5-safetensors)
and [`avencera/silero-vad-v6-safetensors`](https://huggingface.co/avencera/silero-vad-v6-safetensors).
To manage the files yourself, `dev-tools/nemo/export_native.py` writes
them from the NeMo checkpoints in this layout, and `from_native_dir` loads them:

Expand All @@ -207,6 +217,7 @@ models/
parakeet_vocab.json
vad/
silero-vad-v5.safetensors # with `vad`
silero-vad-v6.safetensors # with `vad`
```

```rust,ignore
Expand Down Expand Up @@ -279,27 +290,49 @@ normalizer. Speed is x real time for transcription alone on one RTX 5090, with
models loaded and audio in memory; WhisperX runs its VAD with batch size 16. The
last row's speed is over all 114 hours.

With `vad`, Silero VAD v5 runs on the CPU, at about 0.3 s per hour of audio. On a
GPU each step of its recurrence costs more in launches than the whole step costs on
the CPU. VAD planning helps when most of a recording is not speech, and costs
accuracy and speed on dense or far-field speech:
With `vad`, Silero VAD runs on the CPU, at about 0.5 s per hour of audio. On a GPU
each step of its recurrence costs more in launches than the whole step costs on the
CPU. The scan runs alongside transcription: each speech region goes to the model as
soon as the scan has passed it, and the transcript is the same as scanning first.
VAD planning wins when most of a recording is not speech, and helps a little on
close-talk speech, but costs accuracy on far-field speech and runs at about two
thirds of overlap speed on recordings that are mostly speech:

| Set | Overlap WER | VAD WER | Overlap speed | VAD speed |
|---|---:|---:|---:|---:|
| Sparse speech, 24 % speech (4.2 h) | 14.8 % | **2.3 %** | 3430x | **3990x** |
| Earnings-21 earnings calls | **8.2 %** | 8.4 % | **3630x** | 2030x |
| AMI meetings, headset mix | 21.5 % | **21.1 %** | **3480x** | 1800x |
| AMI meetings, far-field microphone | **23.2 %** | 26.0 % | **3480x** | 1790x |
| CHiME-6 dinner parties | **44.0 %** | 54.0 % | **3490x** | 1970x |
| Sparse speech, 24 % speech (4.2 h) | 14.8 % | **2.3 %** | 3906x | **4509x** |
| Earnings-21 earnings calls | 8.2 % | **8.0 %** | **4049x** | 2994x |
| AMI meetings, headset mix | 21.5 % | **20.8 %** | **3946x** | 2589x |
| AMI meetings, far-field microphone | **23.2 %** | 25.3 % | **3940x** | 2485x |
| CHiME-6 dinner parties | **44.0 %** | 53.4 % | **3994x** | 2918x |

The sparse set is LibriSpeech test-clean utterances separated by 15 to 75 s of
film music, effects, ambience and low-level noise. VAD runs use the default 0.5
speech threshold and pad each speech region by 0.2 s on both sides, including both
sides of a split inside a region longer than the model window. Silero is slow to
react to a soft first word, such as the "a" in "a cold", and 0.1 s of padding cut
it off. 0.2 s lowered WER on every set; larger padding cost AMI headset accuracy.
The speed columns were measured with 0.1 s padding; in the padding sweep, 0.2 s
was no slower.
film music, effects, ambience and low-level noise. Speeds are the best of two or
three runs.

The default, Silero fusion, takes each window's speech probability as the higher
of Silero VAD v5's and v6's, and windows at 0.6 or above count as speech. Either
model alone misses speech the other finds: v6 separates speech from non-speech
better on most audio but misses more of the sparse set's speech at its threshold,
and v5 holds up better on noisy dinner-party audio. Taking the higher probability
scores at or below v5 alone on every set, and the 0.6 threshold keeps the sparse
set at v5's error rate (it rises to 2.8 % at 0.5). Running both models adds about
6 % to the scan's CPU time. VAD WER by model, each alone at its default 0.5
threshold:

| Set | v5 | v6 | Silero fusion (default) |
|---|---:|---:|---:|
| Sparse speech | **2.3 %** | 3.0 % | **2.3 %** |
| Earnings-21 earnings calls | 8.4 % | **8.0 %** | **8.0 %** |
| AMI meetings, headset mix | 21.1 % | **20.7 %** | 20.8 % |
| AMI meetings, far-field microphone | 26.0 % | 25.6 % | **25.3 %** |
| CHiME-6 dinner parties | 54.0 % | 61.9 % | **53.4 %** |

Each speech region is padded by 0.2 s on both sides, including both sides of a
split inside a region longer than the model window. Silero is slow to react to a
soft first word, such as the "a" in "a cold", and 0.1 s of padding cut it off. In
a padding sweep with v5, 0.2 s lowered WER on every set; larger padding cost AMI
headset accuracy.

By default the encoder layers' linear weights are stored in FP16, which has TF32's
10-bit mantissa, and their matrix multiplies run on FP16 tensor cores with FP32
Expand Down Expand Up @@ -436,7 +469,7 @@ fn load_mono_16khz_audio() -> Vec<f32> {
}
```

Enable `vad` when you want VAD-backed speech region planning for sparse speech, long silences, or recordings with a lot of non-speech audio. Windows with a speech probability of at least `config.segmentation.threshold` (0.5 by default) count as speech:
Enable `vad` when you want VAD-backed speech region planning for sparse speech, long silences, or recordings with a lot of non-speech audio. Windows with a speech probability of at least `config.segmentation.threshold` count as speech. By default that is Silero fusion, the higher of Silero VAD v5's and v6's probabilities, with a 0.6 threshold:

```rust
use scriptrs::{LongFormConfig, LongFormMode, LongFormTranscriptionPipeline};
Expand All @@ -459,6 +492,14 @@ fn load_mono_16khz_audio() -> Vec<f32> {
}
```

`VadSegmentationConfig::for_model` runs one model instead, with that model's default threshold, 0.5 for either alone:

```rust,ignore
use scriptrs::{VadModel, VadSegmentationConfig};

config.segmentation = VadSegmentationConfig::for_model(VadModel::SileroV5);
```

### Streaming (CUDA)

`StreamingModel` runs NVIDIA's cache-aware [Nemotron Speech Streaming EN
Expand Down Expand Up @@ -692,7 +733,7 @@ The example expects mono 16kHz WAV input.
- The public API is still moving
- `scriptrs` currently targets the exact file layout and model I/O shipped in `avencera/scriptrs-models`; if you swap in a different CoreML Parakeet export, you may need runtime code changes
- Use `long-form` for the fastest path on clean, dense speech
- Add `vad` when you need better robustness on sparse-speech or non-speech-heavy recordings; on dense or far-field speech it costs accuracy
- Add `vad` when you need better robustness on sparse-speech or non-speech-heavy recordings; on far-field speech it costs accuracy, and on dense speech about a third of the speed

## License

Expand Down
7 changes: 4 additions & 3 deletions crates/scriptrs-python/python/scriptrs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ def from_pretrained(
``~/.cache/huggingface/hub``; later calls load from the cache. Setting
``SCRIPTRS_MODELS_DIR`` loads a local directory instead, as
:meth:`from_dir` does.
With ``vad``, the Silero VAD model is downloaded too, and long recordings
are split at detected speech instead of at fixed intervals, which helps
when most of a recording is silence or noise.
With ``vad``, the Silero VAD v5 and v6 models are downloaded too, and long
recordings are split at speech instead of at fixed intervals, which helps
when most of a recording is silence or noise. Each window counts as speech
when the higher of its v5 and v6 speech probabilities is at least 0.6.

Raises :class:`ScriptrsError` with code ``model_download`` when a
download fails, or ``cuda`` when Linux has no NVIDIA driver.
Expand Down
1 change: 1 addition & 0 deletions dev-tools/nemo/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.venv/
.cache/
14 changes: 8 additions & 6 deletions dev-tools/nemo/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# NeMo parity oracle

NeMo PyTorch is the reference for the native backends. This uv project pins the
stack the 2026-10-23 Parakeet profile measured (NeMo 3.0.0, torch 2.14.1+cu130)
and Silero VAD 5.1.2, whose weights match the published Core ML VAD.
stack the 2026-10-23 Parakeet profile measured (NeMo 3.0.0, torch 2.14.1+cu130).
`silero.py` fetches the two Silero VAD TorchScript models scriptrs ships, 5.1.2 and
6.2.3, from Silero's release tags and checks each against its pinned SHA-256; their
weights match the published Core ML VAD models.

```sh
uv sync
Expand All @@ -12,14 +14,14 @@ just nemo-refs v2 /shared/datasets/parakeet-ref/v2

## `export_native.py`

Writes the native model layout from the `.nemo` checkpoints and the Silero package:
Writes the native model layout from the `.nemo` checkpoints and the Silero models:

```text
parakeet-v2/model.safetensors parakeet-v2/vocab.txt
parakeet-v3/model.safetensors parakeet-v3/parakeet_vocab.json
nemotron-speech-streaming-en-0.6b/model.safetensors .../vocab.txt
nemotron-3.5-asr-streaming-0.6b/model.safetensors .../vocab.txt
vad/silero-vad-v5.safetensors
vad/silero-vad-v5.safetensors vad/silero-vad-v6.safetensors
```

`--only` (repeatable: `v2`, `v3`, `nemotron-en`, `nemotron-3.5`, `vad`) exports a
Expand All @@ -44,15 +46,15 @@ layers 0 and 23, every layer output, the encoder output, a per-step greedy TDT
trace, and a bf16-autocast encoder output for tolerance scale. The trace follows
NeMo's label-looping frame advance (the same rules as `HostLoop`), and generation
fails unless its tokens and timestamps equal NeMo's batched decode. `--vad-audio`
adds Silero v5 per-window probabilities. `--long-audio <wav>` writes only
adds Silero v5 and v6 per-window probabilities, in `silero-v5/` and `silero-v6/`. `--long-audio <wav>` writes only
`long-full` and `long-local`: one 120 s excerpt (from 300 s by default) with full
attention, then with NeMo's long-form recipe (`rel_pos_local_attn` [256, 256]),
the only sets where the two attention modes differ. Each is about 3.5 GB. NeMo runs on the GPU in fp32 with TF32
off, so run it through the homebased `gpu0` queue.

The v3 sets at `/shared/datasets/parakeet-ref/` came from the profile's original
script, which this one ports with an unchanged key layout; v2 sets are in `v2/`
and Silero's in `silero-v5/`. `just parity` in the repository root checks the
and Silero's in `silero-v5/` and `silero-v6/`. `just parity` in the repository root checks the
Rust side against them.

## `stream_ref.py`
Expand Down
24 changes: 13 additions & 11 deletions dev-tools/nemo/dump_ref.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Dump NeMo reference activations for Parakeet TDT 0.6B v2/v3 and Silero VAD v5
"""Dump NeMo reference activations for Parakeet TDT 0.6B v2/v3 and Silero VAD v5 and v6

Writes <out>/b1.safetensors and <out>/b8.safetensors (plus .json metadata): per-stage
encoder activations (fp32, TF32 off), a step-by-step greedy TDT decode trace per
utterance, and a bf16-autocast encoder output for tolerance scale. With --vad-audio it
also writes <out>/vad.safetensors from the Silero v5 TorchScript model. With --long-audio
also writes <out>/silero-v5/vad.safetensors and <out>/silero-v6/vad.safetensors from Silero's
TorchScript models. With --long-audio
it writes long-full and long-local sets for one long excerpt, the second with NeMo's
long-form recipe (rel_pos_local_attn [256, 256])

Expand Down Expand Up @@ -247,17 +248,17 @@ def run_set(model, rows, device, audios=None):


@torch.no_grad()
def dump_vad(out, audio_path):
"""Silero v5 probabilities for every 512-sample window of one file, plus window 0's stages
def dump_vad(out, audio_path, version):
"""One Silero version's probabilities for every 512-sample window of one file, plus window 0's stages

Mirrors scriptrs `process_windows`: zero state per recording, 64 context samples from
the previous chunk, and a short final chunk padded with its last sample
"""
import importlib.resources
import silero

jit = torch.jit.load(
str(importlib.resources.files("silero_vad").joinpath("data/silero_vad.jit")), map_location="cpu"
)
out = out / f"silero-{version}"
out.mkdir(parents=True, exist_ok=True)
jit = torch.jit.load(str(silero.jit_path(version)), map_location="cpu")
model = jit._model
audio = torch.from_numpy(sf.read(audio_path, dtype="float32")[0])
window, context_len = 512, 64
Expand Down Expand Up @@ -288,7 +289,7 @@ def dump_vad(out, audio_path):
save_file({k: v.contiguous() for k, v in tensors.items()}, str(out / "vad.safetensors"))
meta = {"audio": audio_path, "windows": len(probs), "keys": {k: list(v.shape) for k, v in tensors.items()}}
(out / "vad.json").write_text(json.dumps(meta, indent=1))
print("vad", meta)
print(f"vad {version}", meta)


# NeMo's long-form recipe, as the 2026-10-23 profile ran it on the 1 h Earnings-21 file
Expand Down Expand Up @@ -332,7 +333,7 @@ def main():
ap = argparse.ArgumentParser()
ap.add_argument("--version", choices=sorted(NEMO_PATHS), required=True)
ap.add_argument("--out", type=Path, required=True)
ap.add_argument("--vad-audio", help="also dump Silero v5 references for this 16 kHz wav")
ap.add_argument("--vad-audio", help="also dump Silero v5 and v6 references for this 16 kHz wav")
ap.add_argument("--long-audio", help="dump only the long-full and long-local sets from this 16 kHz wav")
ap.add_argument("--long-offset", type=float, default=300.0, help="excerpt start in seconds")
ap.add_argument("--long-seconds", type=float, default=120.0, help="excerpt length in seconds")
Expand All @@ -344,7 +345,8 @@ def main():
out = args.out
out.mkdir(parents=True, exist_ok=True)
if args.vad_audio:
dump_vad(out, args.vad_audio)
for version in ("v5", "v6"):
dump_vad(out, args.vad_audio, version)
model = load_model(args.version, device)
if args.long_audio:
dump_long(model, out, args.long_audio, args.long_offset, args.long_seconds, device)
Expand Down
31 changes: 15 additions & 16 deletions dev-tools/nemo/export_native.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Export Parakeet TDT and Nemotron streaming `.nemo` checkpoints and Silero VAD v5 to
scriptrs native weights
"""Export Parakeet TDT and Nemotron streaming `.nemo` checkpoints and Silero VAD v5
and v6 to scriptrs native weights

Writes, under --out:

parakeet-v2/model.safetensors, parakeet-v2/vocab.txt
parakeet-v3/model.safetensors, parakeet-v3/parakeet_vocab.json
nemotron-speech-streaming-en-0.6b/model.safetensors, .../vocab.txt
nemotron-3.5-asr-streaming-0.6b/model.safetensors, .../vocab.txt
vad/silero-vad-v5.safetensors
vad/silero-vad-v5.safetensors, vad/silero-vad-v6.safetensors

Tensors keep their NeMo (or Silero) names and stay fp32, so the file is the parity
oracle's own weights. Layout changes such as BatchNorm folding or transposes happen
Expand All @@ -22,7 +22,6 @@
import importlib
import importlib.metadata
import inspect
import importlib.resources
import json
import tarfile
from pathlib import Path
Expand All @@ -32,6 +31,8 @@
import yaml
from safetensors.torch import save_file

import silero

FORMAT = "scriptrs-native"
FORMAT_VERSION = "2"

Expand Down Expand Up @@ -360,33 +361,30 @@ def write_vocab(version: str, tokenizer_model: bytes, vocab_size: int, path: Pat
print(f"[{version}] wrote {vocab_size} tokens to {path}")


def export_silero(out: Path) -> None:
def export_silero(version: str, out: Path) -> None:
target = out / "vad"
target.mkdir(parents=True, exist_ok=True)
package_version = importlib.metadata.version("silero-vad")
if not package_version.startswith("5."):
raise SystemExit(f"silero-vad {package_version} does not ship the v5 weights")

jit_path = importlib.resources.files("silero_vad").joinpath("data/silero_vad.jit")
jit_path = silero.jit_path(version)
model = torch.jit.load(str(jit_path), map_location="cpu")
# `_model` is the 16 kHz branch; `_model_8k` is not used by scriptrs
tensors = {
name.removeprefix("_model."): tensor.detach().to(torch.float32).contiguous()
for name, tensor in model.state_dict().items()
if name.startswith("_model.")
}
name = f"silero-vad-{version}"
metadata = {
"format": FORMAT,
"format_version": FORMAT_VERSION,
"model": "silero-vad-v5",
"source": f"silero-vad {package_version} (16 kHz branch)",
"source_sha256": sha256_file(Path(str(jit_path))),
"model": name,
"source": silero.source(version),
"source_sha256": sha256_file(jit_path),
"config": json.dumps(
{"sample_rate": 16000, "window": 512, "context": 64, "state": 128}, sort_keys=True
),
}
save_file(tensors, target / "silero-vad-v5.safetensors", metadata=metadata)
print(f"[vad] wrote {len(tensors)} tensors to {target / 'silero-vad-v5.safetensors'}")
save_file(tensors, target / f"{name}.safetensors", metadata=metadata)
print(f"[vad] wrote {len(tensors)} tensors to {target / f'{name}.safetensors'}")


def main() -> None:
Expand All @@ -400,7 +398,8 @@ def main() -> None:
if key in only:
export_streaming(key, getattr(args, f"{key}_nemo"), args.out)
if "vad" in only:
export_silero(args.out)
for version in silero.VERSIONS:
export_silero(version, args.out)


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion dev-tools/nemo/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies = [
"numpy",
"jiwer",
"whisper-normalizer",
"silero-vad==5.1.2",
"huggingface-hub",
]

Expand Down
Loading
Loading