justinjohn0306 / FakeYou-Tacotron2-Notebook

Tacotron2 Training Notebook for FakeYou.com
151 stars 44 forks source link

Can't convert WAVs to Mel-Spectrograms #12

Open XEROxMEXICANO opened 1 year ago

XEROxMEXICANO commented 1 year ago

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

YTR76 commented 1 year ago

your wavs aren't mono

elmehdihammouch commented 9 months ago

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.