I am working on speech synthesis and I have constructed spectrograms using librosa. When I want to convert the spectrogram into audio to save as wav file, it creates problem. I looked for help and found that liborsa have a function mel_to_audio but that isn't working.
I used this function to get spectrogram of audio file.
librosa.feature.melspectrogram
Here is the function I am using to convert spectrogram to audio.
librosa.feature.inverse.mel_to_audio
But I am getting this error.
ModuleNotFoundError: No module named 'librosa.feature.inverse'
This is how I am reading file using librosa.
def read_audio_from_filename(filename):
audio, sr = librosa.load(filename)
D = np.abs(librosa.stft(audio))**2
audio= librosa.feature.melspectrogram(y=audio, sr=sr, S=D)
return audio
Is there any otherway to convert mel to audio and save it as wav file?
Minimal example:
import librosa
import librosa.display
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def read_audio_from_filename(filename):
audio, sr = librosa.load(filename)
D = np.abs(librosa.stft(audio))**2
audio= librosa.feature.melspectrogram(y=audio, sr=sr, S=D)
return audio
def convert_data():
wav_filename = "Audio/Audio1.wav"
audio = read_audio_from_filename(wav_filename)
return audio
specto = convert_data()
res = librosa.feature.inverse.mel_to_audio(specto)
This is the error:
AttributeError: module 'librosa.feature' has no attribute 'inverse'
mel)
,librosa.display_to_audio
does not seem to exist.DATA_AUDIO_DIR
is not defined. The imports forjoin
andiglob
are missing. Also, the full error stack is missing. – Hendrik