cleanup/rewrite
This commit is contained in:
26
show.py
Normal file
26
show.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import IPython.display as ipd
|
||||
import librosa
|
||||
|
||||
|
||||
SAMPLE_RATE = 22050
|
||||
|
||||
def showSpec(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')
|
||||
plt.show()
|
||||
|
||||
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.show()
|
||||
|
||||
display(ipd.Audio(audio,rate=SAMPLE_RATE))
|
||||
Reference in New Issue
Block a user