|
import streamlit as st |
|
import soundfile as sf |
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
|
|
|
|
st.title("An谩lisis de Se帽al de Audio") |
|
|
|
|
|
audio_file = st.file_uploader("Cargar archivo de audio", type=["wav", "flac", "ogg", "mp3"]) |
|
|
|
|
|
def calculate_envelope(audio): |
|
signal, sr = sf.read(audio) |
|
abs_signal = np.abs(signal) |
|
envelope = np.convolve(abs_signal, np.ones(100)/100, mode='same') |
|
return envelope |
|
|
|
|
|
if audio_file is not None: |
|
if st.button("Calcular envolvente"): |
|
envelope = calculate_envelope(audio_file) |
|
|
|
|
|
plt.plot(envelope) |
|
plt.title("Envolvente de la se帽al de audio") |
|
plt.xlabel("Tiempo (muestras)") |
|
plt.ylabel("Amplitud") |
|
st.pyplot(plt) |
|
|