File size: 695 Bytes
18c46ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import requests

# Define the API endpoint
url = "https://mmesa-websutmmit2024.onrender.com/analyze-stress/"

# Path to the audio file you want to analyze
file_path = "../assets/audio/fitness.wav"

# Open the file in binary mode and send the request
with open(file_path, "rb") as audio_file:
    files = {"file": ("audio.wav", audio_file, "audio/wav")}
    response = requests.post(url, files=files)

# Check if the request was successful
if response.status_code == 200:
    result = response.json()
    print("Stress Level:", result["stress_level"])
    print("Category:", result["category"])
    print("Gender:", result["gender"])
else:
    print("Error:", response.status_code, response.text)