Scipy provides the FFT and inverse FFT functions useful for sound processing.
Example:
import soundfile as sf
from scipy.fftpack import fft, ifft
with open('1.wav', 'rb') as f_wav:
x, rate = sf.read(f_wav)
X = fft(x)
#The ifft function returns a complex variable, but the imaginary part is quite small to be neglected.
y_complex = ifft(X)
y = y_complex.real
sf.write('2.wav', y, 16000)
Reference:
Matlab: Discrete Cosine Transform (DCT) for speech processing (StudyEECC)
Python: Discrete Cosine Transform (DCT) for speech processing (StudyRaspberryPi)
Fourier Transforms (scipy.fft)
scipy and numpy inverse fft returns complex numbers not floats, can't save as wav (StackOverflow)
Python - How to use Soundfile to read and write WAV and FLAC files (Study Raspberry Pi)