Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't convert WAVs to Mel-Spectrograms #12

Open
xenon0054 opened this issue Apr 22, 2023 · 2 comments
Open

Can't convert WAVs to Mel-Spectrograms #12

xenon0054 opened this issue Apr 22, 2023 · 2 comments

Comments

@xenon0054
Copy link

image
I can't get this working, any suggestions?

@YTR76
Copy link

YTR76 commented May 12, 2023

your wavs aren't mono

@elmehdihammouch
Copy link

To address this issue in my situation, I resolved it by modifying the code within the 'create_mels' function to the following:
import librosa
import glob

def create_mels():
print("Generating Mels")

def save_mel_librosa(filename):
    # Load audio file
    audio, sampling_rate = librosa.load(filename, sr=None)

    # Compute mel spectrogram
    melspec = librosa.feature.melspectrogram(y=audio, sr=sampling_rate, n_mels=128)

    # Convert to decibels (log scale)
    melspec_db = librosa.power_to_db(melspec, ref=np.max)

    # Save mel spectrogram as NumPy file
    output_filename = filename.replace('.wav', '')
    np.save(output_filename, melspec_db)

wavs = glob.glob('wavs/*.wav')
for i in tqdm(wavs):
    save_mel_librosa(i)

I hope that be helpful for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants