Perceptual audio quality metrics (ViSQOL MOS-LQO and SCOREQ) — pure-Rust implementation with Python bindings
Project description
Perceptual audio quality metrics in pure Rust, with Python bindings.
ViSQOL (Virtual Speech Quality Objective Listener) is a full-reference metric that compares a degraded signal against a clean reference and predicts a MOS-LQO in the range 1.0 to 5.0. Audio and speech modes, conformance-tested against the reference implementation.
SCOREQ (Speech Contrastive Regression for Quality Assessment) is a neural, wav2vec2-based speech-quality metric. It predicts a MOS from a single signal (no-reference mode), or an embedding distance between a test and reference signal (reference mode).
Built on the audio_samples
ecosystem.
Install
pip install audio-samples-qoe
The wheel is self-contained, so no Rust toolchain is needed. To build from
source instead, install maturin and run maturin develop --release from the repository root.
Usage
from audio_samples import AudioSamples
from audio_samples_qoe import visqol, Scoreq
# Files or audio_samples.AudioSamples, in any combination.
score = visqol("reference.wav", "degraded.wav")
# Speech mode is a keyword away.
score = visqol("reference.wav", "degraded.wav", mode="speech")
# SCOREQ: no-reference MOS, or reference-based embedding distance.
model = Scoreq(domain="natural", mode="nr")
mos = model.predict("degraded.wav")
model = Scoreq(domain="natural", mode="ref")
distance = model.predict_ref("degraded.wav", "reference.wav")
Each signal may be an AudioSamples object or a path to a WAV/FLAC file
(decoded with audio_samples.read()), in any combination. Raw arrays are
deliberately not accepted: wrap them with AudioSamples.new_mono(arr, sample_rate) / new_multi, which is where the sample rate is attached.
Multi-channel signals are mixed down to mono, and any input sample rate is
handled internally. Both metrics release the GIL while computing, so scoring
parallelises across Python threads.
Loading a Scoreq model is expensive (the first use of a given
(domain, mode) pair downloads ~378 MB of weights from Zenodo into
~/.cache/scoreq/), so construct one per (domain, mode) pair and reuse it
across calls.
Modes
| Mode | Operating rate | Bands | MOS mapping | Patch selection |
|---|---|---|---|---|
"audio" |
48 kHz (resampled) | 32, up to Nyquist | Support vector regression | All patches |
"speech" |
Reference's native rate | 21, ≤ 8 kHz | Exponential NSIM fit | Voice-activity gated |
In speech mode the reference is never resampled (16 kHz input is recommended), silence in the reference is excluded by a voice-activity detector, and identical signals score 5.0.
Errors
TypeError: an argument is neither anAudioSamplesnor a path.ValueError: invalidmode/domainstring.OSError: a file could not be read or decoded.audio_samples_qoe.VisqolError: the ViSQOL pipeline failed (most commonly a signal too short to extract a single analysis patch).audio_samples_qoe.ScoreqError: the SCOREQ pipeline failed, orpredict/predict_refwas called on a model loaded for the other mode.
The package ships full type stubs and a py.typed marker, so mypy,
pyright, and IDE completion work out of the box.
Changelog
See CHANGELOG.md.
Contributing
See CONTRIBUTING.md.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file audio_samples_qoe-0.1.3.tar.gz.
File metadata
- Download URL: audio_samples_qoe-0.1.3.tar.gz
- Upload date:
- Size: 391.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
479d275153450ee3b18d9a87f85b24c3253dac02b9e3170809cc8fec4b72dccd
|
|
| MD5 |
ff596716cf08e5d9ff6dfc483dc535bb
|
|
| BLAKE2b-256 |
6fac1af8f8ff8aff922731131eda4923615f9fe5262477120a4218920aa00f91
|
File details
Details for the file audio_samples_qoe-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: audio_samples_qoe-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
510eada42499e7beada4a0c0b918e18230c76a247ebfc4f4abe675c3314223a3
|
|
| MD5 |
49f83cc60718aa3e9c98ea835e8a243b
|
|
| BLAKE2b-256 |
4ea729d1309ddf26b06e30947f389193c2e50fda6b53bf660e45935e84aa92ac
|