nahue-passano
commited on
Commit
•
b61fa10
1
Parent(s):
ba69f04
initial commit
Browse files- .python-version +1 -0
- audio_cloud_service/app.py +29 -0
- poetry.lock +0 -0
- pyproject.toml +19 -0
.python-version
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.9
|
audio_cloud_service/app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import soundfile as sf
|
3 |
+
import numpy as np
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
|
6 |
+
# Configuración de la página de Streamlit
|
7 |
+
st.title("Análisis de Señal de Audio")
|
8 |
+
|
9 |
+
# Carga del archivo de audio
|
10 |
+
audio_file = st.file_uploader("Cargar archivo de audio", type=["wav", "flac", "ogg", "mp3"])
|
11 |
+
|
12 |
+
# Función para calcular la envolvente
|
13 |
+
def calculate_envelope(audio):
|
14 |
+
signal, sr = sf.read(audio)
|
15 |
+
abs_signal = np.abs(signal)
|
16 |
+
envelope = np.convolve(abs_signal, np.ones(100)/100, mode='same') # Suavizado con promedio móvil
|
17 |
+
return envelope
|
18 |
+
|
19 |
+
# Procesamiento y visualización del resultado
|
20 |
+
if audio_file is not None:
|
21 |
+
if st.button("Calcular envolvente"):
|
22 |
+
envelope = calculate_envelope(audio_file)
|
23 |
+
|
24 |
+
# Visualización de la envolvente
|
25 |
+
plt.plot(envelope)
|
26 |
+
plt.title("Envolvente de la señal de audio")
|
27 |
+
plt.xlabel("Tiempo (muestras)")
|
28 |
+
plt.ylabel("Amplitud")
|
29 |
+
st.pyplot(plt)
|
poetry.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pyproject.toml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[tool.poetry]
|
2 |
+
name = "audio-cloud-service"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = ""
|
5 |
+
authors = ["nahue-passano <passano43632@estudiantes.untref.edu.ar>"]
|
6 |
+
readme = "README.md"
|
7 |
+
packages = [{include = "audio_cloud_service"}]
|
8 |
+
|
9 |
+
[tool.poetry.dependencies]
|
10 |
+
python = ">=3.9,<3.9.7 || >3.9.7,<3.11"
|
11 |
+
numpy = "^1.25.0"
|
12 |
+
streamlit = "^1.24.0"
|
13 |
+
soundfile = "^0.12.1"
|
14 |
+
matplotlib = "^3.7.1"
|
15 |
+
|
16 |
+
|
17 |
+
[build-system]
|
18 |
+
requires = ["poetry-core"]
|
19 |
+
build-backend = "poetry.core.masonry.api"
|