chatterbox-mlx 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. chatterbox_mlx-1.0.0/LICENSE +21 -0
  2. chatterbox_mlx-1.0.0/MANIFEST.in +55 -0
  3. chatterbox_mlx-1.0.0/PKG-INFO +448 -0
  4. chatterbox_mlx-1.0.0/README.md +398 -0
  5. chatterbox_mlx-1.0.0/pyproject.toml +68 -0
  6. chatterbox_mlx-1.0.0/setup.cfg +4 -0
  7. chatterbox_mlx-1.0.0/src/chatterbox/__init__.py +60 -0
  8. chatterbox_mlx-1.0.0/src/chatterbox/__main__.py +9 -0
  9. chatterbox_mlx-1.0.0/src/chatterbox/cli.py +457 -0
  10. chatterbox_mlx-1.0.0/src/chatterbox/generation_utils.py +597 -0
  11. chatterbox_mlx-1.0.0/src/chatterbox/models/__init__.py +18 -0
  12. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/__init__.py +5 -0
  13. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/configs.py +12 -0
  14. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/const.py +1 -0
  15. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/decoder.py +376 -0
  16. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/f0_predictor.py +58 -0
  17. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/flow.py +329 -0
  18. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/flow_matching.py +371 -0
  19. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/hifigan.py +612 -0
  20. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/matcha/decoder.py +460 -0
  21. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/matcha/flow_matching.py +141 -0
  22. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/matcha/text_encoder.py +453 -0
  23. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/matcha/transformer.py +353 -0
  24. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/s3gen.py +610 -0
  25. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/__init__.py +0 -0
  26. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/activation.py +87 -0
  27. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/attention.py +331 -0
  28. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/convolution.py +147 -0
  29. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/embedding.py +293 -0
  30. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/encoder_layer.py +237 -0
  31. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/positionwise_feed_forward.py +116 -0
  32. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/subsampling.py +391 -0
  33. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/transformer/upsample_encoder.py +368 -0
  34. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/utils/class_utils.py +74 -0
  35. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/utils/mask.py +196 -0
  36. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/utils/mel.py +105 -0
  37. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen/xvector.py +455 -0
  38. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/__init__.py +74 -0
  39. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/convert_weights.py +891 -0
  40. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/decoder_mlx.py +444 -0
  41. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/f0_predictor_mlx.py +163 -0
  42. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/flow_matching_mlx.py +231 -0
  43. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/flow_mlx.py +340 -0
  44. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/hifigan_mlx.py +626 -0
  45. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/matcha/__init__.py +36 -0
  46. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/matcha/decoder_mlx.py +485 -0
  47. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/matcha/transformer_mlx.py +215 -0
  48. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/s3gen_mlx.py +532 -0
  49. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/transformer/__init__.py +49 -0
  50. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/transformer/attention_mlx.py +302 -0
  51. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/transformer/convolution_mlx.py +175 -0
  52. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/transformer/embedding_mlx.py +254 -0
  53. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/transformer/encoder_layer_mlx.py +210 -0
  54. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/transformer/feed_forward_mlx.py +57 -0
  55. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/transformer/subsampling_mlx.py +201 -0
  56. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/transformer/upsample_encoder_mlx.py +396 -0
  57. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/utils/__init__.py +23 -0
  58. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/utils/mask_mlx.py +155 -0
  59. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/utils/mel_mlx.py +194 -0
  60. chatterbox_mlx-1.0.0/src/chatterbox/models/s3gen_mlx/xvector_mlx.py +601 -0
  61. chatterbox_mlx-1.0.0/src/chatterbox/models/s3tokenizer/__init__.py +31 -0
  62. chatterbox_mlx-1.0.0/src/chatterbox/models/s3tokenizer/s3tokenizer.py +172 -0
  63. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/__init__.py +2 -0
  64. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/inference/alignment_stream_analyzer.py +240 -0
  65. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/inference/t3_hf_backend.py +125 -0
  66. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/llama_configs.py +37 -0
  67. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/modules/cond_enc.py +105 -0
  68. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/modules/learned_pos_emb.py +34 -0
  69. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/modules/perceiver.py +266 -0
  70. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/modules/t3_config.py +55 -0
  71. chatterbox_mlx-1.0.0/src/chatterbox/models/t3/t3.py +581 -0
  72. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/__init__.py +7 -0
  73. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/inference/__init__.py +6 -0
  74. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/inference/alignment_stream_analyzer_mlx.py +316 -0
  75. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/inference/kv_cache_mlx.py +244 -0
  76. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/inference/sampling_utils_mlx.py +207 -0
  77. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/inference/t3_mlx_backend.py +164 -0
  78. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/modules/__init__.py +13 -0
  79. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/modules/cond_enc_mlx.py +161 -0
  80. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/modules/learned_pos_emb_mlx.py +73 -0
  81. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/modules/llama_mlx.py +453 -0
  82. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/modules/perceiver_mlx.py +242 -0
  83. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/quantization/__init__.py +6 -0
  84. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/quantization/quantize_mlx.py +213 -0
  85. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/t3_mlx.py +659 -0
  86. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/utils/__init__.py +14 -0
  87. chatterbox_mlx-1.0.0/src/chatterbox/models/t3_mlx/utils/convert_weights.py +237 -0
  88. chatterbox_mlx-1.0.0/src/chatterbox/models/tokenizers/__init__.py +1 -0
  89. chatterbox_mlx-1.0.0/src/chatterbox/models/tokenizers/tokenizer.py +406 -0
  90. chatterbox_mlx-1.0.0/src/chatterbox/models/utils.py +350 -0
  91. chatterbox_mlx-1.0.0/src/chatterbox/models/voice_encoder/__init__.py +4 -0
  92. chatterbox_mlx-1.0.0/src/chatterbox/models/voice_encoder/config.py +18 -0
  93. chatterbox_mlx-1.0.0/src/chatterbox/models/voice_encoder/melspec.py +79 -0
  94. chatterbox_mlx-1.0.0/src/chatterbox/models/voice_encoder/voice_encoder.py +319 -0
  95. chatterbox_mlx-1.0.0/src/chatterbox/mtl_tts.py +844 -0
  96. chatterbox_mlx-1.0.0/src/chatterbox/mtl_tts_mlx.py +1080 -0
  97. chatterbox_mlx-1.0.0/src/chatterbox/tts.py +665 -0
  98. chatterbox_mlx-1.0.0/src/chatterbox/tts_mlx.py +1707 -0
  99. chatterbox_mlx-1.0.0/src/chatterbox/vc.py +110 -0
  100. chatterbox_mlx-1.0.0/src/chatterbox_mlx.egg-info/PKG-INFO +448 -0
  101. chatterbox_mlx-1.0.0/src/chatterbox_mlx.egg-info/SOURCES.txt +103 -0
  102. chatterbox_mlx-1.0.0/src/chatterbox_mlx.egg-info/dependency_links.txt +1 -0
  103. chatterbox_mlx-1.0.0/src/chatterbox_mlx.egg-info/entry_points.txt +2 -0
  104. chatterbox_mlx-1.0.0/src/chatterbox_mlx.egg-info/requires.txt +28 -0
  105. chatterbox_mlx-1.0.0/src/chatterbox_mlx.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Resemble AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # Include essential files
