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
README.md
CHANGED
|
@@ -86,13 +86,16 @@ if DEVICE != "cpu":
|
|
| 86 |
## π app.py Enhancements Summary
|
| 87 |
|
| 88 |
Our enhanced app.py includes:
|
| 89 |
-
-
|
| 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 |
-
|
| 46 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|