Downloads · 30 days
6
1% of all-time downloads
cptspacemanspiff/diar_streaming_sortformer_4spk-v2-hf
diar_streaming_sortformer_4spk-v2-hf is a machine learning model from cptspacemanspiff. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as cc-by-4.0.
This is a format conversion of NVIDIA NeMo's nvidia/diarstreamingsortformer4spk-v2 into the 🤗 Transformers format. The weights are bit-identical to the original NeMo checkpoint — only the serialization (.nemo → confi…
Downloads · 30 days
6
1% of all-time downloads
All-time downloads
423
Public
Parameters
118M
471 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors471 MB · 100%
From the Hugging Face model README
This is a format conversion of NVIDIA NeMo's
nvidia/diar_streaming_sortformer_4spk-v2
into the 🤗 Transformers format. The weights are bit-identical to the original NeMo checkpoint — only the
serialization (.nemo → config.json + safetensors) and the surrounding inference code differ. No retraining,
fine-tuning, quantization, or merging was performed.
Sortformer is an end-to-end neural speaker-diarization model. It emits, for every ~80 ms output frame, an independent probability for each of up to 4 speakers being active (multi-label / sigmoid), so it naturally handles overlapping speech.
import torch
from transformers import AutoFeatureExtractor, AutoModelForAudioFrameClassification
model_id = "<this-repo>"
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
model = AutoModelForAudioFrameClassification.from_pretrained(model_id).eval()
# `audio` is a 16 kHz mono waveform. The offline path peak-normalizes the waveform first:
import numpy as np
audio = audio / (np.abs(audio).max() + 1e-3)
inputs = feature_extractor(audio, sampling_rate=16000, return_tensors="pt")
with torch.no_grad():
probs = model(**inputs).logits.sigmoid() # (batch, num_frames, num_speakers)
# NOTE: the streaming path expects features extracted WITHOUT peak-normalization.
inputs = feature_extractor(audio, sampling_rate=16000, return_tensors="pt")
with torch.no_grad():
probs = model.diarize_streaming(inputs.input_features, attention_mask=inputs.attention_mask)
Runnable examples (including a live-microphone demo with a real-time plot) are in the Transformers repo under
examples/pytorch/speaker-diarization/.
Converted with transformers/src/transformers/models/sortformer/convert_sortformer_nemo_to_hf.py. The HF
implementation was validated to reproduce the original NeMo model to float precision:
| Path | max|Δ| vs NeMo |
|---|---|
| Offline network (identical features) | ~4e-8 |
| Offline full pipeline (real audio) | ~5e-7 |
Streaming (forward_streaming, AOSC) | ~6e-7 |
Inherited from the source model: CC-BY-4.0. Please cite the original Sortformer work and the NVIDIA NeMo release.