Answer the question
In order to leave comments, you need to log in
Why is the original and restored sound different?
Good afternoon. I wrote this code.
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, sr = None)
print(sr)
D = np.abs(librosa.stft(audio))**2
audio= librosa.feature.melspectrogram(y=audio, sr=sr, S=D)
return audio
def convert_data():
wav_filename = "path"
audio = read_audio_from_filename(wav_filename)
return audio
specto = convert_data()
res = librosa.feature.inverse.mel_to_audio(specto)
sf.write('path-1', res, 44100, 'PCM_24')
ipd.display(ipd.Audio('path'))
ipd.display(ipd.Audio('path-1'))
Answer the question
In order to leave comments, you need to log in
I think because the default settings greatly spoil the audio recording. It is necessary to fine-tune the library when loading audio.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question