Skip to content

Instantly share code, notes, and snippets.

@AyishaR
Created March 15, 2021 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AyishaR/66afa617473f1fa238b8293f5ea55aaa to your computer and use it in GitHub Desktop.
Save AyishaR/66afa617473f1fa238b8293f5ea55aaa to your computer and use it in GitHub Desktop.
# hop_len=int(win_len/4) # default
# fft_len=pow(2, int(np.log2(win_len)+1))
fft_len = 2048
win_len = fft_len
hop_len = int(win_len/4)
def spectrogramOp(X):
spectrogram_out = librosa.core.stft(X, n_fft=fft_len, hop_length=hop_len, win_length=win_len, center=True)
return np.absolute(spectrogram_out)
input_spectrogram = np.empty((input_audio.shape[0], int(fft_len/2 + 1), int(desired_samples/hop_len + 1))).astype(np.float32)
i = 0 ;
for input in input_audio:
input_spectrogram[i] = spectrogramOp(input)
i = i + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment