Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

speechonnxmetrics

Unified speech evaluation metrics: no-reference MOS, intrusive (reference-based) signal metrics, ASR-based text metrics, and speaker similarity, behind one small API that runs on numpy and onnxruntime only.

Why numpy + onnxruntime only

The entire runtime depends on just numpy, onnxruntime and huggingface_hub. There is no torch in the runtime path. Neural MOS predictors (UTMOS, DNSMOS, NISQA, SIGMOS) run as exported ONNX graphs, so the package installs small, imports fast, and runs the same on CPU everywhere. The export extra pulls in torch/onnx, but only for offline model conversion by maintainers, never at inference time.

Model weights download from public HuggingFace repos on first use and cache locally. import speechonnxmetrics touches neither the network nor onnxruntime.

Install

Not yet on PyPI. Install from git:

pip install git+https://github.com/TigreGotico/speechonnxmetrics

Once published, pip install speechonnxmetrics will work too.

Extras (all optional):

extra pulls in needed for
audio soundfile non-WAV input (mp3/flac/ogg…). Base install decodes WAV via the stdlib.
speaker speakeronnx speaker-embedding extraction for speaker_similarity
asr onnx-asr running an ASR model to get hypotheses (WER/CER scoring itself needs nothing)
vad vadonnx voice-activity gating
export torch, onnx maintainer-only offline model conversion
test pytest, pytest-cov, scipy running the test suite (scipy is a test-only oracle)
pip install "speechonnxmetrics[audio,speaker]"

Quickstart

import speechonnxmetrics as s

# No-reference neural MOS (downloads UTMOS weights on first call, then caches):
print(s.score("test/fixtures/audio/source.wav", ["utmos"]))
# -> {'utmos': 4.4115...}

# Intrusive metrics need a clean reference (pure numpy, no download):
print(s.score("test/fixtures/audio/facodec_aria.wav",
              ["stoi", "mcd", "si_sdr"],
              ref="test/fixtures/audio/source.wav"))
# -> {'stoi': 0.662..., 'mcd': 10.459..., 'si_sdr': -26.937...}

Dict-valued metrics flatten into the result. dnsmos becomes dnsmos.sig, dnsmos.bak, dnsmos.ovrl. nisqa becomes nisqa.mos, nisqa.noi, and more. See examples/: every script there runs against the bundled fixture audio.

Metrics

21 metrics live in one registry. score()/score_batch() dispatch the audio metrics. The text metrics compare strings and are called directly from speechonnxmetrics.asr. Enumerate everything at runtime with s.list_metrics() or speechonnxmetrics list.

No-reference MOS (audio, needs model download)

metric range ↑better output meaning
utmos 1-5 yes float UTMOS22 naturalness MOS
dnsmos 1-5 yes sig, bak, ovrl DNSMOS P.835 speech / background / overall quality
dnsmos_p808 1-5 yes float DNSMOS P.808 crowdsourced-listening MOS
sigmos 1-5 yes 7 dims SIGMOS P.804 quality (col,disc,loud,noise,reverb,sig,ovrl)
nisqa 1-5 yes mos,noi,dis,col,loud NISQA-v2 quality, NonCommercial weights

Intrusive / reference-based (audio, pure numpy, needs ref=)

metric range ↑better meaning
stoi 0-1 yes short-time objective intelligibility
estoi 0-1 yes extended STOI
si_sdr dB yes scale-invariant signal-to-distortion ratio
sdr dB yes signal-to-distortion ratio
snr dB yes signal-to-noise ratio
mcd dB no mel-cepstral distortion
log_f0_rmse n/a no log-F0 RMSE (pitch error)
vuv_error 0-1 no voiced/unvoiced decision error rate
lsd dB no log-spectral distance
msd dB no mel-spectral distortion
mel_l1 n/a no L1 distance on log-mel spectrograms

ASR-based text metrics (text, pure numpy, string in/out)

metric range ↑better meaning
wer ≥0 no word error rate
cer 0-1 no character error rate
mer 0-1 no match error rate
wil 0-1 no word information lost
wip 0-1 yes word information preserved

Speaker similarity and verification

Not in the score() registry. Call these from speechonnxmetrics.speaker: speaker_similarity (cosine between speaker embeddings, needs the speaker extra), plus pure-numpy eer, min_dcf and equal_error_threshold over score/label arrays.

Sample-rate handling is automatic: the base resamples input to each model's native rate (UTMOS/DNSMOS 16 kHz, SIGMOS 48 kHz, STOI analysis at 10 kHz), and NISQA is rate-adaptive and never resamples. See docs/metrics.md for the per-metric detail and paper citations, and docs/models.md for the ONNX models and their licences.

