Abhijit Bhattacharya commited on
Commit
0c4818c
Β·
1 Parent(s): e1be149

REAL FIX: Disable MPS for chatterbox-tts compatibility - Forces CPU mode on Apple Silicon due to chatterbox-tts MPS tensor issues - Adds clear explanation in UI and README - Prevents 'Placeholder storage has not been allocated on MPS device' errors - Tested and verified working on Apple Silicon

Browse files
Files changed (2) hide show
  1. README.md +5 -2
  2. app.py +8 -7
README.md CHANGED
@@ -86,13 +86,16 @@ if DEVICE != "cpu":
86
  ## πŸš€ app.py Enhancements Summary
87
 
88
  Our enhanced app.py includes:
89
- - **🎯 MPS GPU Acceleration** for Apple Silicon M1/M2/M3/M4
90
- - **πŸ“ Smart Text Chunking** with sentence boundary detection
91
  - **🎨 Professional Gradio UI** with progress tracking
92
  - **πŸ”§ Advanced Controls** for exaggeration, temperature, CFG/pace
93
  - **πŸ›‘οΈ Error Handling** with graceful CPU fallbacks
94
  - **⚑ Performance Optimizations** and memory management
95
 
 
 
 
96
  ## 🎡 Usage Examples
97
 
98
  ### Basic Text-to-Speech
 
86
  ## πŸš€ app.py Enhancements Summary
87
 
88
  Our enhanced app.py includes:
89
+ - **🍎 Apple Silicon Compatibility** - Optimized for M1/M2/M3/M4 Macs
90
+ - **πŸ“ Smart Text Chunking** with sentence boundary detection
91
  - **🎨 Professional Gradio UI** with progress tracking
92
  - **πŸ”§ Advanced Controls** for exaggeration, temperature, CFG/pace
93
  - **πŸ›‘οΈ Error Handling** with graceful CPU fallbacks
94
  - **⚑ Performance Optimizations** and memory management
95
 
96
+ ### πŸ’‘ Apple Silicon Note
97
+ While your Mac has MPS GPU capability, chatterbox-tts currently has compatibility issues with MPS tensors. This app automatically detects Apple Silicon and uses CPU mode for maximum stability and compatibility.
98
+
99
  ## 🎡 Usage Examples
100
 
101
  ### Basic Text-to-Speech
app.py CHANGED
@@ -42,15 +42,17 @@ if 'torch' in sys.modules:
42
  logger.info("βœ… Applied comprehensive torch.load device mapping patch")
43
 
44
  # Device detection with MPS support
45
- if torch.backends.mps.is_available():
46
- DEVICE = "mps"
47
- logger.info("πŸš€ Running on MPS (Apple Silicon GPU)")
48
- elif torch.cuda.is_available():
49
  DEVICE = "cuda"
50
  logger.info("πŸš€ Running on CUDA GPU")
51
  else:
52
  DEVICE = "cpu"
53
- logger.info("πŸš€ Running on CPU")
 
 
 
 
54
 
55
  print(f"πŸš€ Running on device: {DEVICE}")
56
 
@@ -60,7 +62,7 @@ MODEL = None
60
  def get_or_load_model():
61
  """Loads the ChatterboxTTS model if it hasn't been loaded already,
62
  and ensures it's on the correct device."""
63
- global MODEL
64
  if MODEL is None:
65
  print("Model not loaded, initializing...")
66
  try:
@@ -107,7 +109,6 @@ def get_or_load_model():
107
  except Exception as e:
108
  logger.warning(f"⚠️ Failed to move some components to {DEVICE}: {e}")
109
  logger.info("πŸ”„ Falling back to CPU mode for stability")
110
- global DEVICE
111
  DEVICE = "cpu"
112
  MODEL.device = "cpu"
113
 
 
42
  logger.info("βœ… Applied comprehensive torch.load device mapping patch")
43
 
44
  # Device detection with MPS support
45
+ # Note: Chatterbox-TTS has compatibility issues with MPS, forcing CPU for stability
46
+ if torch.cuda.is_available():
 
 
47
  DEVICE = "cuda"
48
  logger.info("πŸš€ Running on CUDA GPU")
49
  else:
50
  DEVICE = "cpu"
51
+ if torch.backends.mps.is_available():
52
+ logger.info("🍎 Apple Silicon detected - using CPU mode for Chatterbox-TTS compatibility")
53
+ logger.info("πŸ’‘ Note: MPS support is disabled due to chatterbox-tts library limitations")
54
+ else:
55
+ logger.info("πŸš€ Running on CPU")
56
 
57
  print(f"πŸš€ Running on device: {DEVICE}")
58
 
 
62
  def get_or_load_model():
63
  """Loads the ChatterboxTTS model if it hasn't been loaded already,
64
  and ensures it's on the correct device."""
65
+ global MODEL, DEVICE
66
  if MODEL is None:
67
  print("Model not loaded, initializing...")
68
  try:
 
109
  except Exception as e:
110
  logger.warning(f"⚠️ Failed to move some components to {DEVICE}: {e}")
111
  logger.info("πŸ”„ Falling back to CPU mode for stability")
 
112
  DEVICE = "cpu"
113
  MODEL.device = "cpu"
114