28 lines
736 B
Python
28 lines
736 B
Python
import matplotlib.pyplot as plt
|
|
import librosa
|
|
import mlflow
|
|
|
|
|
|
SAMPLE_RATE = 22050
|
|
|
|
def logSpec(spec,e):
|
|
spec = ((spec*80)-80)
|
|
#spec = librosa.db_to_amplitude(spec)
|
|
plt.figure(figsize=(10, 4))
|
|
librosa.display.specshow(spec, sr=SAMPLE_RATE,
|
|
x_axis='time', y_axis='mel',
|
|
cmap='viridis')
|
|
plt.colorbar(format='%+2.0f dB')
|
|
plt.title('Mel spectrogram')
|
|
mlflow.log_figure(plt.gcf(), f"output_{e}.png")
|
|
plt.close()
|
|
|
|
def playSpec(spec):
|
|
S = librosa.feature.inverse.mel_to_stft(spec, sr=SAMPLE_RATE)
|
|
audio = librosa.griffinlim(S,n_iter=25,momentum=0.99)
|
|
|
|
plt.figure(figsize=(12,4))
|
|
plt.plot(audio)
|
|
plt.title('waveform')
|
|
plt.close()
|