GPU inference

The ONNX-backed metrics (the MOS predictors, speaker similarity) run on CPUExecutionProvider by default. To run them on GPU, install onnxruntime-gpu (instead of, or alongside, onnxruntime) with the matching CUDA/cuDNN setup, then pick one of two knobs:

  • SPEECHONNXMETRICS_PROVIDERS — a comma-separated onnxruntime provider list, e.g. SPEECHONNXMETRICS_PROVIDERS=CUDAExecutionProvider,CPUExecutionProvider. This is the knob that matters for batch pipelines and the CLI, which have no providers= argument to thread through — set the env var once and every ONNX session in the process picks it up with no code change.
  • providers= — pass it explicitly to score()/score_batch(), or to an OnnxMetric subclass's constructor, when a given call needs providers different from the process default. An explicit providers= always wins over the env var.

Either way, a provider that onnxruntime does not have built in (or that fails to initialize) is silently dropped rather than raised: the requested list is intersected with onnxruntime.get_available_providers(), and CPUExecutionProvider is always kept as the final fallback so scoring never crashes for lack of a GPU.

CLI

$ speechonnxmetrics --help
usage: speechonnxmetrics [-h] [--version] {score,list} ...

positional arguments:
  {score,list}
    score       score one or more audio files
    list        list available metrics
$ speechonnxmetrics score --help
usage: speechonnxmetrics score [-h] [--ref REF] --metrics METRICS [--sr SR]
                               [--json]
                               audio [audio ...]

positional arguments:
  audio              degraded audio file(s) to score

options:
  --ref REF          reference audio file (required for intrusive metrics)
  --metrics METRICS  comma-separated metric names
  --sr SR            sample rate hint for raw input
  --json             emit JSON instead of a table

Real invocations:

$ speechonnxmetrics score test/fixtures/audio/facodec_aria.wav \
      --ref test/fixtures/audio/source.wav --metrics stoi,mcd,si_sdr
audio                                 mcd                 si_sdr               stoi
test/fixtures/audio/facodec_aria.wav  10.459728433678961  -26.937894650414812  0.6620030195244008

$ speechonnxmetrics list
name         kind   intrusive  requires_download
cer          text   True       False
dnsmos       audio  False      True
...

Full reference in docs/cli.md.

Licence

The package itself is Apache-2.0. Model weights carry their own licences:

licence metrics commercial use
MIT dnsmos, dnsmos_p808, sigmos, utmos permitted
CC BY-NC-SA 4.0 (NonCommercial) nisqa forbidden

nisqa is the one caveat: its weights are NonCommercial. Every other metric is safe for commercial use. The package makes no choice for you. It exposes the metric and states the terms, and selecting it is your call. Full per-model breakdown in docs/models.md.

Models are grouped in the HuggingFace collection speechonnxmetrics models under the TigreGotico org.

Not provided (on purpose)

  • PESQ: ITU-T P.862 licensing is incompatible with an open, pip-installable package, and neural MOS predictors supersede it. Use a dedicated PESQ package under your own licence review if you need it.
  • UTMOSv2: its published score is an ensemble over five folds times five random 3 s crops, so any single-fold single-crop export would be a different estimator, not an approximation of the published numbers.

Docs

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

speechonnxmetrics-0.0.2a3.tar.gz (73.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

speechonnxmetrics-0.0.2a3-py3-none-any.whl (59.8 kB view details)

Uploaded Python 3

File details

Details for the file speechonnxmetrics-0.0.2a3.tar.gz.

File metadata

  • Download URL: speechonnxmetrics-0.0.2a3.tar.gz
  • Upload date:
  • Size: 73.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for speechonnxmetrics-0.0.2a3.tar.gz
Algorithm Hash digest
SHA256 9e1a01b4736fa5b98d4544b20e86c6570b9578b52294d651846f49b3157761ba
MD5 af21e5ebd112a632b401ae04b12c9c90
BLAKE2b-256 7d7a3b602ef6811d1c7e5e95c1d00c0bde0d65b73299f5b5e8da3ba47707d367

See more details on using hashes here.

File details

Details for the file speechonnxmetrics-0.0.2a3-py3-none-any.whl.

File metadata

File hashes

Hashes for speechonnxmetrics-0.0.2a3-py3-none-any.whl
Algorithm Hash digest
SHA256 d93efa65f37af50111d1c34e5bb22bc2c51a4d5f61661c8b5be9396dd1efaf1e
MD5 b5a61e6d761938b0348ac7356b1c9bdc
BLAKE2b-256 07387aeed510907dc7e9a0c1f97f643cdc4b262fbfb5d12322861f1d6394f16a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page