Skip to main content

A-SEM: Accelerated Speech Enhancement Metrics

A high-performance PyTorch library for computing speech quality metrics with GPU acceleration. Includes optimized implementations of PESQ, STOI, SDR, LSD, DNSMOS, and SpeechBERTScore.

Installation

Either download it directly through pip

pip install asem

or clone this repo and run (make sure uv is installed):

uv sync
source .venv/bin/activate

Usage

import torch
from asem import PESQ, STOI, SDR, LSD, DNSMOS, SpeechBERTScore

# Load your audio (shape: [batch_size, samples])
# 4 samples, 10 second each at 16kHz
clean_speech = torch.randn(4, 160000)
noisy_speech = torch.randn(4, 160000)

# Initialize metrics
pesq = PESQ(sample_rate=16000, use_gpu=True)
stoi = STOI(sample_rate=16000, use_gpu=True)
sdr = SDR(sample_rate=16000, use_gpu=True)

# Compute metrics
pesq_scores = pesq(clean_speech, noisy_speech)
stoi_scores = stoi(clean_speech, noisy_speech)
sdr_scores = sdr(clean_speech, noisy_speech)

print(pesq_scores)  # [{'PESQ': 2.1}, {'PESQ': 1.8}, ...]
print(stoi_scores)  # [{'STOI': 0.85, 'ESTOI': 0.82}, ...]

To work with variable-length utterances, pad the waveforms to a common length and pass the true sample counts via the optional lengths argument:

from torch.nn.utils.rnn import pad_sequence

clean_utterances = [torch.randn(120000), torch.randn(90000), torch.randn(143200)]
noisy_utterances = [torch.randn_like(x) for x in clean_utterances]

clean_batch = pad_sequence(clean_utterances, batch_first=True)
noisy_batch = pad_sequence(noisy_utterances, batch_first=True)
lengths = torch.tensor([x.shape[-1] for x in clean_utterances])

pesq_scores = pesq(clean_batch, noisy_batch, lengths=lengths)

Performance

Our GPU-accelerated implementations provide significant speedups over existing libraries:

Performance Comparison

while maintaining results that are extremely close to the originals

Performance Comparison

Available Metrics

Metric Description Reference Reference Implementation
PESQ Perceptual Evaluation of Speech Quality (ITU P.862) Berends et al. ludlows, AudioLabs
(E)STOI (Extended) Short-Time Objective Intelligibility Taal et al., Jensen & Taal mpariente
SDR Signal-to-Distortion Ratio Vincent et al., Scheibler TorchMetrics
LSD Log-Spectral Distance Braun & Tashev Urgent2025
DNSMOS Deep Noise Suppression Mean Opinion Score Reddy et al. DNS-Challenge
SpeechBERTScore Semantic similarity using speech embeddings Saeki et al. Urgent2025

Benchmarking

To run benchmarks on your system:

python benchmark_metrics.py
python plot_results.py

Acknowledgments

The PESQ implementation is based on the excellent work by audiolabs/torch-pesq.

Metadata

Release files for asem 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asem 1.0.0
File Size Uploaded Provenance
asem-1.0.0.tar.gz 2.8 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for asem 1.0.0
File Interpreter ABI Platform
asem-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.9 MB

Release files / asem-1.0.0.tar.gz

Download URL asem-1.0.0.tar.gz
Size 2.8 MB
Tags Source
SHA-256 checksum
How to use checksums
faa5d2bf806489db1d262db1bba8aae10e67172b50e40d5351c4f8c718d7c9ea
BLAKE2b-256 checksum
How to use checksums
8fd436ac8468d0666cd2b9ab919081bf165c0dac7ff4c38017f3b3b564564cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / asem-1.0.0-py3-none-any.whl

Download URL asem-1.0.0-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
62d217bed066338921ccbb01cfbf5221925b3e1bbeb10204513c0073776f95f1
BLAKE2b-256 checksum
How to use checksums
23ebc96af173d8aa44d1723d04835b833425a272bdacd3c732beaa722f10801e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Security for asem 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page