Spaces:
Running on Zero
Running on Zero
Deploy Lisper ZeroGPU Space
Browse files- __pycache__/app.cpython-314.pyc +0 -0
- app.py +19 -3
__pycache__/app.cpython-314.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-314.pyc and b/__pycache__/app.cpython-314.pyc differ
|
|
|
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
import re
|
|
|
|
| 6 |
from typing import Any
|
| 7 |
|
| 8 |
import gradio as gr
|
|
@@ -183,8 +184,7 @@ def parse_response(response: str) -> dict[str, Any]:
|
|
| 183 |
}
|
| 184 |
|
| 185 |
|
| 186 |
-
|
| 187 |
-
def analyze(audio: str | tuple[int, np.ndarray] | None, target_text: str) -> tuple[str, str]:
|
| 188 |
waveform = normalize_audio(audio)
|
| 189 |
processor, model = load_runtime()
|
| 190 |
messages = build_messages(target_text)
|
|
@@ -222,6 +222,22 @@ def analyze(audio: str | tuple[int, np.ndarray] | None, target_text: str) -> tup
|
|
| 222 |
return response, json.dumps(parsed, indent=2)
|
| 223 |
|
| 224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
def build_app() -> gr.Blocks:
|
| 226 |
with gr.Blocks(title="Lisper ZeroGPU", theme=gr.themes.Soft()) as demo:
|
| 227 |
gr.Markdown(
|
|
@@ -266,4 +282,4 @@ def build_app() -> gr.Blocks:
|
|
| 266 |
demo = build_app()
|
| 267 |
|
| 268 |
if __name__ == "__main__":
|
| 269 |
-
demo.queue(default_concurrency_limit=1).launch()
|
|
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
import re
|
| 6 |
+
import traceback
|
| 7 |
from typing import Any
|
| 8 |
|
| 9 |
import gradio as gr
|
|
|
|
| 184 |
}
|
| 185 |
|
| 186 |
|
| 187 |
+
def _analyze_impl(audio: str | tuple[int, np.ndarray] | None, target_text: str) -> tuple[str, str]:
|
|
|
|
| 188 |
waveform = normalize_audio(audio)
|
| 189 |
processor, model = load_runtime()
|
| 190 |
messages = build_messages(target_text)
|
|
|
|
| 222 |
return response, json.dumps(parsed, indent=2)
|
| 223 |
|
| 224 |
|
| 225 |
+
@spaces.GPU(duration=120, size=zero_gpu_size())
|
| 226 |
+
def analyze(audio: str | tuple[int, np.ndarray] | None, target_text: str) -> tuple[str, str]:
|
| 227 |
+
try:
|
| 228 |
+
return _analyze_impl(audio, target_text)
|
| 229 |
+
except Exception as exc:
|
| 230 |
+
payload = {
|
| 231 |
+
"error_type": type(exc).__name__,
|
| 232 |
+
"message": str(exc),
|
| 233 |
+
"model_id": model_id(),
|
| 234 |
+
"dtype": os.environ.get("LISPER_ZERO_GPU_DTYPE", "float16"),
|
| 235 |
+
"zero_gpu_size": zero_gpu_size(),
|
| 236 |
+
"traceback": traceback.format_exc(limit=8),
|
| 237 |
+
}
|
| 238 |
+
return f"ZeroGPU inference failed: {type(exc).__name__}: {exc}", json.dumps(payload, indent=2)
|
| 239 |
+
|
| 240 |
+
|
| 241 |
def build_app() -> gr.Blocks:
|
| 242 |
with gr.Blocks(title="Lisper ZeroGPU", theme=gr.themes.Soft()) as demo:
|
| 243 |
gr.Markdown(
|
|
|
|
| 282 |
demo = build_app()
|
| 283 |
|
| 284 |
if __name__ == "__main__":
|
| 285 |
+
demo.queue(default_concurrency_limit=1).launch(show_error=True)
|