Skip to main content
Glama

tts-mcp

使用 OpenAI TTS API 生成高质量文本转语音的模型上下文协议 (MCP) 服务器和命令行工具。

主要特点

  • MCP 服务器:将文本转语音功能与 Claude Desktop 和其他兼容 MCP 的客户端集成

  • 语音选项:支持多个语音角色(合金、新星、回声等)

  • 高品质音频:支持各种输出格式(MP3、WAV、OPUS、AAC)

  • 可定制:配置语速、语音特征和附加说明

  • CLI 工具:也可用作命令行实用程序,用于直接进行文本到语音的转换

Related MCP server: MCP Memory Server

安装

方法 1:从存储库安装

# Clone the repository
git clone https://github.com/nakamurau1/tts-mcp.git
cd tts-mcp

# Install dependencies
npm install

# Optional: Install globally
npm install -g .

方法二:直接用npx运行(无需安装)

# Start the MCP server directly
npx tts-mcp tts-mcp-server --voice nova --model tts-1-hd

# Use the CLI tool directly
npx tts-mcp -t "Hello, world" -o hello.mp3

MCP 服务器使用情况

MCP 服务器允许您将文本转语音功能与模型上下文协议 (MCP) 兼容客户端(如 Claude Desktop)集成。

启动 MCP 服务器

# Start with default settings
npm run server

# Start with custom settings
npm run server -- --voice nova --model tts-1-hd

# Or directly with API key
node bin/tts-mcp-server.js --voice echo --api-key your-openai-api-key

MCP 服务器选项

Options:
  -V, --version       Display version information
  -m, --model <model> TTS model to use (default: "gpt-4o-mini-tts")
  -v, --voice <voice> Voice character (default: "alloy")
  -f, --format <format> Audio format (default: "mp3")
  --api-key <key>     OpenAI API key (can also be set via environment variable)
  -h, --help          Display help information

与 MCP 客户端集成

MCP 服务器可与 Claude Desktop 及其他兼容 MCP 的客户端一起使用。Claude Desktop 集成步骤如下:

  1. 打开 Claude Desktop 配置文件(通常位于~/Library/Application Support/Claude/claude_desktop_config.json

  2. 添加以下配置,包括您的 OpenAI API 密钥:

{
  "mcpServers": {
    "tts-mcp": {
      "command": "node",
      "args": ["full/path/to/bin/tts-mcp-server.js", "--voice", "nova", "--api-key", "your-openai-api-key"],
      "env": {
        "OPENAI_API_KEY": "your-openai-api-key"
      }
    }
  }
}

或者,您可以使用 npx 进行更简单的设置:

{
  "mcpServers": {
    "tts-mcp": {
      "command": "npx",
      "args": ["-p", "tts-mcp", "tts-mcp-server", "--voice", "nova", "--model", "gpt-4o-mini-tts"],
      "env": {
        "OPENAI_API_KEY": "your-openai-api-key"
      }
    }
  }
}

您可以通过两种方式提供 API 密钥:

  1. 直接方法(建议测试):使用--api-key参数将其包含在args数组中

  2. 环境变量法(更安全):如上图在env对象中设置

安全注意事项:包含 API 密钥时,请确保配置文件的安全。

  1. 重启Claude桌面

  2. 当你要求克劳德“大声朗读这段文字”或类似请求时,文本将转换为语音

可用的 MCP 工具

  • 文本转语音:将文本转换为语音并播放的工具

CLI 工具使用

您还可以将 tts-mcp 用作独立的命令行工具:

# Convert text directly
tts-mcp -t "Hello, world" -o hello.mp3

# Convert from a text file
tts-mcp -f speech.txt -o speech.mp3

# Specify custom voice
tts-mcp -t "Welcome to the future" -o welcome.mp3 -v nova

CLI 工具选项

Options:
  -V, --version           Display version information
  -t, --text <text>       Text to convert
  -f, --file <path>       Path to input text file
  -o, --output <path>     Path to output audio file (required)
  -m, --model <n>         Model to use (default: "gpt-4o-mini-tts")
  -v, --voice <n>         Voice character (default: "alloy")
  -s, --speed <number>    Speech speed (0.25-4.0) (default: 1)
  --format <format>       Output format (default: "mp3")
  -i, --instructions <text> Additional instructions for speech generation
  --api-key <key>         OpenAI API key (can also be set via environment variable)
  -h, --help              Display help information

支持的声音

支持以下语音角色:

  • 合金(默认)

  • 珊瑚

  • 回声

  • 寓言

  • 缟玛瑙

  • 新星

  • 圣人

  • 闪光

支持的型号

  • tts-1

  • tts-1-hd

  • gpt-4o-mini-tts(默认)

输出格式

支持以下输出格式:

  • mp3(默认)

  • 作品

  • 音频

  • flac

  • 音频

  • 脉冲编码调制

环境变量

您还可以使用系统环境变量配置该工具:

OPENAI_API_KEY=your-api-key-here

执照

麻省理工学院

-
security - not tested
A
license - permissive license
-
quality - not tested

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nakamurau1/tts-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server