pystoi is a Python library that computes the Short Term Objective Intelligibility (STOI) measure, a metric highly correlated with the subjective intelligibility of degraded speech signals. It is an intrusive measure, requiring both clean and degraded speech inputs. It serves as an objective alternative for evaluating the effect of non-linear processing like noise reduction or binary masking on speech intelligibility. The current version is 0.4.1, and its development appears to be in maintenance mode.
pip install pystoiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to compute the STOI score between a clean and a degraded speech signal. It uses `soundfile` to read the audio, then calls the `stoi` function with the clean signal, degraded signal, and sampling frequency. The `extended` parameter can be set to `True` for extended STOI.
Ensure `clean_audio` and `denoised_audio` numpy arrays have identical `shape` before passing them to `stoi`.
Process audio files one by one in a loop, or consider alternative libraries/forks if batch processing is critical for your workflow.
Be aware of performance limitations for very large datasets; ensure your environment is optimized for CPU-bound tasks.
If exact STOI values are required, rely on the `pystoi` library. If an approximate STOI suitable for gradient-based optimization in PyTorch is needed, `pytorch_stoi` might be considered, but be aware of the numerical differences.
Install the library using pip: `pip install pystoi`
Ensure both input signals have the same length by trimming or padding one of them: `min_len = min(len(clean_speech), len(degraded_speech)); score = pystoi.stoi(clean_speech[:min_len], degraded_speech[:min_len], fs_sig=16000)`
Provide the correct sampling rate (in Hz) for your speech signals: `import pystoi; score = pystoi.stoi(clean_speech, degraded_speech, fs_sig=16000)`
Call the `stoi` function directly from the `pystoi` package or import it: `import pystoi; score = pystoi.stoi(clean_speech, degraded_speech, fs_sig=16000)`