Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,28 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from pipeline import run_pipeline
|
| 4 |
|
| 5 |
def infer(file):
|
| 6 |
-
|
|
|
|
| 7 |
return run_pipeline(path, out_style="json")
|
| 8 |
|
| 9 |
demo = gr.Interface(
|
| 10 |
fn=infer,
|
| 11 |
inputs=gr.File(label="Upload audio/video (mp3, mp4, wav)"),
|
| 12 |
-
outputs=gr.JSON(label="Result"),
|
| 13 |
title="Aphasia Classification",
|
| 14 |
-
description="MP3/MP4 → WAV → .cha → JSON → model"
|
|
|
|
| 15 |
)
|
| 16 |
|
| 17 |
if __name__ == "__main__":
|
| 18 |
-
demo.
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import warnings
|
| 3 |
+
warnings.filterwarnings("ignore", message="pkg_resources is deprecated")
|
| 4 |
+
|
| 5 |
import gradio as gr
|
| 6 |
from pipeline import run_pipeline
|
| 7 |
|
| 8 |
def infer(file):
|
| 9 |
+
# gr.File gives a tempfile object; if you used gr.Audio it might be a str
|
| 10 |
+
path = getattr(file, "name", file)
|
| 11 |
return run_pipeline(path, out_style="json")
|
| 12 |
|
| 13 |
demo = gr.Interface(
|
| 14 |
fn=infer,
|
| 15 |
inputs=gr.File(label="Upload audio/video (mp3, mp4, wav)"),
|
| 16 |
+
outputs=gr.JSON(label="Result"),
|
| 17 |
title="Aphasia Classification",
|
| 18 |
+
description="MP3/MP4 → WAV → .cha → JSON → model",
|
| 19 |
+
concurrency_limit=1,
|
| 20 |
)
|
| 21 |
|
| 22 |
if __name__ == "__main__":
|
| 23 |
+
demo.launch(
|
| 24 |
+
server_name="0.0.0.0",
|
| 25 |
+
server_port=7860,
|
| 26 |
+
show_error=True,
|
| 27 |
+
max_threads=1, # be gentle on Spaces CPU
|
| 28 |
+
)
|