TheStinger's picture
Update app.py
1762dd4
raw
history blame
583 Bytes
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()