Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Facebookresearch Audiocraft PesqMetric

From Leeroopedia
Knowledge Sources
Domains Audio_Metrics, Speech_Quality
Last Updated 2026-02-14 01:00 GMT

Overview

Concrete tool for computing PESQ (Perceptual Evaluation of Speech Quality) scores between generated and reference audio.

Description

PesqMetric wraps the PESQ library as a torchmetrics-compatible metric. It resamples audio to 16 kHz, computes per-sample PESQ scores, and aggregates across the batch. Samples where no speech is detected are silently skipped.

Usage

Import this metric when evaluating audio compression or watermarking quality on speech-like signals.

Code Reference

Source Location

Signature

class PesqMetric(torchmetrics.Metric):
    def __init__(self, sample_rate: int): ...
    def update(self, preds: torch.Tensor, targets: torch.Tensor): ...
    def compute(self) -> torch.Tensor: ...

Import

from audiocraft.metrics.pesq import PesqMetric

I/O Contract

Inputs

Name Type Required Description
preds torch.Tensor Yes Predicted audio [B, C, T]
targets torch.Tensor Yes Reference audio [B, C, T]

Outputs

Name Type Description
pesq_score torch.Tensor Mean PESQ score

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment