Mac 本地部署语音合成 IndexTTS

✨ 文章介绍了如何在 Mac(Apple Silicon)上使用 MLX 框架本地部署开源语音合成模型 IndexTTS-2。整理了环境配置、模型下载及常见报错的完整解决方案,帮助用户在本地免费实现高质量的语音克隆与情感控制。

TOC

当下的 TTS 语音合成开源方案已经很不错了,某些方面甚至可以说是媲美闭源服务的。在“丐版” Mac 上跑了一些测试,比较满意的是用 MLX 推理框架运行 IndexTTS-2 模型。

方案

推理引擎 (mlx-indextts):负责在 Mac GPU 上加速运行语音合成的核心代码。

https://github.com/solar2ain/mlx-indextts

模型权重 (IndexTTS-2-fp16):Mac 内存有限,故使用针对 Apple MLX 优化的半精度(fp16)语音合成模型,负责根据文本和参考音色生成语音。

https://huggingface.co/mlx-community/IndexTTS-2-fp16

部署

这些活全让 AI Agent 干就是了

git clone https://github.com/solar2ain/mlx-indextts.git

cd mlx-indextts

因本机有多个 Python 版本,这里使用 mise 来管理使用。

mise use python@3.13

python --version

使用 uv 安装依赖

uv sync --all-extras
# 后续运行报错 ModuleNotFoundError: No module named 'einops'
uv pip install einops

从 Hugging Face 拉取模型权重文件到当前路径下的 models 目录(梯子流量足就不考虑镜像了

uvx --from huggingface_hub hf download mlx-community/IndexTTS-2-fp16 --local-dir models/IndexTTS-2-fp16

测试生成,准备好参考音色素材 reference.wav

uv run mlx-indextts generate \
    -m models/IndexTTS-2-fp16 \
    -r reference.wav \
    -t "你好,这是一个语音合成测试。" \
    -o output.wav

这里出现报错:FileNotFoundError: W2V stats file not found: wav2vec2bert_stats.pt,这里直接从官方 IndexTeam/IndexTTS-2 仓库单独把 wav2vec2bert_stats.pt 拉下来放到 models/IndexTTS-2-fp16 模型目录

cd models/IndexTTS-2-fp16

curl -L -o wav2vec2bert_stats.pt https://huggingface.co/IndexTeam/IndexTTS-2/resolve/main/wav2vec2bert_stats.pt

然后重新运行上面的生成命令即可得到 output.wav,后续可以让 AI Agent 通过 Skill 调用。

其他 TTS 项目

https://github.com/index-tts/index-tts

https://github.com/QwenLM/Qwen3-TTS

https://github.com/breezeblue-ai/breeze-tts

https://github.com/FunAudioLLM/CosyVoice

https://github.com/fishaudio/fish-speech

https://github.com/RVC-Boss/GPT-SoVITS

https://github.com/SWivid/F5-TTS

https://github.com/hexgrad/kokoro

https://github.com/nari-labs/dia

https://github.com/2noise/ChatTTS