Skip to main content

A Python implementation of the correlation based glimpse proportion (CGP) index

Project description

cgp

A Python implementation of the correlation based glimpse proportion (CGP) index proposed in [1] for speech intelligibility prediction.

Supports batched inputs.

Installation

pip install python-cgp

Usage

import cgp
import soundfile as sf

x, fs = sf.read("path/to/input/signal")
y, fs = sf.read("path/to/reference/signal")

z = cgp.cgp(x, y, fs)

For batched inputs:

import cgp
import numpy as np
import soundfile as sf

x_1, fs = sf.read("path/to/input/signal/1")
y_1, fs = sf.read("path/to/reference/signal/1")

x_2, fs = sf.read("path/to/input/signal/2")
y_2, fs = sf.read("path/to/reference/signal/2")

# x_1 and x_2 might have different lengths so we pad before creating the batch
lengths = [len(x_1), len(x_2)]
n = max(lengths)
x_1 = np.pad(x_1, (0, n - len(x_1)))
y_1 = np.pad(y_1, (0, n - len(y_1)))
x_2 = np.pad(x_2, (0, n - len(x_2)))
y_2 = np.pad(y_2, (0, n - len(y_2)))

# create the batch
x = np.stack([x_1, x_2])
y = np.stack([y_1, y_2])

# provide the lengths argument to ensure the same result as for unbatched processing
z = cgp.cgp(x, y, fs, axis=1, lengths=lengths)

Note

This implementation corrects an indexing error in the original MATLAB code in removeSilentFrames.m which causes the last frame in the voice activity detection stage to be discarded. This means the results can differ slightly from the original implementation. To obtain the same results as the original implementation, set the _discard_last_frame argument to True.

Speed comparison with pystoi

The paper claims CGP takes substantially less time to execute compared to baselines such as ESTOI [2]. Below is a comparison with pystoi for unbatched inputs.

TODO

References

[1] A. Alghamdi, L. Moen, W.-Y. Chan, D. Fogerty and J. Jensen, "Correlation based glimpse proportion index", in Proc. WASPAA, 2023.
[2] J. Jensen and C. H. Taal, "An algorithm for predicting the intelligibility of speech masked by modulated noise maskers", in IEEE/ACM Trans. Audio, Speech, Lang. Process., 2016.

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

python-cgp-0.0.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

python_cgp-0.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file python-cgp-0.0.1.tar.gz.

File metadata

  • Download URL: python-cgp-0.0.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for python-cgp-0.0.1.tar.gz
Algorithm Hash digest
SHA256 53396c47c242dfe5f6c2fa2175c2ace3e52bd33de41b1aaa44ac1ec042a5059e
MD5 c9c8e158755b43f407be752e79389c7d
BLAKE2b-256 6c7383193abc13119f57bd52920703f3ae723a67b5d8f01f3ce98bd10e8a2686

See more details on using hashes here.

File details

Details for the file python_cgp-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: python_cgp-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for python_cgp-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 024abd23a36d368656a8f2905be25cddc8ab419b73ea9d18f281371a408bc9e4
MD5 afc47176b2438d549ff90d3d71690741
BLAKE2b-256 2038c46329d297ce5e78d11174a12661e146e063436dc19044e03442ce8e18cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page