Back to MCP directory
publicPublicdnsLocal runtime

kyutai-tts-docker

Kyutai TTS的Docker部署方案,提供一键启动的Web界面、REST API和MCP工具支持,支持GPU加速和多语言界面。

article

README

🚀 久太语音合成(Kyutai TTS)Docker部署

久太语音合成(Kyutai TTS)的生产就绪型Docker部署方案,支持用户界面(UI)、REST API和多模态通信协议(MCP)。

🚀 快速开始

使用Docker Hub(推荐)

docker run -d \
  --name kyutai-tts \
  --gpus all \
  -p 8900:8900 \
  -e NVIDIA_VISIBLE_DEVICES=0 \
  neosun/kyutai-tts:allinone

访问地址:http://localhost:8900

使用Docker Compose

git clone https://github.com/neosun100/kyutai-tts-docker.git
cd kyutai-tts-docker
./start.sh

✨ 主要特性

  • 🚀 一键部署:自动选择GPU并检测端口。
  • 🎨 三种访问模式:支持Web UI、REST API和MCP工具。
  • 🧠 智能GPU管理:采用懒加载机制并自动释放内存。
  • 🌐 多语言界面:提供英文和中文界面。
  • 📦 一体化镜像:无需外部依赖,包含所有模型。
  • 🔒 生产就绪:支持HTTPS、健康检查和监控。

📦 安装指南

前提条件

  • Docker 20.10 及以上版本
  • Docker Compose 2.0 及以上版本
  • 支持CUDA的NVIDIA GPU
  • nvidia-docker运行时

方法一:从Docker Hub拉取

docker pull neosun/kyutai-tts:allinone

方法二:从源码构建

git clone https://github.com/neosun100/kyutai-tts-docker.git
cd kyutai-tts-docker
docker-compose build

🔧 配置说明

环境变量

| 变量 | 默认值 | 描述 | |------|--------|------| | PORT | 8900 | 服务端口 | | DEVICE | cuda | 设备类型(cuda/cpu) | | GPU_IDLE_TIMEOUT | 60 | GPU空闲超时时间(秒) | | NVIDIA_VISIBLE_DEVICES | 0 | 要使用的GPU ID |

.env文件示例

PORT=8900
DEVICE=cuda
GPU_IDLE_TIMEOUT=60
NVIDIA_VISIBLE_DEVICES=0

💻 使用示例

Web UI

  1. 打开浏览器,访问:http://localhost:8900
  2. 输入要合成的文本
  3. (可选)调整参数
  4. 点击“生成”
  5. 播放或下载音频

REST API

生成语音

curl -X POST http://localhost:8900/api/tts \
  -F "text=Hello, world!" \
  -F "cfg_coef=2.0" \
  --output output.wav

检查GPU状态

curl http://localhost:8900/api/gpu/status

释放GPU内存

curl -X POST http://localhost:8900/api/gpu/offload

MCP工具

详细的MCP使用说明请参阅 MCP_GUIDE.md

result = await mcp_client.call_tool(
    "text_to_speech",
    {
        "text": "Hello from MCP!",
        "output_path": "/tmp/output.wav"
    }
)

📚 详细文档

项目结构

kyutai-tts-docker/
├── app.py                 # Flask应用程序
├── gpu_manager.py         # GPU资源管理器
├── mcp_server.py          # MCP服务器
├── Dockerfile             # Docker镜像文件
├── Dockerfile.allinone    # 一体化镜像文件
├── docker-compose.yml     # Docker Compose配置文件
├── start.sh               # 一键启动脚本
├── test_api.sh            # API测试脚本
└── docs/                  # 文档目录
    ├── QUICKSTART.md
    ├── MCP_GUIDE.md
    └── TEST_REPORT.md

技术栈

  • 框架:Flask 3.0
  • 机器学习框架:PyTorch 2.7 + CUDA 12.1
  • 语音合成模型:Kyutai TTS 1.6B(英文/法文)
  • API文档:Swagger/Flasgger
  • MCP:FastMCP 0.2
  • 容器:Docker + nvidia-docker

API文档

服务启动后,可通过以下地址访问Swagger文档:http://localhost:8900/apidocs

可用端点

  • GET /health - 健康检查
  • GET /api/gpu/status - GPU状态
  • POST /api/tts - 生成语音
  • POST /api/gpu/offload - 释放GPU内存

生产部署

使用Nginx反向代理

server {
    listen 443 ssl;
    server_name your-domain.com;
    
    location / {
        proxy_pass http://localhost:8900;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

多GPU设置

# GPU 0
NVIDIA_VISIBLE_DEVICES=0 PORT=8900 docker-compose up -d

# GPU 1
NVIDIA_VISIBLE_DEVICES=1 PORT=8901 docker-compose up -d

性能指标

  • 模型大小:16亿参数
  • GPU内存:3 - 4GB
  • 延迟:350ms(L40S,32并发)
  • 速度:实时速度的3 - 5倍
  • 音频质量:16位PCM,24kHz

🤝 贡献指南

欢迎贡献代码!请随意提交拉取请求。

  1. 分叉仓库
  2. 创建功能分支(git checkout -b feature/AmazingFeature
  3. 提交更改(git commit -m 'Add some AmazingFeature'
  4. 推送到分支(git push origin feature/AmazingFeature
  5. 打开拉取请求

📝 更新日志

v1.0.0 (2025-12-14)

  • 初始版本发布
  • 支持GPU的Docker部署
  • 支持多语言的Web UI
  • 带有Swagger文档的REST API
  • MCP服务器实现
  • 一体化Docker镜像

📄 许可证

  • Python代码:MIT许可证
  • Rust代码:Apache许可证
  • 模型权重:CC-BY 4.0

🙏 致谢

⭐ 星标历史

Star History Chart

📱 关注我们

公众号

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client