Spaces:
Runtime error
Runtime error
Spaces, ZeroGPU
Browse files
webui.py
CHANGED
@@ -21,7 +21,7 @@ import gradio as gr
|
|
21 |
from datetime import datetime
|
22 |
from cli.SparkTTS import SparkTTS
|
23 |
from sparktts.utils.token_parser import LEVELS_MAP_UI
|
24 |
-
|
25 |
|
26 |
def initialize_model(model_dir="pretrained_models/Spark-TTS-0.5B", device=0):
|
27 |
"""Load the model once at the beginning."""
|
@@ -30,7 +30,7 @@ def initialize_model(model_dir="pretrained_models/Spark-TTS-0.5B", device=0):
|
|
30 |
model = SparkTTS(model_dir, device)
|
31 |
return model
|
32 |
|
33 |
-
|
34 |
def run_tts(
|
35 |
text,
|
36 |
model,
|
@@ -73,7 +73,7 @@ def run_tts(
|
|
73 |
|
74 |
return save_path, model # Return model along with audio path
|
75 |
|
76 |
-
|
77 |
def voice_clone(text, model, prompt_text, prompt_wav_upload, prompt_wav_record):
|
78 |
"""Gradio interface for TTS with prompt speech input."""
|
79 |
# Determine prompt speech (from audio file or recording)
|
@@ -85,7 +85,7 @@ def voice_clone(text, model, prompt_text, prompt_wav_upload, prompt_wav_record):
|
|
85 |
|
86 |
return audio_output_path, model
|
87 |
|
88 |
-
|
89 |
def voice_creation(text, model, gender, pitch, speed):
|
90 |
"""Gradio interface for TTS with control over voice attributes."""
|
91 |
pitch = LEVELS_MAP_UI[int(pitch)]
|
@@ -189,4 +189,4 @@ def build_ui(model_dir, device=0):
|
|
189 |
|
190 |
if __name__ == "__main__":
|
191 |
demo = build_ui(model_dir="pretrained_models/Spark-TTS-0.5B", device=0)
|
192 |
-
demo.launch(
|
|
|
21 |
from datetime import datetime
|
22 |
from cli.SparkTTS import SparkTTS
|
23 |
from sparktts.utils.token_parser import LEVELS_MAP_UI
|
24 |
+
import spaces
|
25 |
|
26 |
def initialize_model(model_dir="pretrained_models/Spark-TTS-0.5B", device=0):
|
27 |
"""Load the model once at the beginning."""
|
|
|
30 |
model = SparkTTS(model_dir, device)
|
31 |
return model
|
32 |
|
33 |
+
@spaces.GPU
|
34 |
def run_tts(
|
35 |
text,
|
36 |
model,
|
|
|
73 |
|
74 |
return save_path, model # Return model along with audio path
|
75 |
|
76 |
+
@spaces.GPU
|
77 |
def voice_clone(text, model, prompt_text, prompt_wav_upload, prompt_wav_record):
|
78 |
"""Gradio interface for TTS with prompt speech input."""
|
79 |
# Determine prompt speech (from audio file or recording)
|
|
|
85 |
|
86 |
return audio_output_path, model
|
87 |
|
88 |
+
@spaces.GPU
|
89 |
def voice_creation(text, model, gender, pitch, speed):
|
90 |
"""Gradio interface for TTS with control over voice attributes."""
|
91 |
pitch = LEVELS_MAP_UI[int(pitch)]
|
|
|
189 |
|
190 |
if __name__ == "__main__":
|
191 |
demo = build_ui(model_dir="pretrained_models/Spark-TTS-0.5B", device=0)
|
192 |
+
demo.queue().launch()
|