Skip to main content

MCP server for text-to-speech using bytedance-tts - generates audio from text

Project description

MCP Bytedance TTS 语音生成器

本项目是一个 Model Context Protocol (MCP) 服务器,基于字节跳动 OpenSpeech TTS 的 HTTP 接口,将文本转换为语音音频。 遵循"只使用 HTTP,不使用 WebSocket"的约定。

✨ 功能特性

  • 文本转语音:调用 Bytedance OpenSpeech TTS HTTP 接口生成音频
  • 音色管理:支持通过 voice-config.json 将可读名称映射到官方 voice_type
  • 简单集成:暴露 MCP 工具,Agent 直接调用生成 WAV 文件
  • 跨平台运行:Windows、Linux、macOS

🚀 安装

使用 uvx(推荐)

uvx mcp-bytedance-tts@latest  # 直接运行、更新,无需安装

或者使用 pipx 安装:

pipx install mcp-bytedance-tts

使用 uvx 运行(推荐)

uvx mcp-bytedance-tts

构建和发布

rm -rf dist && pip install build && python -m build && pip install twine && twine upload dist/*

⚙️ 配置

config.json 中填写以下字段:

  • appid:控制台获取的应用 ID
  • accessToken:控制台获取的访问令牌(用于 Authorization)
  • secretKey:控制台获取的密钥(当前 HTTP 方案不直接使用)
  • defaultVoiceType:默认的 voice_type(如 zh_male_xxx)
  • defaultAudioEncoding:音频编码(默认 wav)
  • uid:用户标识

可选在项目 src/ 目录放置 voice-config.json,将“可读名称”映射到“官方 voice_type ID”。当调用时传入名称会自动解析为 ID。

安全提示:请勿将密钥、令牌提交到版本库。

🖥️ MCP 客户端配置

在 MCP 客户端(例如 Claude Desktop、Cursor)的配置中添加:

使用 uvx(推荐)

{
  "mcpServers": {
    "mcp-bytedance-tts": {
      "command": "uvx",
      "args": ["mcp-bytedance-tts"]
    }
  }
}

🛠️ 可用工具

mcp_bytedance_tts_generate_audio

使用字节跳动 OpenSpeech TTS 的 HTTP 接口(仅 HTTP)将文本生成音频文件。

参数

  • text(string,必填):要转换为语音的文本
  • voiceType(string,可选):音色名称或 voice_type ID;未提供时使用 defaultVoiceType
  • outputDir(string,必填):输出目录
{
  "name": "mcp_bytedance_tts_generate_audio",
  "arguments": {
    "text": "请将这段文字合成为语音文件",
    "voiceType": "zh_male_yuanboxiaoshu_moon_bigtts",
    "outputDir": "./output"
  }
}

返回值

  • 文本:生成成功消息,包含最终 WAV 文件路径(例如 ./output/1767514828_93829.wav)

工具定义位置:server.py

⚡ 快速开始

uvx mcp-bytedance-tts

💡 使用示例

配置完成后,你可以直接让 AI 助手:

  • "将这段中文生成音频文件"
  • "指定音色 温柔女神 生成语音"
  • "把文本生成 WAV 并保存到 ./output"

音色映射

音色名称到 ID 的映射关系存储在 voice-config.json 中。 例如,"温柔女神" 映射到 "ICL_zh_female_wenrounvshen_239eff5e8ffa_tob"。

💻 开发

设置开发环境

git clone https://github.com/aardpro/mcp-bytedance-tts.git
cd mcp-bytedance-tts
pip install -e ".[dev]"

运行测试

pytest

📂 项目结构

mcp-bytedance-tts/
├── src/
│   └── main/
│       ├── __init__.py
│       ├── __main__.py
│       ├── server.py
│       └── config.json
├── voice-config.json
├── pyproject.toml
├── requirements.txt
├── README.md
├── APIDOC.md
└── LICENSE

❓ 常见问题

配置问题

请确保已正确填写 config.json 的 appid 与 accessToken,并设置 defaultVoiceType。

音频生成失败

如果音频生成失败,请检查:

  1. appid 与 accessToken 是否有效
  2. voiceType 是否存在或映射正确
  3. outputDir 是否有写入权限

📄 许可证

MIT License - 详见 LICENSE 文件。

🤝 贡献

欢迎提交 Pull Request 来改进这个项目!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_bytedance_tts-1.0.5.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_bytedance_tts-1.0.5-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file mcp_bytedance_tts-1.0.5.tar.gz.

File metadata

  • Download URL: mcp_bytedance_tts-1.0.5.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mcp_bytedance_tts-1.0.5.tar.gz
Algorithm Hash digest
SHA256 bd96b6fa50ae5140ee5fedf06eb7269ca18a0f44d28de973f0a2837b8c6532ee
MD5 f9535bee51623e9ab775cc62ab93befb
BLAKE2b-256 d6fcd9a8ae47c71afbc19407127a24a41066c487e82af0c1a22ca381bc15c0ed

See more details on using hashes here.

File details

Details for the file mcp_bytedance_tts-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_bytedance_tts-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cc95c4103fc522ff6db5282e2fdc11fda3a29d628700b0151c77bedbe7d51f3f
MD5 72c6cb9cd03cde5986e29f666f0c9abb
BLAKE2b-256 9ddb80dd3af3e152d2ae56832110cf05ca84e9b2f3ae5031407961ec81a43e93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page