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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pghipy-0.1.1.tar.gz
(4.0 kB
view details)
File details
Details for the file pghipy-0.1.1.tar.gz.
File metadata
- Download URL: pghipy-0.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b44d157324ade4913a5eaf6055f164609bb67b160fa27e4d7fa97bbc1e7f164
|
|
| MD5 |
94b5e9071b091b3d1cb1ce9d0dba3b9e
|
|
| BLAKE2b-256 |
16d2eba3364362a29c8e10df6b2b6351a698fc7dff6f514abaa1a9a33a19df4f
|