Spaces:
Build error
Build error
ZeroGPU support (#3)
Browse files- ZeroGPU support (efc21c4bb3c6647854100af0dcc6b3f7ae983445)
Co-authored-by: Apolinário from multimodal AI art <[email protected]>
app.py
CHANGED
@@ -3,6 +3,7 @@ import tempfile
|
|
3 |
import time
|
4 |
from pathlib import Path
|
5 |
from typing import Optional, Tuple
|
|
|
6 |
|
7 |
import gradio as gr
|
8 |
import numpy as np
|
@@ -11,7 +12,6 @@ import torch
|
|
11 |
|
12 |
from dia.model import Dia
|
13 |
|
14 |
-
|
15 |
# --- Global Setup ---
|
16 |
parser = argparse.ArgumentParser(description="Gradio interface for Nari TTS")
|
17 |
parser.add_argument(
|
@@ -45,7 +45,7 @@ except Exception as e:
|
|
45 |
print(f"Error loading Nari model: {e}")
|
46 |
raise
|
47 |
|
48 |
-
|
49 |
def run_inference(
|
50 |
text_input: str,
|
51 |
audio_prompt_input: Optional[Tuple[int, np.ndarray]],
|
@@ -60,7 +60,7 @@ def run_inference(
|
|
60 |
Runs Nari inference using the globally loaded model and provided inputs.
|
61 |
Uses temporary files for text and audio prompt compatibility with inference.generate.
|
62 |
"""
|
63 |
-
global model, device # Access global model, config, device
|
64 |
|
65 |
if not text_input or text_input.isspace():
|
66 |
raise gr.Error("Text input cannot be empty.")
|
|
|
3 |
import time
|
4 |
from pathlib import Path
|
5 |
from typing import Optional, Tuple
|
6 |
+
import spaces
|
7 |
|
8 |
import gradio as gr
|
9 |
import numpy as np
|
|
|
12 |
|
13 |
from dia.model import Dia
|
14 |
|
|
|
15 |
# --- Global Setup ---
|
16 |
parser = argparse.ArgumentParser(description="Gradio interface for Nari TTS")
|
17 |
parser.add_argument(
|
|
|
45 |
print(f"Error loading Nari model: {e}")
|
46 |
raise
|
47 |
|
48 |
+
@spaces.GPU
|
49 |
def run_inference(
|
50 |
text_input: str,
|
51 |
audio_prompt_input: Optional[Tuple[int, np.ndarray]],
|
|
|
60 |
Runs Nari inference using the globally loaded model and provided inputs.
|
61 |
Uses temporary files for text and audio prompt compatibility with inference.generate.
|
62 |
"""
|
63 |
+
# global model, device # Access global model, config, device
|
64 |
|
65 |
if not text_input or text_input.isspace():
|
66 |
raise gr.Error("Text input cannot be empty.")
|