Skip to main content

GPU-accelerated PyTorch implementations of speech quality metrics (PESQ, STOI, SDR, LSD, DNSMOS, SpeechBERTScore).

Project description

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.

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

asem-1.0.0.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

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

asem-1.0.0-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file asem-1.0.0.tar.gz.

File metadata

  • Download URL: asem-1.0.0.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for asem-1.0.0.tar.gz
Algorithm Hash digest
SHA256 faa5d2bf806489db1d262db1bba8aae10e67172b50e40d5351c4f8c718d7c9ea
MD5 c016ab5f599220248b550ca47fd584dd
BLAKE2b-256 8fd436ac8468d0666cd2b9ab919081bf165c0dac7ff4c38017f3b3b564564cd4

See more details on using hashes here.

File details

Details for the file asem-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: asem-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for asem-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62d217bed066338921ccbb01cfbf5221925b3e1bbeb10204513c0073776f95f1
MD5 2dfc2b50830fa478f74b0e9d44443210
BLAKE2b-256 23ebc96af173d8aa44d1723d04835b833425a272bdacd3c732beaa722f10801e

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 Pingdom Monitoring Sentry Error logging StatusPage Status page