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
winpghi, gamma = get_default_window(NFFT)
winsynth = calculate_synthesis_window(NFFT, HOP, winpghi)
y, sr = librosa.load(librosa.example('trumpet'))
S = np.abs(stft(y,win_length=NFFT,hop_length=HOP,window=winpghi))
phase = pghi(S,win_length=NFFT,hop_length=HOP,gamma=gamma)
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
Thanks
Richard Lyman rrlyman
Andrés Marafioti andimarafioti
License
The MIT License (MIT)