Fish Audio MCP 服务器是一个 MCP(模型上下文协议)服务器,它能让 Fish Audio 的文本转语音 API 与 Claude 等大语言模型(LLMs)实现无缝集成,从而实现由自然语言驱动的语音合成。
你可以直接使用 npx 运行这个 MCP 服务器:
npx @alanse/fish-audio-mcp-server
或者全局安装它:
npm install -g @alanse/fish-audio-mcp-server
export FISH_API_KEY=your_fish_audio_api_key_here
{
"mcpServers": {
"fish-audio": {
"command": "npx",
"args": ["-y", "@alanse/fish-audio-mcp-server"],
"env": {
"FISH_API_KEY": "your_fish_audio_api_key_here",
"FISH_MODEL_ID": "speech-1.6",
"FISH_REFERENCE_ID": "your_voice_reference_id_here",
"FISH_OUTPUT_FORMAT": "mp3",
"FISH_STREAMING": "false",
"FISH_LATENCY": "balanced",
"FISH_MP3_BITRATE": "128",
"FISH_AUTO_PLAY": "false",
"AUDIO_OUTPUT_DIR": "~/.fish-audio-mcp/audio_output"
}
}
}
}
{
"mcpServers": {
"fish-audio": {
"command": "npx",
"args": ["-y", "@alanse/fish-audio-mcp-server"],
"env": {
"FISH_API_KEY": "your_fish_audio_api_key_here",
"FISH_MODEL_ID": "speech-1.6",
"FISH_REFERENCES": "[{'reference_id':'id1','name':'Alice','tags':['female','english']},{'reference_id':'id2','name':'Bob','tags':['male','japanese']},{'reference_id':'id3','name':'Carol','tags':['female','japanese','anime']}]",
"FISH_DEFAULT_REFERENCE": "id1",
"FISH_OUTPUT_FORMAT": "mp3",
"FISH_STREAMING": "false",
"FISH_LATENCY": "balanced",
"FISH_MP3_BITRATE": "128",
"FISH_AUTO_PLAY": "false",
"AUDIO_OUTPUT_DIR": "~/.fish-audio-mcp/audio_output"
}
}
}
}
npx @alanse/fish-audio-mcp-server
npm install -g @alanse/fish-audio-mcp-server
User: "Generate speech saying 'Hello, world! Welcome to Fish Audio TTS.'"
Claude: I'll generate speech for that text using Fish Audio TTS.
[Uses fish_audio_tts tool with text parameter]
Result: Audio file saved to ./audio_output/tts_2025-01-03T10-30-00.mp3
User: "Generate speech with voice model xyz123 saying 'This is a custom voice test'"
Claude: I'll generate speech using the specified voice model.
[Uses fish_audio_tts tool with text and reference_id parameters]
Result: Audio generated with custom voice model xyz123
User: "Use Alice's voice to say 'Hello from Alice'"
Claude: I'll generate speech using Alice's voice.
[Uses fish_audio_tts tool with reference_name: "Alice"]
Result: Audio generated with Alice's voice
User: "Generate Japanese speech saying 'こんにちは' with an anime voice"
Claude: I'll generate Japanese speech with an anime-style voice.
[Uses fish_audio_tts tool with reference_tag: "anime"]
Result: Audio generated with anime voice style
User: "What voices are available?"
Claude: I'll list all configured voice references.
[Uses fish_audio_list_references tool]
Result:
- Alice (id: id1) - Tags: female, english [Default]
- Bob (id: id2) - Tags: male, japanese
- Carol (id: id3) - Tags: female, japanese, anime
User: "Generate a long speech in streaming mode about the benefits of AI"
Claude: I'll generate the speech in streaming mode for faster response.
[Uses fish_audio_tts tool with streaming: true]
Result: Streaming audio saved to ./audio_output/tts_2025-01-03T10-35-00.mp3
User: "Stream and play in real-time: 'Welcome to the future of AI'"
Claude: I'll stream the speech via WebSocket and play it in real-time.
[Uses fish_audio_tts tool with websocket_streaming: true, realtime_play: true]
Result: Audio streamed and played in real-time via WebSocket
| 属性 | 详情 | 默认值 | 是否必需 |
|---|---|---|---|
FISH_API_KEY |
你的 Fish Audio API 密钥 | - | 是 |
FISH_MODEL_ID |
要使用的文本转语音模型(s1、speech-1.5、speech-1.6) | s1 |
可选 |
FISH_REFERENCE_ID |
默认语音参考 ID(单参考模式) | - | 可选 |
FISH_REFERENCES |
多个语音参考(见下文) | - | 可选 |
FISH_DEFAULT_REFERENCE |
使用多个参考时的默认参考 ID | - | 可选 |
FISH_OUTPUT_FORMAT |
默认音频格式(mp3、wav、pcm、opus) | mp3 |
可选 |
FISH_STREAMING |
启用流式模式(HTTP/WebSocket) | false |
可选 |
FISH_LATENCY |
延迟模式(正常、平衡) | balanced |
可选 |
FISH_MP3_BITRATE |
MP3 比特率(64、128、192) | 128 |
可选 |
FISH_AUTO_PLAY |
自动播放音频并启用实时播放 | false |
可选 |
AUDIO_OUTPUT_DIR |
音频文件输出目录 | ~/.fish-audio-mcp/audio_output |
可选 |
使用 FISH_REFERENCES 环境变量和 JSON 数组:
FISH_REFERENCES='[
{"reference_id":"id1","name":"Alice","tags":["female","english"]},
{"reference_id":"id2","name":"Bob","tags":["male","japanese"]},
{"reference_id":"id3","name":"Carol","tags":["female","japanese","anime"]}
]'
FISH_DEFAULT_REFERENCE="id1"
使用编号的环境变量:
FISH_REFERENCE_1_ID=id1
FISH_REFERENCE_1_NAME=Alice
FISH_REFERENCE_1_TAGS=female,english
FISH_REFERENCE_2_ID=id2
FISH_REFERENCE_2_NAME=Bob
FISH_REFERENCE_2_TAGS=male,japanese
fish_audio_tts使用 Fish Audio 的文本转语音 API 从文本生成语音。
text(必需):要转换为语音的文本(最多 10,000 个字符)reference_id(可选):语音模型参考 IDreference_name(可选):按名称选择语音reference_tag(可选):按标签选择语音streaming(可选):启用流式模式format(可选):输出格式(mp3、wav、pcm、opus)mp3_bitrate(可选):MP3 比特率(64、128、192)normalize(可选):启用文本规范化(默认:true)latency(可选):延迟模式(正常、平衡)output_path(可选):自定义输出文件路径auto_play(可选):自动播放生成的音频websocket_streaming(可选):使用 WebSocket 流式传输而不是 HTTPrealtime_play(可选):在 WebSocket 流式传输期间实时播放音频语音选择优先级:reference_id > reference_name > reference_tag > 默认
fish_audio_list_references列出所有配置的语音参考。
无需参数。
git clone https://github.com/da-okazaki/mcp-fish-audio-server.git
cd mcp-fish-audio-server
npm install
.env 文件:cp .env.example .env
# Edit .env with your API key
npm run build
npm run dev
运行测试套件:
npm test
mcp-fish-audio-server/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── tools/
│ │ └── tts.ts # TTS tool implementation
│ ├── services/
│ │ └── fishAudio.ts # Fish Audio API client
│ ├── types/
│ │ └── index.ts # TypeScript definitions
│ └── utils/
│ └── config.ts # Configuration management
├── tests/ # Test files
├── audio_output/ # Default audio output directory
├── package.json
├── tsconfig.json
└── README.md
本项目采用 MIT 许可证,请参阅 LICENSE 文件获取详细信息。
该服务提供两个主要方法:
服务器处理各种错误场景:
FISH_API_KEY 环境变量AUDIO_OUTPUT_DIR 路径是否存在