skillfed

torch-stoi

Computes Short Term Objective Intelligibility in PyTorch

torch-stoi v0.2.3 427.6K downloads/30d#6,749 on PyPI107
Permissive license MIT DORMANT released

What it is and what it does

torch_stoi is a PyTorch implementation of the Short Term Objective Intelligibility (STOI) metric, designed specifically for use as a differentiable loss function in neural network training. It wraps the classical and extended STOI measures—metrics originally developed to predict speech intelligibility in noisy conditions—into a form that PyTorch can backpropagate through. The package depends on numpy, torch, pystoi, and torchaudio to compute the metric.

The implementation is intentionally approximate rather than exact: it trades perfect fidelity to the original STOI algorithm for computational efficiency and differentiability in a training loop. The documentation explicitly warns that it is intended only as a loss function, not as a replacement for the original metric when exact reproducibility matters. This makes it suitable for training speech enhancement or denoising models where STOI-like objectives guide the network, but not for rigorous evaluation benchmarking.

Use it for:

  • Train a speech denoising network using NegSTOILoss as the primary loss function to optimize for intelligibility rather than raw signal fidelity.
  • Combine NegSTOILoss with other losses in a multi-objective speech enhancement model to balance intelligibility and artifact reduction.
  • Validate speech enhancement models on STOI-like criteria during training without switching to a separate evaluation pipeline.
  • Experiment with speech quality metrics in PyTorch workflows where torchaudio and torch are already in use.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Computes Short Term Objective Intelligibility (STOI) as a PyTorch loss function for training speech enhancement models, wrapping the classical and extended STOI metrics in differentiable form.

Yes, if you are training a PyTorch speech enhancement model and want STOI as a loss function. Install friction is low and the license is permissive. However, the dormant maintenance status (no releases for 683 days) and the documented approximation—not exact replication—of the original metric mean you should verify that the implementation's behavior matches your training requirements before committing to it in production. No known security vulnerabilities.

Install

torch-stoi on PyPI

pip

pip install torch-stoi

uv

uv add torch-stoi

poetry

poetry add torch-stoi

Installing torch-stoi

Before you install

Low friction—pure Python wheel with four runtime dependencies (numpy, torch, pystoi, torchaudio). Dormant maintenance status (last commit 2024-09-30, no releases for 683 days) means no active bug fixes or feature work, but the narrow scope and stable API reduce risk.

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install torch_stoi

import torch
from torch_stoi import NegSTOILoss

sample_rate = 16000
loss_func = NegSTOILoss(sample_rate=sample_rate)
noisy_speech = torch.randn(2, 16000)
clean_speech = torch.randn(2, 16000)
loss = loss_func(noisy_speech, clean_speech)

Verify before relying

  • Whether the PyTorch implementation's approximation error relative to the original STOI metric is acceptable for your specific training task (documentation notes results 'should be close enough' but exact quantitative bounds are not provided).
  • Minimum Python version and PyTorch version compatibility (requires_python is unspecified in the fact sheet).

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 4 — numpy, torch, pystoi, torchaudio
Maintenance dormant — 683 days since the last release
Last repo commit
First released
Downloads 427,554/month — #6,749 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: torch_stoi-0.2.3-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3

Tags

speech intelligibility loss pytorchstoi loss functionspeech enhancement training metricaudio quality loss pytorchspeech denoising objectivedifferentiable stoi metric
speech-processingloss-functionaudio-ml

More Artificial Intelligence packages