Last active
February 5, 2023 02:40
-
-
Save ketanhdoshi/35f19156e18e4cb771564b1c58041594 to your computer and use it in GitHub Desktop.
Transform Mel Spectrogram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------------------- | |
# Generate a Spectrogram | |
# ---------------------------- | |
@staticmethod | |
def spectro_gram(aud, n_mels=64, n_fft=1024, hop_len=None): | |
sig,sr = aud | |
top_db = 80 | |
# spec has shape [channel, n_mels, time], where channel is mono, stereo etc | |
spec = transforms.MelSpectrogram(sr, n_fft=n_fft, hop_length=hop_len, n_mels=n_mels)(sig) | |
# Convert to decibels | |
spec = transforms.AmplitudeToDB(top_db=top_db)(spec) | |
return (spec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@staticmethod
def spectro_gram(aud, n_mels=64, n_fft=1024, hop_len=None):
sig,sr = aud
top_db = 80
@harthalhmati2000