MCPcopy Create free account
hub / github.com/SparkAudio/Spark-TTS / initialize_model

Function initialize_model

webui.py:29–48  ·  view source on GitHub ↗

Load the model once at the beginning.

(model_dir="pretrained_models/Spark-TTS-0.5B", device=0)

Source from the content-addressed store, hash-verified

27
28
29def initialize_model(model_dir="pretrained_models/Spark-TTS-0.5B", device=0):
30 """Load the model once at the beginning."""
31 logging.info(f"Loading model from: {model_dir}")
32
33 # Determine appropriate device based on platform and availability
34 if platform.system() == "Darwin":
35 # macOS with MPS support (Apple Silicon)
36 device = torch.device(f"mps:{device}")
37 logging.info(f"Using MPS device: {device}")
38 elif torch.cuda.is_available():
39 # System with CUDA support
40 device = torch.device(f"cuda:{device}")
41 logging.info(f"Using CUDA device: {device}")
42 else:
43 # Fall back to CPU
44 device = torch.device("cpu")
45 logging.info("GPU acceleration not available, using CPU")
46
47 model = SparkTTS(model_dir, device)
48 return model
49
50
51def run_tts(

Callers 1

build_uiFunction · 0.85

Calls 1

SparkTTSClass · 0.90

Tested by

no test coverage detected