mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
18 lines
450 B
Python
18 lines
450 B
Python
|
import gradio as gr
|
||
|
import matplotlib.pyplot as plt
|
||
|
import numpy as np
|
||
|
from scipy import signal
|
||
|
from scipy.io import wavfile
|
||
|
|
||
|
|
||
|
def reverse_audio(audio):
|
||
|
sr, data = audio
|
||
|
data = np.delete(data, 1, 1).reshape(-1)
|
||
|
frequencies, times, spectrogram = signal.spectrogram(data.reshape(-1), sr, window="hamming")
|
||
|
|
||
|
plt.pcolormesh(times, frequencies, np.log10(spectrogram))
|
||
|
return plt
|
||
|
|
||
|
|
||
|
gr.Interface(reverse_audio, "audio", "plot").launch()
|