Skip to main content

pghipy: Phase Gradient Heap Integration in Python

A Python implementation of STFT/ISTFT transforms and phase recovery using Phase Gradient Heap Integration. Based on code from phase-reconstruction and tifgan/phase_recovery. The package does not require installation of ltfatpy and works in Windows/MacOS/Linux.

Installation

pip install pghipy

Usage

import librosa
import numpy as np
from pghipy import get_default_window, calculate_synthesis_window
from pghipy import stft, pghi, istft

NFFT = 1024
HOP = NFFT//8   # Increasing overlap improves phase recovery

# Create Gaussian windows
winpghi, gamma = get_default_window(NFFT)
winsynth = calculate_synthesis_window(NFFT, HOP, winpghi)

# Magnitude spectrogram
y, sr = librosa.load(librosa.example('trumpet'))
S = np.abs(stft(y,win_length=NFFT,hop_length=HOP,window=winpghi))

# Estimate phase
phase = pghi(S,win_length=NFFT,hop_length=HOP,gamma=gamma)

# Invert
S = S*np.exp(1.0j*phase)
y_inv = istft(S,win_length=NFFT,hop_length=HOP,synthesis_window=winsynth)

Note: Uses numba JIT compiler to obtain a significant speed-up in phase recovery. Compilation is deferred until the first execution of the function pghi (i.e., lazy compilation).

Dependencies

  • numpy
  • scipy
  • numba

Thanks

Richard Lyman rrlyman

Andrés Marafioti andimarafioti

License

The MIT License (MIT)

Metadata

Release files for pghipy 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pghipy 0.1.1
File Size Uploaded Provenance Actions
pghipy-0.1.1.tar.gz 4.0 kB Without provenance Details for pghipy-0.1.1.tar.gz

Release files / pghipy-0.1.1.tar.gz

Download URL pghipy-0.1.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0b44d157324ade4913a5eaf6055f164609bb67b160fa27e4d7fa97bbc1e7f164
BLAKE2b-256 checksum
How to use checksums
16d2eba3364362a29c8e10df6b2b6351a698fc7dff6f514abaa1a9a33a19df4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

Security for pghipy 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page