2
+ include README.md
3
+ include LICENSE
4
+ include pyproject.toml
5
+
6
+ # Include source code (already handled by setuptools, but explicit is good)
7
+ recursive-include src *.py
8
+
9
+ # Exclude development and documentation files
10
+ exclude .env
11
+ exclude .gitignore
12
+ exclude Makefile
13
+ recursive-exclude * __pycache__
14
+ recursive-exclude * *.py[co]
15
+ recursive-exclude * .DS_Store
16
+
17
+ # Exclude all markdown files except README
18
+ exclude *.md
19
+ include README.md
20
+
21
+ # Exclude test files
22
+ recursive-exclude tests *
23
+ exclude test_*.py
24
+ exclude *_test.py
25
+
26
+ # Exclude example files
27
+ exclude example_*.py
28
+
29
+ # Exclude benchmark files
30
+ exclude benchmark_*.py
31
+ exclude benchmark_*.json
32
+ recursive-exclude benchmark_output *
33
+
34
+ # Exclude audio files
35
+ exclude *.wav
36
+ exclude *.mp3
37
+ exclude *.flac
38
+
39
+ # Exclude notebook files
40
+ exclude *.ipynb
41
+
42
+ # Exclude build artifacts
43
+ recursive-exclude dist *
44
+ recursive-exclude build *
45
+ recursive-exclude *.egg-info *
46
+
47
+ # Exclude IDE and editor files
48
+ recursive-exclude .vscode *
49
+ recursive-exclude .idea *
50
+ exclude .python-version
51
+
52
+ # Exclude cache directories
53
+ recursive-exclude .pytest_cache *
54
+ recursive-exclude __pycache__ *
55
+ recursive-exclude audiobook_cache *
@@ -0,0 +1,448 @@
1
+ Metadata-Version: 2.4
2
+ Name: chatterbox-mlx
3
+ Version: 1.0.0
4
+ Summary: Chatterbox MLX: Open Source TTS and Voice Conversion for MLX. Based off of Chatterbox by Resemble AI
5
+ Author-email: michael-yang <contact@michaelyang.ai>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/michaelcreatesstuff/chatterbox
8
+ Project-URL: Repository, https://github.com/michaelcreatesstuff/chatterbox
9
+ Keywords: tts,text-to-speech,voice-cloning,speech-synthesis,ai,multilingual,mlx,apple-silicon
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: <3.14,>=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy==2.3.5
23
+ Requires-Dist: scipy>=1.11.0
24
+ Requires-Dist: librosa==0.11.0
25
+ Requires-Dist: s3tokenizer
26
+ Requires-Dist: torch>=2.9.0
27
+ Requires-Dist: torchaudio>=2.9.0
28
+ Requires-Dist: torchcodec>=0.7.0
29
+ Requires-Dist: transformers==4.57.3
30
+ Requires-Dist: diffusers==0.35.2
31
+ Requires-Dist: resemble-perth==1.0.1
32
+ Requires-Dist: conformer==0.3.2
33
+ Requires-Dist: safetensors>=0.7.0
34
+ Requires-Dist: huggingface-hub>=0.20.0
35
+ Requires-Dist: spacy>=3.8.3
36
+ Requires-Dist: spacy-pkuseg==1.0.1
37
+ Requires-Dist: pykakasi==2.3.0
38
+ Requires-Dist: psutil==7.2.0
39
+ Requires-Dist: mlx==0.29.4
40
+ Requires-Dist: mlx-lm==0.28.3
41
+ Provides-Extra: dev
42
+ Requires-Dist: mlx-whisper>=0.4.0; extra == "dev"
43
+ Requires-Dist: parakeet-mlx==0.4.1; extra == "dev"
44
+ Requires-Dist: black==25.12.0; extra == "dev"
45
+ Requires-Dist: ruff==0.14.10; extra == "dev"
46
+ Requires-Dist: pytest==9.0.2; extra == "dev"
47
+ Requires-Dist: build==1.3.0; extra == "dev"
48
+ Requires-Dist: twine==6.2.0; extra == "dev"
49
+ Dynamic: license-file
50
+
51
+ # Chatterbox MLX - Apple Silicon Optimized TTS
52
+
53
+ [![PyPI version](https://badge.fury.io/py/chatterbox-mlx.svg)](https://badge.fury.io/py/chatterbox-mlx)
54
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
55
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
56
+
57
+ **An MLX-optimized fork of [Resemble AI's Chatterbox TTS](https://github.com/resemble-ai/chatterbox) for Apple Silicon, delivering up to 2.4x faster inference.**
58
+
59
+ ---
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install chatterbox-mlx
65
+ ```
66
+
67
+ ### Requirements
68
+
69
+ - macOS with Apple Silicon (M1/M2/M3/M4)
70
+ - Python 3.11+ (tested primarily with 3.11.12. Also tested with 3.12.12 and 3.13.2)
71
+ - ~4GB disk space for model weights
72
+
73
+ **Important:** Python must be compiled with `lzma` support. If you're using pyenv:
74
+
75
+ ```bash
76
+ # Install xz library first (provides liblzma)
77
+ brew install xz
78
+
79
+ # Then install Python (or reinstall if already installed)
80
+ pyenv install 3.11.12 # or your preferred version
81
+ ```
82
+
83
+ If you see an error about `ModuleNotFoundError: No module named '_lzma'`, you need to install `xz` and reinstall Python.
84
+
85
+ ---
86
+
87
+ ## CLI Usage
88
+
89
+ Generate speech directly from the terminal:
90
+
91
+ ```bash
92
+ # Generate English speech (auto-generated filename):
93
+ chatterbox "Artificial intelligence has made remarkable strides in recent years, particularly in the field of natural language processing."
94
+
95
+ # Generate Spanish speech:
96
+ chatterbox "La inteligencia artificial ha logrado avances notables en los últimos años." --lang es
97
+
98
+ # Use the --voice flag to provide a reference audio file for voice cloning:
99
+ chatterbox "Artificial intelligence has made remarkable strides in recent years, particularly in the field of natural language processing." --voice speaker.wav
100
+
101
+ # Run multilingual benchmark (saves to benchmark_output/)
102
+ chatterbox --benchmark --languages en es
103
+ ```
104
+
105
+ ### CLI Options
106
+
107
+ | Option | Description | Default |
108
+ | ----------------- | -------------------------------------------- | ----------------- |
109
+ | `-o, --output` | Output WAV file path | Auto-generated |
110
+ | `-l, --lang` | Language code (en, es, fr, de, ja, zh, etc.) | `en` |
111
+ | `-v, --voice` | Reference audio for voice cloning | None |
112
+ | `--exaggeration` | Emotion intensity (0.0-1.0) | `0.5` |
113
+ | `--cfg` | Classifier-free guidance weight | `0.5` |
114
+ | `--backend` | Backend: hybrid-mlx, mlx, pytorch | `hybrid-mlx` |
115
+ | `--benchmark` | Run multilingual benchmark | False |
116
+ | `--languages` | Languages to benchmark | en es fr de ja zh |
117
+ | `--no-save-audio` | Don't save benchmark audio files | False (saves) |
118
+ | `-q, --quiet` | Suppress progress messages | False |
119
+
120
+ ---
121
+
122
+ ## Quick Start
123
+
124
+ ```python
125
+ import torchaudio as ta
126
+ from chatterbox.tts_mlx import ChatterboxTTSMLX
127
+
128
+ # Load model (downloads weights automatically on first run). Default is "cpu", choose "hybrid-mlx" for best performance on an Apple Silicon device.
129
+ model = ChatterboxTTSMLX.from_pretrained(device="hybrid-mlx")
130
+
131
+
132
+ # Generate speech
133
+ text = "Hello! This is Chatterbox running with MLX optimization on Apple Silicon."
134
+ wav = model.generate(text)
135
+ ta.save("output.wav", wav, model.sr)
136
+
137
+ # Voice cloning with reference audio
138
+ wav = model.generate(
139
+ text,
140
+ audio_prompt_path="reference_voice.wav",
141
+ exaggeration=0.5, # Emotion intensity (0.0-1.0)
142
+ cfg_weight=0.5, # Classifier-free guidance
143
+ )
144
+ ```
145
+
146
+ ### Long-Form Audio Generation
147
+
148
+ For texts longer than ~50 words, use chunked generation:
149
+
150
+ ```python
151
+ long_text = """
152
+ Your long text here. It can span multiple paragraphs and sentences.
153
+ The generate_long method will automatically split it at sentence boundaries,
154
+ generate each chunk separately, and crossfade them together seamlessly.
155
+ """
156
+
157
+ wav = model.generate_long(
158
+ long_text,
159
+ audio_prompt_path="reference_voice.wav",
160
+ chunk_size_words=50,
161
+ overlap_duration=0.1,
162
+ )
163
+ ta.save("long_output.wav", wav, model.sr)
164
+ ```
165
+
166
+ ## 🙏 Acknowledgements
167
+
168
+ This project is built on top of the excellent **[Chatterbox TTS](https://github.com/resemble-ai/chatterbox)** by [Resemble AI](https://resemble.ai). I'm deeply grateful for their work in creating and open-sourcing a production-grade, multilingual text-to-speech system under the MIT license.
169
+
170
+ **This fork focuses specifically on MLX optimizations for Apple Silicon.** If you're looking for the original project with CUDA support and the full feature set, please visit the [official Resemble AI repository](https://github.com/resemble-ai/chatterbox).
171
+
172
+ ---
173
+
174
+ ## What's Different in This Fork?
175
+
176
+ This package provides **native MLX acceleration** for Apple Silicon Macs, achieving significant performance improvements:
177
+
178
+ | Text Length | CPU Baseline | MLX Optimized | Speedup |
179
+ | ----------------- | ------------ | ------------- | --------------- |
180
+ | Short (5 words) | 8.91s | 3.70s | **2.4x faster** |
181
+ | Medium (31 words) | 57.51s | 24.40s | **2.4x faster** |
182
+ | Long (94 words) | 137.92s | 62.66s | **2.2x faster** |
183
+
184
+ ### Key Optimizations
185
+
186
+ - **MLX-Native T3 Model**: The 520M parameter Llama 3 backbone runs entirely on MLX
187
+ - **Float16 KV Cache**: Up to 5.8 GB memory savings with 32% faster generation
188
+ - **Hybrid Architecture**: Combines MLX speed with PyTorch quality controls
189
+ - **Long-Form Generation**: Intelligent chunking with crossfade for extended audio
190
+
191
+ ---
192
+
193
+ ## Benchmark Results
194
+
195
+ All benchmarks run on **Apple M4 (32GB RAM), macOS 15.4, Python 3.11, PyTorch 2.8.0**.
196
+
197
+ ### English TTS Performance
198
+
199
+ | Device | Text | Words | Time | RTF |
200
+ | -------------- | ------ | ----- | ------- | ----- |
201
+ | **Hybrid-MLX** | short | 5 | 4.08s | 0.65x |
202
+ | **Hybrid-MLX** | medium | 31 | 25.24s | 0.73x |
203
+ | **Hybrid-MLX** | long | 94 | 62.66s | 0.74x |
204
+ | Pure MLX | short | 5 | 3.70s | 0.69x |
205
+ | Pure MLX | medium | 31 | 24.40s | 0.72x |
206
+ | Pure MLX | long | 94 | 68.82s | 0.71x |
207
+ | CPU | short | 5 | 8.91s | 0.27x |
208
+ | CPU | medium | 31 | 57.51s | 0.33x |
209
+ | CPU | long | 94 | 137.92s | 0.34x |
210
+
211
+ **Key findings:**
212
+
213
+ - **Hybrid-MLX** recommended for production (best quality/speed balance)
214
+ - **Pure MLX** fastest for short texts, but quality degrades on long texts
215
+ - **2.2-2.4x speedup** vs CPU baseline across all text lengths
216
+
217
+ ### Multilingual Performance
218
+
219
+ | Device | Language | Time | RTF |
220
+ | ---------- | -------- | ------ | ----- |
221
+ | Hybrid-MLX | English | 12.25s | 0.71x |
222
+ | Hybrid-MLX | Spanish | 14.74s | 0.76x |
223
+ | Pure MLX | English | 14.55s | 0.67x |
224
+ | Pure MLX | Spanish | 13.78s | 0.75x |
225
+ | MPS | English | 19.96s | 0.50x |
226
+ | MPS | Spanish | 21.06s | 0.51x |
227
+ | CPU | English | 25.64s | 0.32x |
228
+ | CPU | Spanish | 31.31s | 0.33x |
229
+
230
+ ### Visual Comparison
231
+
232
+ ```
233
+ GENERATION TIME COMPARISON
234
+
235
+ Short (5 words)
236
+ ├─ CPU ████████████████████████████████████████ 8.91s
237
+ ├─ Hybrid-MLX ██████████████████ 4.08s (2.2x faster)
238
+ └─ Pure MLX ████████████████ 3.70s (2.4x faster)
239
+
240
+ Medium (31 words)
241
+ ├─ CPU ████████████████████████████████████████ 57.51s
242
+ ├─ Hybrid-MLX █████████████████ 25.24s (2.3x faster)
243
+ └─ Pure MLX ████████████████ 24.40s (2.4x faster)
244
+
245
+ Long (94 words)
246
+ ├─ CPU ████████████████████████████████████████ 137.92s
247
+ ├─ Hybrid-MLX █████████████████ 62.66s (2.2x faster) ✓ Best quality
248
+ └─ Pure MLX ██████████████████ 68.82s (2.0x faster)
249
+ ```
250
+
251
+ ### Backend Comparison
252
+
253
+ | Backend | Description | RTF | Memory | Recommendation |
254
+ | --------------- | ------------------------------ | ----- | ------ | -------------------- |
255
+ | **Hybrid-MLX** | T3 (MLX) + S3Gen (PyTorch/MPS) | 0.74x | ~16GB | ✅ Production use |
256
+ | **Pure MLX** | Everything on MLX | 0.71x | ~14GB | Minimal dependencies |
257
+ | **PyTorch MPS** | Full PyTorch on MPS | 0.51x | ~14GB | Fallback |
258
+ | **CPU** | PyTorch on CPU | 0.34x | ~14GB | Baseline |
259
+
260
+ _RTF = Real-Time Factor (audio_duration / generation_time). Higher is better._
261
+
262
+ ---
263
+
264
+ ## Running Benchmarks
265
+
266
+ You can reproduce these benchmarks on your own hardware.
267
+
268
+ ### English TTS Benchmark
269
+
270
+ ```bash
271
+ # Full benchmark (all backends)
272
+ python benchmark_mps.py --runs 3 --validate
273
+
274
+ # Quick test with Hybrid-MLX only
275
+ python benchmark_mps.py --hybrid-mlx-only --runs 1
276
+
277
+ # CPU baseline only
278
+ python benchmark_mps.py --cpu-only --runs 1
279
+
280
+ # With voice cloning
281
+ python benchmark_mps.py --audio-prompt speaker.wav --runs 3
282
+
283
+ # Enable memory debugging
284
+ DEBUG_MEMORY=1 python benchmark_mps.py --hybrid-mlx-only
285
+ ```
286
+
287
+ **Options:**
288
+ | Flag | Description |
289
+ |------|-------------|
290
+ | `--warmup N` | Warmup runs before timing (default: 1) |
291
+ | `--runs N` | Number of timed benchmark runs (default: 3) |
292
+ | `--devices` | Backends to test: `mps`, `cpu`, `hybrid-mlx`, `mlx`, `mlx-q4` |
293
+ | `--audio-prompt FILE` | Reference audio for voice cloning |
294
+ | `--output-dir DIR` | Output directory (default: `benchmark_output/`) |
295
+ | `--validate` | Enable Whisper transcription validation (computes WER) |
296
+ | `--mps-only` | Only benchmark PyTorch MPS |
297
+ | `--cpu-only` | Only benchmark CPU |
298
+ | `--hybrid-mlx-only` | Only benchmark Hybrid-MLX |
299
+ | `--mlx-only` | Only benchmark Pure MLX |
300
+ | `--debug-memory` | Enable detailed memory logging |
301
+
302
+ ### Multilingual Benchmark
303
+
304
+ ```bash
305
+ # Test specific languages
306
+ python benchmark_multilingual.py \
307
+ --audio-prompt speaker.wav \
308
+ --languages en es fr de ja zh \
309
+ --runs 3
310
+
311
+ # Quick test with Hybrid-MLX
312
+ python benchmark_multilingual.py \
313
+ --audio-prompt speaker.wav \
314
+ --languages en es \
315
+ --hybrid-mlx-only
316
+
317
+ # With validation
318
+ python benchmark_multilingual.py \
319
+ --audio-prompt speaker.wav \
320
+ --languages en es fr \
321
+ --validate
322
+ ```
323
+
324
+ **Supported Languages:**
325
+ `en` (English), `es` (Spanish), `fr` (French), `de` (German), `it` (Italian), `pt` (Portuguese), `ru` (Russian), `ja` (Japanese), `zh` (Chinese), `ko` (Korean), `ar` (Arabic), `hi` (Hindi), `tr` (Turkish), `pl` (Polish), `nl` (Dutch), `sv` (Swedish), `da` (Danish), `no` (Norwegian), `fi` (Finnish), `el` (Greek), `he` (Hebrew), `ms` (Malay), `sw` (Swahili)
326
+
327
+ ### Benchmark Output
328
+
329
+ Results are saved to:
330
+
331
+ - `benchmark_output/benchmark_results.json` - English TTS results
332
+ - `benchmark_multilingual_output/multilingual_results.json` - Multilingual results
333
+ - Generated audio files: `{device}_{category}.wav`
334
+
335
+ ---
336
+
337
+ ## Architecture
338
+
339
+ Chatterbox is a two-stage TTS pipeline. This fork accelerates the most compute-intensive component (T3) with MLX:
340
+
341
+ ```
342
+ ┌─────────────────────────────────────────────────────────────────────┐
343
+ │ CHATTERBOX MLX PIPELINE │
344
+ ├─────────────────────────────────────────────────────────────────────┤
345
+ │ │
346
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
347
+ │ │ VoiceEncoder │ │ T3 │ │ S3Gen │ │
348
+ │ │ (PyTorch) │───▶│ (MLX) │───▶│ (PyTorch/MPS) │ │
349
+ │ │ ~2M params │ │ 520M params │ │ ~80M params │ │
350
+ │ └──────────────┘ └──────────────┘ └──────────────────────┘ │
351
+ │ ▲ │
352
+ │ │ │
353
+ │ 2.4x faster with MLX │
354
+ │ │
355
+ └─────────────────────────────────────────────────────────────────────┘
356
+ ```
357
+
358
+ ---
359
+
360
+ ## Supported Languages
361
+
362
+ All 23 languages from the original Chatterbox are supported:
363
+
364
+ Arabic • Danish • German • Greek • English • Spanish • Finnish • French • Hebrew • Hindi • Italian • Japanese • Korean • Malay • Dutch • Norwegian • Polish • Portuguese • Russian • Swedish • Swahili • Turkish • Chinese
365
+
366
+ ```python
367
+ from chatterbox.mtl_tts_mlx import ChatterboxMultilingualTTSMLX
368
+
369
+ model = ChatterboxMultilingualTTSMLX.from_pretrained(device="mps")
370
+
371
+ # French
372
+ wav = model.generate("Bonjour, comment ça va?", language_id="fr")
373
+
374
+ # Japanese
375
+ wav = model.generate("こんにちは、元気ですか?", language_id="ja")
376
+ ```
377
+
378
+ ---
379
+
380
+ ## Tips for Best Results
381
+
382
+ ### General Use
383
+
384
+ - Default settings (`exaggeration=0.5`, `cfg_weight=0.5`) work well for most cases
385
+ - Ensure reference audio matches target language to avoid accent transfer
386
+
387
+ ### Expressive Speech
388
+
389
+ - Lower `cfg_weight` (~0.3) + higher `exaggeration` (~0.7) for dramatic delivery
390
+ - Higher exaggeration speeds up speech; lower cfg_weight compensates
391
+
392
+ ### Memory Usage
393
+
394
+ Enable debug logging to monitor memory:
395
+
396
+ ```bash
397
+ DEBUG_MEMORY=1 python your_script.py
398
+ ```
399
+
400
+ ---
401
+
402
+ ## Differences from Original Chatterbox
403
+
404
+ | Feature | Original (Resemble AI) | This Fork |
405
+ | ------------------- | ---------------------- | ---------------------- |
406
+ | **Target Hardware** | NVIDIA CUDA | Apple Silicon |
407
+ | **ML Framework** | PyTorch | MLX + PyTorch hybrid |
408
+ | **T3 Inference** | PyTorch | MLX (2.4x faster) |
409
+ | **KV Cache** | Float32 | Float16 (32% faster) |
410
+ | **Long-form Audio** | Basic | Chunked with crossfade |
411
+
412
+ ---
413
+
414
+ ## Credits & Links
415
+
416
+ - **Original Project**: [Resemble AI's Chatterbox](https://github.com/resemble-ai/chatterbox)
417
+ - **Resemble AI**: [resemble.ai](https://resemble.ai) - For creating and open-sourcing this incredible TTS system
418
+ - **Demo**: [Hugging Face Space](https://huggingface.co/spaces/ResembleAI/Chatterbox)
419
+ - **Evaluation**: [Outperforms ElevenLabs](https://podonos.com/resembleai/chatterbox)
420
+
421
+ ### Upstream Dependencies
422
+
423
+ - [CosyVoice](https://github.com/FunAudioLLM/CosyVoice)
424
+ - [HiFT-GAN](https://github.com/yl4579/HiFTNet)
425
+ - [Llama 3](https://github.com/meta-llama/llama3)
426
+ - [MLX](https://github.com/ml-explore/mlx)
427
+
428
+ ---
429
+
430
+ ## License
431
+
432
+ MIT License - Same as the original Chatterbox project.
433
+
434
+ ---
435
+
436
+ ## Citation
437
+
438
+ If you use this project, please cite the original Chatterbox:
439
+
440
+ ```bibtex
441
+ @misc{chatterboxtts2025,
442
+ author = {{Resemble AI}},
443
+ title = {{Chatterbox-TTS}},
444
+ year = {2025},
445
+ howpublished = {\url{https://github.com/resemble-ai/chatterbox}},
446
+ note = {GitHub repository}
447
+ }
448
+ ```