Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -18,9 +18,7 @@ from irodori_tts.inference_runtime import (
|
|
| 18 |
# Configuration
|
| 19 |
# ---------------------------------------------------------------------------
|
| 20 |
|
| 21 |
-
MODEL_REPO = os.environ.get(
|
| 22 |
-
"MODEL_REPO", "Aratako/Irodori-TTS-v4.1-Small-Quantized/int8-weight-only"
|
| 23 |
-
)
|
| 24 |
CODEC_REPO = "Aratako/Semantic-DACVAE-Japanese-32dim"
|
| 25 |
MAX_GRADIO_CANDIDATES = int(os.environ.get("MAX_GRADIO_CANDIDATES", "8"))
|
| 26 |
GRADIO_AUDIO_COLS_PER_ROW = 4
|
|
@@ -129,6 +127,8 @@ def _load_models():
|
|
| 129 |
# Load models at startup (ZeroGPU intercepts .to("cuda"))
|
| 130 |
_load_models()
|
| 131 |
|
|
|
|
|
|
|
| 132 |
|
| 133 |
# ---------------------------------------------------------------------------
|
| 134 |
# GPU-decorated Inference
|
|
@@ -164,6 +164,9 @@ def run_inference_gpu(
|
|
| 164 |
) -> tuple[list[tuple[int, np.ndarray]], str]:
|
| 165 |
"""Generate Japanese speech from text using Irodori-TTS-v4.1-Small (INT8 quantized).
|
| 166 |
|
|
|
|
|
|
|
|
|
|
| 167 |
Args:
|
| 168 |
text: Japanese text to synthesize.
|
| 169 |
caption: Optional style/emotion prompt.
|
|
@@ -196,6 +199,16 @@ def run_inference_gpu(
|
|
| 196 |
if _runtime is None:
|
| 197 |
_load_models()
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
log_buffer = io.StringIO()
|
| 200 |
|
| 201 |
def stdout_log(msg: str) -> None:
|
|
|
|
| 18 |
# Configuration
|
| 19 |
# ---------------------------------------------------------------------------
|
| 20 |
|
| 21 |
+
MODEL_REPO = os.environ.get("MODEL_REPO", "Aratako/Irodori-TTS-v4.1-Small")
|
|
|
|
|
|
|
| 22 |
CODEC_REPO = "Aratako/Semantic-DACVAE-Japanese-32dim"
|
| 23 |
MAX_GRADIO_CANDIDATES = int(os.environ.get("MAX_GRADIO_CANDIDATES", "8"))
|
| 24 |
GRADIO_AUDIO_COLS_PER_ROW = 4
|
|
|
|
| 127 |
# Load models at startup (ZeroGPU intercepts .to("cuda"))
|
| 128 |
_load_models()
|
| 129 |
|
| 130 |
+
_quantized = False
|
| 131 |
+
|
| 132 |
|
| 133 |
# ---------------------------------------------------------------------------
|
| 134 |
# GPU-decorated Inference
|
|
|
|
| 164 |
) -> tuple[list[tuple[int, np.ndarray]], str]:
|
| 165 |
"""Generate Japanese speech from text using Irodori-TTS-v4.1-Small (INT8 quantized).
|
| 166 |
|
| 167 |
+
The base bf16 model is loaded at startup; INT8 weight-only quantization is
|
| 168 |
+
applied on the first GPU call to reduce VRAM usage while preserving quality.
|
| 169 |
+
|
| 170 |
Args:
|
| 171 |
text: Japanese text to synthesize.
|
| 172 |
caption: Optional style/emotion prompt.
|
|
|
|
| 199 |
if _runtime is None:
|
| 200 |
_load_models()
|
| 201 |
|
| 202 |
+
global _quantized
|
| 203 |
+
if not _quantized:
|
| 204 |
+
from irodori_tts.quantization import quantize_model
|
| 205 |
+
|
| 206 |
+
quantized_count = quantize_model(
|
| 207 |
+
_runtime.model, quantization_type="int8_weight_only", profile="core"
|
| 208 |
+
)
|
| 209 |
+
print(f"[Info] Quantized {quantized_count} layers to INT8 weight-only.", flush=True)
|
| 210 |
+
_quantized = True
|
| 211 |
+
|
| 212 |
log_buffer = io.StringIO()
|
| 213 |
|
| 214 |
def stdout_log(msg: str) -> None:
|