-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrontend.py
More file actions
25 lines (20 loc) · 911 Bytes
/
frontend.py
File metadata and controls
25 lines (20 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import streamlit as st
import requests
st.title("🎤 Voice Stress & Depression Detector")
st.write("Upload or record your voice to analyze stress levels.")
uploaded_file = st.file_uploader("Upload your voice sample (WAV file)", type=["wav"])
if uploaded_file is not None:
st.audio(uploaded_file, format='audio/wav')
if st.button("Analyze"):
files = {"file": uploaded_file.getvalue()}
try:
response = requests.post("http://127.0.0.1:5000/analyze", files=files)
result = response.json()
if "error" in result:
st.error(f"Error: {result['error']}")
else:
st.success(f"Stress Level: {result['stress_level']}")
st.write(f"Pitch: {result['pitch']:.2f}")
st.write(f"Energy: {result['energy']:.4f}")
except Exception as e:
st.error(f"Connection error: {e}")