Hi
Thank you for your response.
Let me share the complete step.
CASE 1: Audio file is loaded at sr = 48000
D = np.abs(librosa.stft(wav_file1,
win_length = 2048,
hop_length = 2048,
n_fft = 2048,
window = hamming,
center = False))**2
S1 = librosa.feature.melspectrogram(S = D, sr = 48000, n_mels=128, htk = True)
fig, ax = plt.subplots()
S_dB = librosa.power_to_db(S1, ref=np.max)
img = librosa.display.specshow(S_dB, x_axis='time', y_axis='mel', sr=48000, ax=ax)
fig.colorbar(img, ax=ax, format='%+2.0f dB')
ax.set(title='Mel-frequency spectrogram')
CASE 2: Audio file is loaded at sr = 22050
D = np.abs(librosa.stft(wav_file1,
win_length = 2048,
hop_length = 2048,
n_fft = 2048,
window = hamming,
center = False))**2
S1 = librosa.feature.melspectrogram(S = D, sr = 48000, n_mels=128, htk = True)
fig, ax = plt.subplots()
S_dB = librosa.power_to_db(S1, ref=np.max)
img = librosa.display.specshow(S_dB, x_axis='time', y_axis='mel', sr=22050, ax=ax)
fig.colorbar(img, ax=ax, format='%+2.0f dB')
ax.set(title='Mel-frequency spectrogram')
I intentionally put sr = 48000 while calculating melspectrogram. I want to understand how it is shifting the spectrum. Can it change the spectrum if choose different sampling rate? If it does then how?