import gradio as gr | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from scipy.io import wavfile | |
def create_spectrogram(audio_data, sample_rate): | |
# Crea lo spettrogramma | |
plt.specgram(audio_data, Fs=sample_rate) | |
# Salva lo spettrogramma in un file PNG | |
plt.savefig('spectrogram.png') | |
# Ritorna il file PNG dello spettrogramma | |
return 'spectrogram.png' | |
# Crea l'interfaccia Gradio | |
iface = gr.Interface(fn=create_spectrogram, inputs=gr.Audio(), outputs="image", enable_queue=False) | |
iface.launch() | |