0

There is a code which generates mel-spectrogram for mono audio.

import librosa, librosa.display
import matplotlib.pyplot as plt
import numpy as np
file = "C:/Users/User/Desktop/sound.wav"
y, sr = librosa.load(file, sr=48000)
librosa.feature.melspectrogram(y=y, sr=sr)
S = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128, fmax=12000)
S_dB = librosa.power_to_db(S, ref=np.max)
lr.display.specshow(S_dB, x_axis='time', y_axis='mel', sr=sr, fmax=12000)
plt.colorbar(format='%+2.0f dB')
plt.title('Mel-spektrogram')
plt.tight_layout()
plt.show()

Is there any possibility to rewrite the code so that it can generate mel-spectrogram for stereophonic audio? If not how else can i do it?

asked Oct 19, 2020 at 13:34

1 Answer 1

1

To get multi-channel data you need to use librosa.load(..., mono=False). The shape of y will then be (channels, samples). You can then compute the mel-spectrogram separately for each of the channels.

answered Oct 20, 2020 at 8:13
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.