Spaces:
Running
Running
enable zerogpu acceleration
Browse files
app.py
CHANGED
|
@@ -10,6 +10,7 @@ import tempfile
|
|
| 10 |
import gradio as gr
|
| 11 |
import torch
|
| 12 |
from pathlib import Path
|
|
|
|
| 13 |
|
| 14 |
# Add current directory to Python path for local zipvoice package
|
| 15 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
@@ -101,6 +102,7 @@ def load_models_and_components(model_name: str):
|
|
| 101 |
model_config["feature"]["sampling_rate"])
|
| 102 |
|
| 103 |
|
|
|
|
| 104 |
def synthesize_speech_gradio(
|
| 105 |
text: str,
|
| 106 |
prompt_audio_file,
|
|
@@ -125,7 +127,7 @@ def synthesize_speech_gradio(
|
|
| 125 |
# Load models and components
|
| 126 |
model, tokenizer, vocoder, feature_extractor, sampling_rate = load_models_and_components(model_name)
|
| 127 |
|
| 128 |
-
device = torch.device("cpu")
|
| 129 |
|
| 130 |
# Save uploaded audio to temporary file
|
| 131 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_audio:
|
|
|
|
| 10 |
import gradio as gr
|
| 11 |
import torch
|
| 12 |
from pathlib import Path
|
| 13 |
+
import spaces
|
| 14 |
|
| 15 |
# Add current directory to Python path for local zipvoice package
|
| 16 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
| 102 |
model_config["feature"]["sampling_rate"])
|
| 103 |
|
| 104 |
|
| 105 |
+
@spaces.GPU
|
| 106 |
def synthesize_speech_gradio(
|
| 107 |
text: str,
|
| 108 |
prompt_audio_file,
|
|
|
|
| 127 |
# Load models and components
|
| 128 |
model, tokenizer, vocoder, feature_extractor, sampling_rate = load_models_and_components(model_name)
|
| 129 |
|
| 130 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 131 |
|
| 132 |
# Save uploaded audio to temporary file
|
| 133 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_audio:
|