Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py (or main.py if no FastAPI)
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
API_URL = "http://127.0.0.1:7860/api/v1/voice/score" # internal FastAPI
|
| 6 |
+
|
| 7 |
+
def score_vocal(audio_file):
|
| 8 |
+
# send audio to FastAPI endpoint
|
| 9 |
+
with open(audio_file.name, "rb") as f:
|
| 10 |
+
files = {"file": f}
|
| 11 |
+
response = requests.post(API_URL, files=files)
|
| 12 |
+
|
| 13 |
+
if response.status_code == 200:
|
| 14 |
+
return response.json()["fatigue_score"]
|
| 15 |
+
else:
|
| 16 |
+
return f"Error: {response.status_code}"
|
| 17 |
+
|
| 18 |
+
# Gradio interface (even minimal)
|
| 19 |
+
iface = gr.Interface(
|
| 20 |
+
fn=score_vocal,
|
| 21 |
+
inputs=gr.Audio(type="file"),
|
| 22 |
+
outputs=gr.Textbox(label="Vocal Fatigue Score"),
|
| 23 |
+
title="Auralis Vocal Fatigue API"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|