speechonnxmetrics 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. speechonnxmetrics-0.0.1/LICENSE +17 -0
  2. speechonnxmetrics-0.0.1/MANIFEST.in +3 -0
  3. speechonnxmetrics-0.0.1/PKG-INFO +236 -0
  4. speechonnxmetrics-0.0.1/README.md +195 -0
  5. speechonnxmetrics-0.0.1/pyproject.toml +66 -0
  6. speechonnxmetrics-0.0.1/setup.cfg +4 -0
  7. speechonnxmetrics-0.0.1/speechonnxmetrics/__init__.py +20 -0
  8. speechonnxmetrics-0.0.1/speechonnxmetrics/_dsp/__init__.py +36 -0
  9. speechonnxmetrics-0.0.1/speechonnxmetrics/_dsp/audio.py +113 -0
  10. speechonnxmetrics-0.0.1/speechonnxmetrics/_dsp/dtw.py +87 -0
  11. speechonnxmetrics-0.0.1/speechonnxmetrics/_dsp/fbank.py +114 -0
  12. speechonnxmetrics-0.0.1/speechonnxmetrics/_dsp/mel.py +108 -0
  13. speechonnxmetrics-0.0.1/speechonnxmetrics/_dsp/pitch.py +121 -0
  14. speechonnxmetrics-0.0.1/speechonnxmetrics/_dsp/resample.py +65 -0
  15. speechonnxmetrics-0.0.1/speechonnxmetrics/_dsp/stft.py +114 -0
  16. speechonnxmetrics-0.0.1/speechonnxmetrics/api.py +109 -0
  17. speechonnxmetrics-0.0.1/speechonnxmetrics/asr/__init__.py +50 -0
  18. speechonnxmetrics-0.0.1/speechonnxmetrics/asr/normalize.py +87 -0
  19. speechonnxmetrics-0.0.1/speechonnxmetrics/asr/wer.py +190 -0
  20. speechonnxmetrics-0.0.1/speechonnxmetrics/base.py +164 -0
  21. speechonnxmetrics-0.0.1/speechonnxmetrics/cli.py +101 -0
  22. speechonnxmetrics-0.0.1/speechonnxmetrics/intrusive/__init__.py +30 -0
  23. speechonnxmetrics-0.0.1/speechonnxmetrics/intrusive/_common.py +88 -0
  24. speechonnxmetrics-0.0.1/speechonnxmetrics/intrusive/cepstral.py +131 -0
  25. speechonnxmetrics-0.0.1/speechonnxmetrics/intrusive/sdr.py +55 -0
  26. speechonnxmetrics-0.0.1/speechonnxmetrics/intrusive/spectral.py +70 -0
  27. speechonnxmetrics-0.0.1/speechonnxmetrics/intrusive/stoi.py +175 -0
  28. speechonnxmetrics-0.0.1/speechonnxmetrics/mos/__init__.py +18 -0
  29. speechonnxmetrics-0.0.1/speechonnxmetrics/mos/dnsmos.py +157 -0
  30. speechonnxmetrics-0.0.1/speechonnxmetrics/mos/nisqa.py +125 -0
  31. speechonnxmetrics-0.0.1/speechonnxmetrics/mos/sigmos.py +95 -0
  32. speechonnxmetrics-0.0.1/speechonnxmetrics/mos/utmos.py +59 -0
  33. speechonnxmetrics-0.0.1/speechonnxmetrics/registry.py +170 -0
  34. speechonnxmetrics-0.0.1/speechonnxmetrics/resolver.py +92 -0
  35. speechonnxmetrics-0.0.1/speechonnxmetrics/speaker/__init__.py +21 -0
  36. speechonnxmetrics-0.0.1/speechonnxmetrics/speaker/similarity.py +162 -0
  37. speechonnxmetrics-0.0.1/speechonnxmetrics/version.py +13 -0
  38. speechonnxmetrics-0.0.1/speechonnxmetrics.egg-info/PKG-INFO +236 -0
  39. speechonnxmetrics-0.0.1/speechonnxmetrics.egg-info/SOURCES.txt +51 -0
  40. speechonnxmetrics-0.0.1/speechonnxmetrics.egg-info/dependency_links.txt +1 -0
  41. speechonnxmetrics-0.0.1/speechonnxmetrics.egg-info/entry_points.txt +2 -0
  42. speechonnxmetrics-0.0.1/speechonnxmetrics.egg-info/requires.txt +24 -0
  43. speechonnxmetrics-0.0.1/speechonnxmetrics.egg-info/top_level.txt +1 -0
  44. speechonnxmetrics-0.0.1/test/test_api.py +138 -0
  45. speechonnxmetrics-0.0.1/test/test_asr.py +306 -0
  46. speechonnxmetrics-0.0.1/test/test_base.py +102 -0
  47. speechonnxmetrics-0.0.1/test/test_cli.py +58 -0
  48. speechonnxmetrics-0.0.1/test/test_dsp.py +321 -0
  49. speechonnxmetrics-0.0.1/test/test_import.py +22 -0
  50. speechonnxmetrics-0.0.1/test/test_intrusive.py +481 -0
  51. speechonnxmetrics-0.0.1/test/test_mos.py +549 -0
  52. speechonnxmetrics-0.0.1/test/test_registry.py +57 -0
  53. speechonnxmetrics-0.0.1/test/test_speaker.py +158 -0
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 TigreGóticoLda
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ include LICENSE
2
+ include README.md
3
+ recursive-include speechonnxmetrics/data *
@@ -0,0 +1,236 @@
1
+ Metadata-Version: 2.4
2
+ Name: speechonnxmetrics
3
+ Version: 0.0.1
4
+ Summary: Unified speech evaluation metrics — MOS, intrusive, and ASR — on numpy + onnxruntime only
5
+ Author-email: JarbasAi <jarbasai@mailfence.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/TigreGotico/speechonnxmetrics
8
+ Project-URL: Repository, https://github.com/TigreGotico/speechonnxmetrics
9
+ Keywords: speech evaluation,mos,utmos,nisqa,dnsmos,sigmos,stoi,si-sdr,mcd,wer,cer,speaker similarity,onnx
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
18
+ Classifier: Intended Audience :: Developers
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy
23
+ Requires-Dist: onnxruntime>=1.17
24
+ Requires-Dist: huggingface_hub
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest; extra == "test"
27
+ Requires-Dist: pytest-cov; extra == "test"
28
+ Requires-Dist: scipy; extra == "test"
29
+ Provides-Extra: export
30
+ Requires-Dist: torch; extra == "export"
31
+ Requires-Dist: onnx; extra == "export"
32
+ Provides-Extra: audio
33
+ Requires-Dist: soundfile; extra == "audio"
34
+ Provides-Extra: speaker
35
+ Requires-Dist: speakeronnx; extra == "speaker"
36
+ Provides-Extra: asr
37
+ Requires-Dist: onnx-asr; extra == "asr"
38
+ Provides-Extra: vad
39
+ Requires-Dist: vadonnx; extra == "vad"
40
+ Dynamic: license-file
41
+
42
+ # speechonnxmetrics
43
+
44
+ Unified **speech evaluation metrics** — no-reference MOS, intrusive (reference-based)
45
+ signal metrics, ASR-based text metrics, and speaker similarity — behind one small API,
46
+ running on **numpy and onnxruntime only**.
47
+
48
+ ## Why numpy + onnxruntime only
49
+
50
+ The entire runtime depends on just **numpy, onnxruntime and huggingface_hub**. There is
51
+ **no torch in the runtime path**. Neural MOS predictors (UTMOS, DNSMOS, NISQA, SIGMOS)
52
+ run as exported ONNX graphs, so the package installs small, imports fast, and runs the
53
+ same on CPU everywhere. The `export` extra pulls in torch/onnx, but only for offline
54
+ model conversion by maintainers — never at inference time.
55
+
56
+ Model weights download from public HuggingFace repos on first use and cache locally;
57
+ `import speechonnxmetrics` touches neither the network nor onnxruntime.
58
+
59
+ ## Install
60
+
61
+ Not yet on PyPI. Install from git:
62
+
63
+ ```bash
64
+ pip install git+https://github.com/TigreGotico/speechonnxmetrics
65
+ ```
66
+
67
+ Once published, `pip install speechonnxmetrics` will work too.
68
+
69
+ Extras (all optional):
70
+
71
+ | extra | pulls in | needed for |
72
+ |---|---|---|
73
+ | `audio` | `soundfile` | non-WAV input (mp3/flac/ogg…). Base install decodes WAV via the stdlib. |
74
+ | `speaker` | `speakeronnx` | speaker-embedding extraction for `speaker_similarity` |
75
+ | `asr` | `onnx-asr` | running an ASR model to get hypotheses (WER/CER scoring itself needs nothing) |
76
+ | `vad` | `vadonnx` | voice-activity gating |
77
+ | `export` | `torch`, `onnx` | maintainer-only offline model conversion |
78
+ | `test` | `pytest`, `pytest-cov`, `scipy` | running the test suite (scipy is a test-only oracle) |
79
+
80
+ ```bash
81
+ pip install "speechonnxmetrics[audio,speaker]"
82
+ ```
83
+
84
+ ## Quickstart
85
+
86
+ ```python
87
+ import speechonnxmetrics as s
88
+
89
+ # No-reference neural MOS (downloads UTMOS weights on first call, then caches):
90
+ print(s.score("test/fixtures/audio/source.wav", ["utmos"]))
91
+ # -> {'utmos': 4.4115...}
92
+
93
+ # Intrusive metrics need a clean reference (pure numpy, no download):
94
+ print(s.score("test/fixtures/audio/facodec_aria.wav",
95
+ ["stoi", "mcd", "si_sdr"],
96
+ ref="test/fixtures/audio/source.wav"))
97
+ # -> {'stoi': 0.662..., 'mcd': 10.459..., 'si_sdr': -26.937...}
98
+ ```
99
+
100
+ Dict-valued metrics flatten into the result: `dnsmos` becomes `dnsmos.sig`,
101
+ `dnsmos.bak`, `dnsmos.ovrl`; `nisqa` becomes `nisqa.mos`, `nisqa.noi`, … More in
102
+ [`examples/`](examples/) — every script there runs against the bundled fixture audio.
103
+
104
+ ## Metrics
105
+
106
+ 21 metrics live in one registry. `score()`/`score_batch()` dispatch the **audio**
107
+ metrics; the **text** metrics compare strings and are called directly from
108
+ `speechonnxmetrics.asr`. Enumerate everything at runtime with `s.list_metrics()` or
109
+ `speechonnxmetrics list`.
110
+
111
+ ### No-reference MOS (audio, needs model download)
112
+
113
+ | metric | range | ↑better | output | meaning |
114
+ |---|---|---|---|---|
115
+ | `utmos` | 1–5 | yes | float | UTMOS22 naturalness MOS |
116
+ | `dnsmos` | 1–5 | yes | `sig`, `bak`, `ovrl` | DNSMOS P.835 speech / background / overall quality |
117
+ | `dnsmos_p808` | 1–5 | yes | float | DNSMOS P.808 crowdsourced-listening MOS |
118
+ | `sigmos` | 1–5 | yes | 7 dims | SIGMOS P.804 quality (`col`,`disc`,`loud`,`noise`,`reverb`,`sig`,`ovrl`) |
119
+ | `nisqa` | 1–5 | yes | `mos`,`noi`,`dis`,`col`,`loud` | NISQA-v2 quality — **NonCommercial weights** |
120
+
121
+ ### Intrusive / reference-based (audio, pure numpy, needs `ref=`)
122
+
123
+ | metric | range | ↑better | meaning |
124
+ |---|---|---|---|
125
+ | `stoi` | 0–1 | yes | short-time objective intelligibility |
126
+ | `estoi` | 0–1 | yes | extended STOI |
127
+ | `si_sdr` | dB | yes | scale-invariant signal-to-distortion ratio |
128
+ | `sdr` | dB | yes | signal-to-distortion ratio |
129
+ | `snr` | dB | yes | signal-to-noise ratio |
130
+ | `mcd` | dB | no | mel-cepstral distortion |
131
+ | `log_f0_rmse` | — | no | log-F0 RMSE (pitch error) |
132
+ | `vuv_error` | 0–1 | no | voiced/unvoiced decision error rate |
133
+ | `lsd` | dB | no | log-spectral distance |
134
+ | `msd` | dB | no | mel-spectral distortion |
135
+ | `mel_l1` | — | no | L1 distance on log-mel spectrograms |
136
+
137
+ ### ASR-based text metrics (text, pure numpy, string in/out)
138
+
139
+ | metric | range | ↑better | meaning |
140
+ |---|---|---|---|
141
+ | `wer` | ≥0 | no | word error rate |
142
+ | `cer` | 0–1 | no | character error rate |
143
+ | `mer` | 0–1 | no | match error rate |
144
+ | `wil` | 0–1 | no | word information lost |
145
+ | `wip` | 0–1 | yes | word information preserved |
146
+
147
+ ### Speaker similarity & verification
148
+
149
+ Not in the `score()` registry — call them from `speechonnxmetrics.speaker`:
150
+ `speaker_similarity` (cosine between speaker embeddings, needs the `speaker` extra),
151
+ plus pure-numpy `eer`, `min_dcf` and `equal_error_threshold` over score/label arrays.
152
+
153
+ Sample-rate handling is automatic: the base resamples input to each model's native rate
154
+ (UTMOS/DNSMOS 16 kHz, SIGMOS 48 kHz, STOI analysis at 10 kHz), and NISQA is
155
+ rate-adaptive and never resamples. See [`docs/metrics.md`](docs/metrics.md) for the
156
+ per-metric detail and paper citations, and [`docs/models.md`](docs/models.md) for the
157
+ ONNX models and their licences.
158
+
159
+ ## CLI
160
+
161
+ ```
162
+ $ speechonnxmetrics --help
163
+ usage: speechonnxmetrics [-h] [--version] {score,list} ...
164
+
165
+ positional arguments:
166
+ {score,list}
167
+ score score one or more audio files
168
+ list list available metrics
169
+ ```
170
+
171
+ ```
172
+ $ speechonnxmetrics score --help
173
+ usage: speechonnxmetrics score [-h] [--ref REF] --metrics METRICS [--sr SR]
174
+ [--json]
175
+ audio [audio ...]
176
+
177
+ positional arguments:
178
+ audio degraded audio file(s) to score
179
+
180
+ options:
181
+ --ref REF reference audio file (required for intrusive metrics)
182
+ --metrics METRICS comma-separated metric names
183
+ --sr SR sample rate hint for raw input
184
+ --json emit JSON instead of a table
185
+ ```
186
+
187
+ Real invocations:
188
+
189
+ ```
190
+ $ speechonnxmetrics score test/fixtures/audio/facodec_aria.wav \
191
+ --ref test/fixtures/audio/source.wav --metrics stoi,mcd,si_sdr
192
+ audio mcd si_sdr stoi
193
+ test/fixtures/audio/facodec_aria.wav 10.459728433678961 -26.937894650414812 0.6620030195244008
194
+
195
+ $ speechonnxmetrics list
196
+ name kind intrusive requires_download
197
+ cer text True False
198
+ dnsmos audio False True
199
+ ...
200
+ ```
201
+
202
+ Full reference in [`docs/cli.md`](docs/cli.md).
203
+
204
+ ## Licence
205
+
206
+ The package itself is **Apache-2.0**. Model weights carry their own licences:
207
+
208
+ | licence | metrics | commercial use |
209
+ |---|---|---|
210
+ | MIT | `dnsmos`, `dnsmos_p808`, `sigmos`, `utmos` | permitted |
211
+ | **CC BY-NC-SA 4.0 (NonCommercial)** | **`nisqa`** | **forbidden** |
212
+
213
+ **`nisqa` is the one caveat: its weights are NonCommercial.** Every other metric is
214
+ safe for commercial use. The package makes no choice for you — it exposes the metric
215
+ and states the terms; selecting it is your call. Full per-model breakdown in
216
+ [`docs/models.md`](docs/models.md).
217
+
218
+ Models are grouped in the HuggingFace collection **speechonnxmetrics models** under the
219
+ `TigreGotico` org.
220
+
221
+ ## Not provided (on purpose)
222
+
223
+ - **PESQ** — ITU-T P.862 licensing is incompatible with an open, pip-installable
224
+ package, and neural MOS predictors supersede it. Use a dedicated PESQ package under
225
+ your own licence review if you need it.
226
+ - **UTMOSv2** — its published score is an ensemble over five folds × five random 3 s
227
+ crops, so any single-fold single-crop export would be a *different* estimator, not an
228
+ approximation of the published numbers.
229
+
230
+ ## Docs
231
+
232
+ - [`docs/index.md`](docs/index.md) — orientation
233
+ - [`docs/metrics.md`](docs/metrics.md) — every metric family in detail
234
+ - [`docs/usage.md`](docs/usage.md) — `score` vs `score_batch`, custom metrics, caching
235
+ - [`docs/cli.md`](docs/cli.md) — CLI reference
236
+ - [`docs/models.md`](docs/models.md) — ONNX models, HF repos and licences
@@ -0,0 +1,195 @@
1
+ # speechonnxmetrics
2
+
3
+ Unified **speech evaluation metrics** — no-reference MOS, intrusive (reference-based)
4
+ signal metrics, ASR-based text metrics, and speaker similarity — behind one small API,
5
+ running on **numpy and onnxruntime only**.
6
+
7
+ ## Why numpy + onnxruntime only
8
+
9
+ The entire runtime depends on just **numpy, onnxruntime and huggingface_hub**. There is
10
+ **no torch in the runtime path**. Neural MOS predictors (UTMOS, DNSMOS, NISQA, SIGMOS)
11
+ run as exported ONNX graphs, so the package installs small, imports fast, and runs the
12
+ same on CPU everywhere. The `export` extra pulls in torch/onnx, but only for offline
13
+ model conversion by maintainers — never at inference time.
14
+
15
+ Model weights download from public HuggingFace repos on first use and cache locally;
16
+ `import speechonnxmetrics` touches neither the network nor onnxruntime.
17
+
18
+ ## Install
19
+
20
+ Not yet on PyPI. Install from git:
21
+
22
+ ```bash
23
+ pip install git+https://github.com/TigreGotico/speechonnxmetrics
24
+ ```
25
+
26
+ Once published, `pip install speechonnxmetrics` will work too.
27
+
28
+ Extras (all optional):
29
+
30
+ | extra | pulls in | needed for |
31
+ |---|---|---|
32
+ | `audio` | `soundfile` | non-WAV input (mp3/flac/ogg…). Base install decodes WAV via the stdlib. |
33
+ | `speaker` | `speakeronnx` | speaker-embedding extraction for `speaker_similarity` |
34
+ | `asr` | `onnx-asr` | running an ASR model to get hypotheses (WER/CER scoring itself needs nothing) |
35
+ | `vad` | `vadonnx` | voice-activity gating |
36
+ | `export` | `torch`, `onnx` | maintainer-only offline model conversion |
37
+ | `test` | `pytest`, `pytest-cov`, `scipy` | running the test suite (scipy is a test-only oracle) |
38
+
39
+ ```bash
40
+ pip install "speechonnxmetrics[audio,speaker]"
41
+ ```
42
+
43
+ ## Quickstart
44
+
45
+ ```python
46
+ import speechonnxmetrics as s
47
+
48
+ # No-reference neural MOS (downloads UTMOS weights on first call, then caches):
49
+ print(s.score("test/fixtures/audio/source.wav", ["utmos"]))
50
+ # -> {'utmos': 4.4115...}
51
+
52
+ # Intrusive metrics need a clean reference (pure numpy, no download):
53
+ print(s.score("test/fixtures/audio/facodec_aria.wav",
54
+ ["stoi", "mcd", "si_sdr"],
55
+ ref="test/fixtures/audio/source.wav"))
56
+ # -> {'stoi': 0.662..., 'mcd': 10.459..., 'si_sdr': -26.937...}
57
+ ```
58
+
59
+ Dict-valued metrics flatten into the result: `dnsmos` becomes `dnsmos.sig`,
60
+ `dnsmos.bak`, `dnsmos.ovrl`; `nisqa` becomes `nisqa.mos`, `nisqa.noi`, … More in
61
+ [`examples/`](examples/) — every script there runs against the bundled fixture audio.
62
+
63
+ ## Metrics
64
+
65
+ 21 metrics live in one registry. `score()`/`score_batch()` dispatch the **audio**
66
+ metrics; the **text** metrics compare strings and are called directly from
67
+ `speechonnxmetrics.asr`. Enumerate everything at runtime with `s.list_metrics()` or
68
+ `speechonnxmetrics list`.
69
+
70
+ ### No-reference MOS (audio, needs model download)
71
+
72
+ | metric | range | ↑better | output | meaning |
73
+ |---|---|---|---|---|
74
+ | `utmos` | 1–5 | yes | float | UTMOS22 naturalness MOS |
75
+ | `dnsmos` | 1–5 | yes | `sig`, `bak`, `ovrl` | DNSMOS P.835 speech / background / overall quality |
76
+ | `dnsmos_p808` | 1–5 | yes | float | DNSMOS P.808 crowdsourced-listening MOS |
77
+ | `sigmos` | 1–5 | yes | 7 dims | SIGMOS P.804 quality (`col`,`disc`,`loud`,`noise`,`reverb`,`sig`,`ovrl`) |
78
+ | `nisqa` | 1–5 | yes | `mos`,`noi`,`dis`,`col`,`loud` | NISQA-v2 quality — **NonCommercial weights** |
79
+
80
+ ### Intrusive / reference-based (audio, pure numpy, needs `ref=`)
81
+
82
+ | metric | range | ↑better | meaning |
83
+ |---|---|---|---|
84
+ | `stoi` | 0–1 | yes | short-time objective intelligibility |
85
+ | `estoi` | 0–1 | yes | extended STOI |
86
+ | `si_sdr` | dB | yes | scale-invariant signal-to-distortion ratio |
87
+ | `sdr` | dB | yes | signal-to-distortion ratio |
88
+ | `snr` | dB | yes | signal-to-noise ratio |
89
+ | `mcd` | dB | no | mel-cepstral distortion |
90
+ | `log_f0_rmse` | — | no | log-F0 RMSE (pitch error) |
91
+ | `vuv_error` | 0–1 | no | voiced/unvoiced decision error rate |
92
+ | `lsd` | dB | no | log-spectral distance |
93
+ | `msd` | dB | no | mel-spectral distortion |
94
+ | `mel_l1` | — | no | L1 distance on log-mel spectrograms |
95
+
96
+ ### ASR-based text metrics (text, pure numpy, string in/out)
97
+
98
+ | metric | range | ↑better | meaning |
99
+ |---|---|---|---|
100
+ | `wer` | ≥0 | no | word error rate |
101
+ | `cer` | 0–1 | no | character error rate |
102
+ | `mer` | 0–1 | no | match error rate |
103
+ | `wil` | 0–1 | no | word information lost |
104
+ | `wip` | 0–1 | yes | word information preserved |
105
+
106
+ ### Speaker similarity & verification
107
+
108
+ Not in the `score()` registry — call them from `speechonnxmetrics.speaker`:
109
+ `speaker_similarity` (cosine between speaker embeddings, needs the `speaker` extra),
110
+ plus pure-numpy `eer`, `min_dcf` and `equal_error_threshold` over score/label arrays.
111
+
112
+ Sample-rate handling is automatic: the base resamples input to each model's native rate
113
+ (UTMOS/DNSMOS 16 kHz, SIGMOS 48 kHz, STOI analysis at 10 kHz), and NISQA is
114
+ rate-adaptive and never resamples. See [`docs/metrics.md`](docs/metrics.md) for the
115
+ per-metric detail and paper citations, and [`docs/models.md`](docs/models.md) for the
116
+ ONNX models and their licences.
117
+
118
+ ## CLI
119
+
120
+ ```
121
+ $ speechonnxmetrics --help
122
+ usage: speechonnxmetrics [-h] [--version] {score,list} ...
123
+
124
+ positional arguments:
125
+ {score,list}
126
+ score score one or more audio files
127
+ list list available metrics
128
+ ```
129
+
130
+ ```
131
+ $ speechonnxmetrics score --help
132
+ usage: speechonnxmetrics score [-h] [--ref REF] --metrics METRICS [--sr SR]
133
+ [--json]
134
+ audio [audio ...]
135
+
136
+ positional arguments:
137
+ audio degraded audio file(s) to score
138
+
139
+ options:
140
+ --ref REF reference audio file (required for intrusive metrics)
141
+ --metrics METRICS comma-separated metric names
142
+ --sr SR sample rate hint for raw input
143
+ --json emit JSON instead of a table
144
+ ```
145
+
146
+ Real invocations:
147
+
148
+ ```
149
+ $ speechonnxmetrics score test/fixtures/audio/facodec_aria.wav \
150
+ --ref test/fixtures/audio/source.wav --metrics stoi,mcd,si_sdr
151
+ audio mcd si_sdr stoi
152
+ test/fixtures/audio/facodec_aria.wav 10.459728433678961 -26.937894650414812 0.6620030195244008
153
+
154
+ $ speechonnxmetrics list
155
+ name kind intrusive requires_download
156
+ cer text True False
157
+ dnsmos audio False True
158
+ ...
159
+ ```
160
+
161
+ Full reference in [`docs/cli.md`](docs/cli.md).
162
+
163
+ ## Licence
164
+
165
+ The package itself is **Apache-2.0**. Model weights carry their own licences:
166
+
167
+ | licence | metrics | commercial use |
168
+ |---|---|---|
169
+ | MIT | `dnsmos`, `dnsmos_p808`, `sigmos`, `utmos` | permitted |
170
+ | **CC BY-NC-SA 4.0 (NonCommercial)** | **`nisqa`** | **forbidden** |
171
+
172
+ **`nisqa` is the one caveat: its weights are NonCommercial.** Every other metric is
173
+ safe for commercial use. The package makes no choice for you — it exposes the metric
174
+ and states the terms; selecting it is your call. Full per-model breakdown in
175
+ [`docs/models.md`](docs/models.md).
176
+
177
+ Models are grouped in the HuggingFace collection **speechonnxmetrics models** under the
178
+ `TigreGotico` org.
179
+
180
+ ## Not provided (on purpose)
181
+
182
+ - **PESQ** — ITU-T P.862 licensing is incompatible with an open, pip-installable
183
+ package, and neural MOS predictors supersede it. Use a dedicated PESQ package under
184
+ your own licence review if you need it.
185
+ - **UTMOSv2** — its published score is an ensemble over five folds × five random 3 s
186
+ crops, so any single-fold single-crop export would be a *different* estimator, not an
187
+ approximation of the published numbers.
188
+
189
+ ## Docs
190
+
191
+ - [`docs/index.md`](docs/index.md) — orientation
192
+ - [`docs/metrics.md`](docs/metrics.md) — every metric family in detail
193
+ - [`docs/usage.md`](docs/usage.md) — `score` vs `score_batch`, custom metrics, caching
194
+ - [`docs/cli.md`](docs/cli.md) — CLI reference
195
+ - [`docs/models.md`](docs/models.md) — ONNX models, HF repos and licences
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "speechonnxmetrics"
7
+ dynamic = ["version"]
8
+ description = "Unified speech evaluation metrics — MOS, intrusive, and ASR — on numpy + onnxruntime only"
9
+ license = {text = "Apache-2.0"}
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Programming Language :: Python :: 3.10",
13
+ "Programming Language :: Python :: 3.11",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Programming Language :: Python :: 3.13",
16
+ "License :: OSI Approved :: Apache Software License",
17
+ "Operating System :: OS Independent",
18
+ "Topic :: Multimedia :: Sound/Audio :: Speech",
19
+ "Intended Audience :: Developers",
20
+ ]
21
+ authors = [{name = "JarbasAi", email = "jarbasai@mailfence.com"}]
22
+ readme = "README.md"
23
+ requires-python = ">=3.10"
24
+ keywords = [
25
+ "speech evaluation", "mos", "utmos", "nisqa", "dnsmos", "sigmos",
26
+ "stoi", "si-sdr", "mcd", "wer", "cer", "speaker similarity", "onnx",
27
+ ]
28
+ dependencies = [
29
+ "numpy",
30
+ "onnxruntime>=1.17",
31
+ "huggingface_hub",
32
+ ]
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/TigreGotico/speechonnxmetrics"
36
+ Repository = "https://github.com/TigreGotico/speechonnxmetrics"
37
+
38
+ [project.scripts]
39
+ speechonnxmetrics = "speechonnxmetrics.cli:main"
40
+
41
+ [project.optional-dependencies]
42
+ # test deps — scipy is a TEST-ONLY oracle for validating DSP primitives, never a
43
+ # runtime dependency
44
+ test = ["pytest", "pytest-cov", "scipy"]
45
+ # offline model conversion scripts only (maintainer use); never a runtime dependency
46
+ export = ["torch", "onnx"]
47
+ # broad codec support for _dsp.audio; the base install falls back to stdlib wave (WAV only)
48
+ audio = ["soundfile"]
49
+ speaker = ["speakeronnx"]
50
+ asr = ["onnx-asr"]
51
+ vad = ["vadonnx"]
52
+
53
+ [tool.setuptools.dynamic]
54
+ version = {attr = "speechonnxmetrics.version.__version__"}
55
+
56
+ [tool.setuptools.packages.find]
57
+ where = ["."]
58
+ include = ["speechonnxmetrics*"]
59
+
60
+ [tool.setuptools.package-data]
61
+ "speechonnxmetrics" = ["data/*"]
62
+
63
+ [tool.pytest.ini_options]
64
+ markers = [
65
+ "models: needs the ONNX weights; skipped when they are neither cached nor downloadable",
66
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ """speechonnxmetrics — unified speech evaluation metrics (MOS, intrusive, ASR, speaker)."""
2
+ from __future__ import annotations
3
+
4
+ from speechonnxmetrics.api import score, score_batch
5
+ from speechonnxmetrics.base import Metric, ModelEntry, OnnxMetric
6
+ from speechonnxmetrics.registry import RegistryEntry, get, list_metrics, register
7
+ from speechonnxmetrics.version import __version__
8
+
9
+ __all__ = [
10
+ "__version__",
11
+ "score",
12
+ "score_batch",
13
+ "Metric",
14
+ "ModelEntry",
15
+ "OnnxMetric",
16
+ "RegistryEntry",
17
+ "get",
18
+ "list_metrics",
19
+ "register",
20
+ ]
@@ -0,0 +1,36 @@
1
+ """Shared numpy DSP primitives (STFT, mel, Kaldi filterbank, pitch, DTW, resampling, audio I/O).
2
+
3
+ Kept out of onnxruntime graphs so every front-end/back-end transform is inspectable
4
+ and torch-free at runtime. There is exactly one STFT implementation in this package —
5
+ every metric and every ONNX frontend must route through it.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from speechonnxmetrics._dsp.audio import AudioLoadError, load_audio
10
+ from speechonnxmetrics._dsp.dtw import DTWError, dtw
11
+ from speechonnxmetrics._dsp.fbank import deltas, fbank, hamming, mel_banks
12
+ from speechonnxmetrics._dsp.mel import log_melspectrogram, mel_filterbank, melspectrogram
13
+ from speechonnxmetrics._dsp.pitch import PitchError, yin
14
+ from speechonnxmetrics._dsp.resample import kaiser_resample
15
+ from speechonnxmetrics._dsp.stft import hamming_window, istft, stft, vorbis_window
16
+
17
+ __all__ = [
18
+ "stft",
19
+ "istft",
20
+ "hamming_window",
21
+ "vorbis_window",
22
+ "fbank",
23
+ "mel_banks",
24
+ "hamming",
25
+ "deltas",
26
+ "kaiser_resample",
27
+ "mel_filterbank",
28
+ "melspectrogram",
29
+ "log_melspectrogram",
30
+ "yin",
31
+ "PitchError",
32
+ "dtw",
33
+ "DTWError",
34
+ "load_audio",
35
+ "AudioLoadError",
36
+ ]