Skip to content

Instantly share code, notes, and snippets.

@DalyaG
Created May 9, 2020 20:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DalyaG/48367a5fd3b4355fb1be45195489e1f9 to your computer and use it in GitHub Desktop.
Save DalyaG/48367a5fd3b4355fb1be45195489e1f9 to your computer and use it in GitHub Desktop.
Sanity Check for Mel Spectrogram Computation
# Sanity check that indeed we understood the underlying pipeline
S = librosa.feature.melspectrogram(whale_song, sr=sr, n_fft=n_fft, hop_length=hop_length, n_mels=n_mels)
fft_windows = librosa.stft(whale_song, n_fft=n_fft, hop_length=hop_length)
magnitude = np.abs(fft_windows)**2
mel = librosa.filters.mel(sr=sr, n_fft=n_fft, n_mels=n_mels)
assert (mel.dot(magnitude) == S).all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment