AlphaAvatar Persona - Speaker Vector (CAM++ zh-en, ONNX)
Speaker-embedding model used by the AlphaAvatar Persona plugin
(alphaavatar.persona.speaker.vector). It maps an 80-bin Kaldi filterbank sequence to a
192-dimensional speaker embedding. Chinese and English speech.
Revisions up to 62a02e9ebd28cab1f3e279e632474a687554283e of this repository hold the
previous model, ERes2NetV2 (model.onnx SHA256 a8614dde…), and its documentation; they
remain available at those revisions. Vectors of the two models are not comparable.
Artifact
| File | model.onnx |
| SHA256 | 38a03abb2bb0492155e990fe86ccb86182600de6f7b0a0ba42690d88c63fb436 |
| Size | 27.6 MiB (28,924,444 bytes) |
| ONNX IR / opset | 7 / 13 |
| Exported by | pytorch 2.9.0, TorchScript exporter (dynamo=False) |
| Parameters | 6,907,680 |
Provenance
Upstream: ModelScope iic/speech_campplus_sv_zh_en_16k-common_advanced, tag v1.0.0
(file commit 73001f7ab0bbf7a18739f6e0a48bc1bc74f7a271), campplus_cn_en_common.pt,
SHA256 92f29b94e6948786a26778c9e302525d185bb08c8b9f5252ed98776902840199, declared
Apache License 2.0 in its model card.
AlphaAvatar exported model.onnx from that checkpoint with export/export_campplus.py, using
the CAM++ definition of the pinned modelscope package. With the versions in
export/requirements.txt the script reproduces model.onnx byte for byte.
Why this is not the sherpa-onnx export
CAM++'s CAMLayer.seg_pooling averages 100-frame segments with
avg_pool1d(ceil_mode=True). PyTorch divides the last, partial segment by the frames it
holds. The stock export is AveragePool(ceil_mode=1, count_include_pad=1), which
onnxruntime divides by 100. Such a graph agrees with the checkpoint only when the pooled
length (feature frames / 2, rounded up) is a multiple of 100.
During export, seg_pooling is replaced by exact_seg_pooling (export/campplus_onnx.py).
It computes the same values with zero padding, a sum per segment and a division by the frames
each segment holds. The weights and every other operation are unchanged.
export/pooling_repro.py is the minimal reproduction. It exports the checkpoint both ways and
compares each with PyTorch:
- on random features whose pooled length falls on both sides of the boundaries at 100–400;
- on the three upstream example recordings, whole and cropped (
verification/pooling_repro.json).
| export | pooled length a multiple of 100 | other lengths |
|---|---|---|
| stock | min cosine 0.9999999999989 (13 inputs) | min cosine 0.845 (37 inputs) |
exact (model.onnx) | min cosine 0.9999999999987 (13 inputs) | min cosine 0.99999999998 (37 inputs) |
The sherpa-onnx release 3dspeaker_speech_campplus_sv_zh_en_16k-common_advanced.onnx shows
the same values as the stock export (verification/sherpa_artifact.json).
Verification
- Random features: 66 frame counts from 20 to 2001, against the checkpoint in PyTorch with its original pooling. Max absolute difference 1.5e-05, min cosine 0.99999999999 (
verification/export_check.json). - Real speech: 24 ASCEND clips (0.50–11.85 s), through AlphaAvatar's filterbank. Max absolute difference 2.0e-05, min cosine 0.99999988.
- Known answer: the upstream example recordings score 0.667 for the same speaker and 0.067 / 0.057 across speakers (
examples/output.json).
Input / output
input x float32 [N, T, 80]
output embedding float32 [N, 192]
Any frame count T is accepted; no fixed input length is required.
Preprocessing
16 kHz mono. Kaldi-style log-mel filterbank, 80 bins, dither 0.0, then per-dimension mean normalisation over time:
from torchaudio.compliance import kaldi
feat = kaldi.fbank(wav, num_mel_bins=80, sample_frequency=16000, dither=0.0)
feat = feat - feat.mean(0, keepdim=True) # [T, 80]
feat = feat.unsqueeze(0) # [1, T, 80]
Postprocessing
The graph output is not L2-normalised. Normalise before computing cosine similarity:
emb = emb / np.linalg.norm(emb, axis=-1, keepdims=True)
score = float(a @ b.T)
The upstream configuration.json records a decision threshold of 0.33.
AlphaAvatar applies its own SPEAKER_MATCH_THRESHOLD, which lives in the AlphaAvatar
repository and is not part of this artifact.
Reproduce
pip install -r export/requirements.txt
cd export
python export_campplus.py --checkpoint campplus_cn_en_common.pt --out model.onnx
python pooling_repro.py --checkpoint campplus_cn_en_common.pt \
--audio speaker1_a_cn_16k.wav speaker1_b_cn_16k.wav speaker2_a_cn_16k.wav --out report.json
python make_examples.py --model model.onnx \
--audio speaker1_a_cn_16k.wav speaker1_b_cn_16k.wav speaker2_a_cn_16k.wav --out examples
The checkpoint and the example recordings come from the upstream ModelScope repository at
tag v1.0.0; examples/input.json lists their SHA256.
Repository files
| file | purpose |
|---|---|
model.onnx | the model |
model_manifest.json | authoritative manifest: provenance, export change, verified pre/postprocessing |
config.json | minimal ONNX descriptor; also the Hub's download-count query file. Not a transformers config |
export/ | export script, shared code, pooling reproduction, example generator, pinned requirements |
verification/ | export check, pooling reproduction report, sherpa-onnx comparison |
examples/ | a deterministic input, its exact output, and the known answer on real speech |
checksums.sha256 | covers every file above |
evaluation/ | how AlphaAvatar's speaker matching thresholds were calibrated and tested with this model: protocol, scripts, session manifests and result tables, no audio (its own SHA256SUMS, not in checksums.sha256) |
Licence
Apache-2.0, inherited from the upstream model. See LICENSE and NOTICE.