Skip to content

Instantly share code, notes, and snippets.

@pragatibaheti
Created April 26, 2020 12:27
Show Gist options
  • Save pragatibaheti/8f60615a315e00f58ba6e47c1d9afcff to your computer and use it in GitHub Desktop.
Save pragatibaheti/8f60615a315e00f58ba6e47c1d9afcff to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
y, sr = librosa.load(audio_file.wav, offset=30, duration=10)
y_filt = librosa.effects.preemphasis(y)
# and plot the results for comparison
S_orig = librosa.amplitude_to_db(np.abs(librosa.stft(y)), ref=np.max)
S_preemph = librosa.amplitude_to_db(np.abs(librosa.stft(y_filt)), ref=np.max)
librosa.display.specshow(S_orig, y_axis='log', x_axis='time')
plt.title('Original signal')
librosa.display.specshow(S_preemph, y_axis='log', x_axis='time')
plt.title('Pre-emphasized signal')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment