Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: iic/speech_eres2netv2_sv_zh-cn_16k-common
|
| 4 |
+
tags:
|
| 5 |
+
- speaker-diarization
|
| 6 |
+
- speaker-recognition
|
| 7 |
+
- speaker-embedding
|
| 8 |
+
- onnx
|
| 9 |
+
- quantized
|
| 10 |
+
- int8
|
| 11 |
+
- sherpa-onnx
|
| 12 |
+
library_name: sherpa-onnx
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## `diarize-embedding-eres2netv2-int8.onnx`
|
| 16 |
+
|
| 17 |
+
Statically int8-quantized [ERes2NetV2](https://arxiv.org/abs/2406.02167) speaker
|
| 18 |
+
embedder (3D-Speaker, `zh-cn 16k-common`), for speaker diarization under
|
| 19 |
+
sherpa-onnx.
|
| 20 |
+
|
| 21 |
+
- **28 MB** (fp32 source: 71 MB), 192-dim embeddings, 16 kHz.
|
| 22 |
+
- Drop-in for `SpeakerEmbeddingExtractorConfig`: the sherpa `metadata_props`
|
| 23 |
+
(`framework`, `sample_rate`, `output_dim`, `feature_normalize_type`) are
|
| 24 |
+
preserved, which the extractor requires.
|
| 25 |
+
|
| 26 |
+
### Why quantize
|
| 27 |
+
|
| 28 |
+
fp32 ERes2NetV2 separates close voices well, but its 2D convolutions cost about
|
| 29 |
+
**10x** CAM++'s embedding time — roughly 11 minutes on a 19-minute meeting,
|
| 30 |
+
untenable on the no-GPU laptops this app targets. Static quantization removes
|
| 31 |
+
that objection:
|
| 32 |
+
|
| 33 |
+
| build | time per 6 s window (ORT CPU, 4 threads) |
|
| 34 |
+
|---|---|
|
| 35 |
+
| fp32 | 223 ms |
|
| 36 |
+
| **int8 static (this file)** | **77 ms — 2.9x faster** |
|
| 37 |
+
| int8 *dynamic* | 528 ms — 2.4x **slower** |
|
| 38 |
+
|
| 39 |
+
Dynamic quantization is a trap here: it lowers `Conv` to `ConvInteger`, which
|
| 40 |
+
onnxruntime's CPU provider does not optimize. Static quantization lowers to
|
| 41 |
+
`QLinearConv`, which it does.
|
| 42 |
+
|
| 43 |
+
### Accuracy
|
| 44 |
+
|
| 45 |
+
Against the fp32 model on real meeting windows: embedding cosine **≥ 0.9956**
|
| 46 |
+
(mean 0.9973), and the pairwise-similarity matrix — what clustering actually
|
| 47 |
+
consumes — drifts by at most **0.019**.
|
| 48 |
+
|
| 49 |
+
End-to-end on diarization bench (DER against hand-annotated references):
|
| 50 |
+
|
| 51 |
+
| fixture | CAM++ | this model |
|
| 52 |
+
|---|---|---|
|
| 53 |
+
| 2-speaker interview, 28 min | DER 12.6%, 2 voices | DER 12.7%, 2 voices |
|
| 54 |
+
| 2-speaker phone call, 8 min | DER 14.6%, 2 voices | DER 14.5%, 2 voices |
|
| 55 |
+
| multi-speaker meeting, 19 min | 2 voices, 80/20 speech split | **3 voices, 42/37/21** |
|
| 56 |
+
|
| 57 |
+
Two-speaker recordings cannot tell these models apart. The difference appears
|
| 58 |
+
where it matters — a meeting with several voices, where CAM++ collapses 80% of
|
| 59 |
+
the speech onto one speaker.
|
| 60 |
+
|
| 61 |
+
Both models still undercount a crowded room (3 of 5 real speakers on that
|
| 62 |
+
meeting), so lets the user pin the speaker count rather than trust
|
| 63 |
+
auto-detection.
|
| 64 |
+
|
| 65 |
+
### How it was made
|
| 66 |
+
|
| 67 |
+
`quantize_static` with `QuantFormat.QOperator`, per-channel int8 weights, uint8
|
| 68 |
+
activations, `Conv` only, calibrated on ~40 log-mel fbank windows (600 frames
|
| 69 |
+
≈ 6 s, per-window global-mean normalized, matching sherpa's own preprocessing)
|
| 70 |
+
taken from a real meeting recording. Model metadata is copied back from the
|
| 71 |
+
fp32 file afterwards, since the quantizer drops it.
|
| 72 |
+
|
| 73 |
+
The script lives in the app repo (`scripts/quantize-eres2netv2.py`):
|
| 74 |
+
|
| 75 |
+
```bash
|
| 76 |
+
python3 scripts/quantize-eres2netv2.py \
|
| 77 |
+
eres2netv2-fp32.onnx diarize-embedding-eres2netv2-int8.onnx \
|
| 78 |
+
some-real-meeting.mp3
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### Verifying this file
|
| 82 |
+
|
| 83 |
+
```
|
| 84 |
+
sha256 be6b162137d8b08854268a97763c007e49882f221e02950242923d40d2be157e
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
## Credits and license
|
| 88 |
+
|
| 89 |
+
The weights derive from
|
| 90 |
+
[`iic/speech_eres2netv2_sv_zh-cn_16k-common`](https://www.modelscope.cn/models/iic/speech_eres2netv2_sv_zh-cn_16k-common)
|
| 91 |
+
by the [3D-Speaker](https://github.com/modelscope/3D-Speaker) team (Apache-2.0);
|
| 92 |
+
the fp32 ONNX export came via
|
| 93 |
+
[csukuangfj/speaker-embedding-models](https://huggingface.co/csukuangfj/speaker-embedding-models).
|
| 94 |
+
This repository redistributes a quantized derivative under the same Apache-2.0
|
| 95 |
+
terms. If you use it, cite the original work:
|
| 96 |
+
|
| 97 |
+
```bibtex
|
| 98 |
+
@inproceedings{eres2netv2,
|
| 99 |
+
title = {{ERes2NetV2}: Boosting Short-Duration Speaker Verification
|
| 100 |
+
Performance with Computational Efficiency},
|
| 101 |
+
author = {Chen, Yafeng and Zheng, Siqi and Wang, Hui and Cheng, Luyao and
|
| 102 |
+
Zhu, Tinglong and Huang, Rongjie and Qian, Chong and Chen, Qian
|
| 103 |
+
and Zhang, Wen and Wang, Yanmin},
|
| 104 |
+
booktitle = {Interspeech},
|
| 105 |
+
year = {2024}
|
| 106 |
+
}
|