neo7team commited on
Commit
9671be0
·
verified ·
1 Parent(s): 74d7062

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -19,8 +19,9 @@ def get_or_load_model():
19
  if MODEL is None:
20
  print("Model not loaded, initializing...")
21
  try:
22
- # Load the model directly to the specified DEVICE (CPU)
23
- MODEL = ChatterboxTTS.from_pretrained(DEVICE)
 
24
  if hasattr(MODEL, 'to') and str(getattr(MODEL, 'device', 'cpu')) != DEVICE:
25
  MODEL.to(DEVICE)
26
  print(f"Model loaded successfully. Internal device: {getattr(MODEL, 'device', 'N/A')}")
 
19
  if MODEL is None:
20
  print("Model not loaded, initializing...")
21
  try:
22
+ # Correctly load the model by passing 'device' as a keyword argument.
23
+ # This ensures the model's tensors are mapped to the CPU during loading.
24
+ MODEL = ChatterboxTTS.from_pretrained(device=DEVICE)
25
  if hasattr(MODEL, 'to') and str(getattr(MODEL, 'device', 'cpu')) != DEVICE:
26
  MODEL.to(DEVICE)
27
  print(f"Model loaded successfully. Internal device: {getattr(MODEL, 'device', 'N/A')}")