import numpy as np
import matplotlib.pyplot as plt
import IPython.display as ipd
import librosa
import librosa.display
x, sr = librosa.load("Billy.wav")
S = librosa.stft(x)
fig, ax = plt.subplots()
img = librosa.display.specshow(librosa.amplitude_to_db(np.abs(S),ref=np.max), y_axis='linear', x_axis='time', ax=ax)
ax.set_title('Power spectrogram')
fig.colorbar(img, ax=ax, format="%+2.0f dB")
ipd.Audio(x, rate=sr)
f = np.arange(S.shape[0])
t = np.arange(S.shape[1])
A = np.exp(-t[None, :]*f[:, None]/(100*S.shape[1]))
librosa.display.specshow(A, y_axis='linear', x_axis='time')
SNew = S*A
fig, ax = plt.subplots()
img = librosa.display.specshow(librosa.amplitude_to_db(np.abs(SNew),ref=np.max), y_axis='linear', x_axis='time', ax=ax)
ax.set_title('Power spectrogram')
fig.colorbar(img, ax=ax, format="%+2.0f dB")
y = librosa.istft(SNew)
ipd.Audio(y, rate=sr)