Spaces:
Runtime error
Runtime error
import gradio as gr | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from scipy.io import wavfile | |
def create_spectrogram(audio_file): | |
# Leggi il file audio | |
sample_rate, data = wavfile.read(audio_file.name) | |
# Crea lo spettrogramma | |
plt.specgram(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.inputs.File(type="audio"), outputs="image") | |
iface.launch() | |