fix spectogram

This commit is contained in:
Ali Abid 2020-09-22 14:18:40 -07:00
parent 3b4a33c7ec
commit f56a936cac

View File

@ -8,13 +8,14 @@ from scipy import signal
def spectrogram(audio):
sr, data = audio
data = np.delete(data, 1, 1).reshape(-1)
frequencies, times, spectrogram_data = signal.spectrogram(data.reshape(-1), sr, window="hamming")
if len(data.shape) == 2:
data = np.mean(data, axis=0)
frequencies, times, spectrogram_data = signal.spectrogram(data, sr, window="hamming")
plt.pcolormesh(times, frequencies, np.log10(spectrogram_data))
return plt
io = gr.Interface(spectrogram, "audio", "plot
io = gr.Interface(spectrogram, "audio", "plot")
io.test_launch()
io.launch()