Synthesize Speech with Custom Voices
MCP server for Fish Audio's TTS API - natural-language speech generation with multi-voice selection by ID, name, or tag, and HTTP/WebSocket streaming.
Why it matters
Integrate Fish Audio's advanced Text-to-Speech API with LLMs to generate natural-sounding speech. Supports voice cloning, multilingual capabilities, and streaming for dynamic audio applications.
Outcomes
What it gets done
Generate speech from text using Fish Audio TTS.
Clone custom voices for unique audio output.
Support multilingual speech synthesis.
Stream audio in real-time for low-latency applications.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-fish-audio | bash Capabilities
Tools your agent gets
Generates speech from text using Fish Audio's TTS API with support for custom voices and streaming.
Displays all configured voice references with their IDs, names, and tags.
Overview
Fish Audio MCP Server
An MCP server exposing Fish Audio's TTS API as two tools - fish_audio_tts for text-to-speech generation with voice selection and streaming, and fish_audio_list_references for listing configured voices - to LLMs like Claude. Use for conversational text-to-speech generation with multiple selectable voices. Requires a Fish Audio API key and network access; text per call is capped at 10,000 characters.
What it does
An MCP server integrating Fish Audio's Text-to-Speech API with LLMs like Claude, turning natural-language requests into synthesized speech. Fish Audio itself provides state-of-the-art voice synthesis, voice cloning, multilingual support (including English, Japanese, and Chinese), low-latency streaming, and fine-grained control over speech prosody and emotion; this server exposes those capabilities as MCP tools.
It provides two tools. fish_audio_tts generates speech from text (up to 10,000 characters), with parameters for selecting a voice by reference_id, reference_name, or reference_tag (in that priority order, falling back to a configured default), choosing output format (mp3, wav, pcm, or opus), MP3 bitrate (64/128/192), latency mode (normal or balanced), text normalization, a custom output path, auto-play, and either HTTP or WebSocket streaming with optional real-time playback during WebSocket streaming. fish_audio_list_references takes no parameters and returns all configured voice references with their IDs, names, tags, and which one is the default.
Multiple voice references can be configured two ways: a FISH_REFERENCES environment variable holding a JSON array of {reference_id, name, tags} objects plus a FISH_DEFAULT_REFERENCE, or individually numbered variables (FISH_REFERENCE_1_ID, FISH_REFERENCE_1_NAME, FISH_REFERENCE_1_TAGS, and so on) for backward compatibility. A single-voice mode is also supported for simpler setups using just FISH_REFERENCE_ID.
npx @alanse/fish-audio-mcp-server
Documented usage patterns include generating basic speech from text, selecting a specific voice by ID, name ("Use Alice's voice"), or tag ("anime voice" for a Japanese phrase), listing all available configured voices, running in HTTP streaming mode for faster response on long text, and WebSocket streaming with real-time playback.
The underlying service exposes two generation modes internally: generateSpeech for standard, buffer-returning TTS suited to short texts with lower memory use, and generateSpeechStream for streaming, real-time-suited generation on longer texts. Documented error codes include INVALID_API_KEY, NETWORK_ERROR, INVALID_PARAMS, QUOTA_EXCEEDED, and SERVER_ERROR.
When to use - and when NOT to
Use this connector when you want an AI assistant to generate spoken audio from text conversationally - picking a specific voice by name or tag, streaming long-form narration, or managing a small library of configured voices for different personas or languages. It requires a Fish Audio API key and network access to Fish Audio's service, so it is not usable offline, and generated text is capped at 10,000 characters per call, so very long content needs to be chunked.
Capabilities
Accepts text to synthesize plus optional voice-selection and format parameters. Returns a generated audio file (mp3/wav/pcm/opus) written to a configurable output directory, or a streamed audio buffer for real-time playback, plus a listing of configured voice references when queried, built on the Fish Audio TTS API.
How to install
Install via npx @alanse/fish-audio-mcp-server or a global npm install, configured entirely through environment variables (FISH_API_KEY, FISH_MODEL_ID, FISH_REFERENCES/FISH_REFERENCE_ID, FISH_OUTPUT_FORMAT, FISH_STREAMING, AUDIO_OUTPUT_DIR, and related settings) inside an MCP client's server configuration.
Who it's for
Developers and content creators who want AI-driven text-to-speech with selectable voices and streaming support wired directly into their LLM workflow, rather than calling the Fish Audio API manually or using a separate TTS tool.
Source README
Fish Audio MCP Server
An MCP (Model Context Protocol) server that provides seamless integration between Fish Audio's Text-to-Speech API and LLMs like Claude, enabling natural language-driven speech synthesis.
What is Fish Audio?
Fish Audio is a cutting-edge Text-to-Speech platform that offers:
- ๐ State-of-the-art voice synthesis with natural-sounding output
- ๐ฏ Voice cloning capabilities to create custom voice models
- ๐ Multilingual support including English, Japanese, Chinese, and more
- โก Low-latency streaming for real-time applications
- ๐จ Fine-grained control over speech prosody and emotions
This MCP server brings Fish Audio's powerful capabilities directly to your LLM workflows.
Features
- ๐๏ธ High-Quality TTS: Leverage Fish Audio's state-of-the-art TTS models
- ๐ Streaming Support: Real-time audio streaming for low-latency applications
- ๐จ Multiple Voices: Support for custom voice models via reference IDs
- ๐ฏ Smart Voice Selection: Select voices by ID, name, or tags
- ๐ Voice Library Management: Configure and manage multiple voice references
- ๐ง Flexible Configuration: Environment variable-based configuration
- ๐ฆ Multiple Audio Formats: Support for MP3, WAV, PCM, and Opus
- ๐ Easy Integration: Simple setup with any MCP-compatible client
Quick Start
Installation
You can run this MCP server directly using npx:
npx @alanse/fish-audio-mcp-server
Or install it globally:
npm install -g @alanse/fish-audio-mcp-server
Configuration
Get your Fish Audio API key from Fish Audio
Set up environment variables:
export FISH_API_KEY=your_fish_audio_api_key_here
- Add to your MCP settings configuration:
Single Voice Mode (Simple)
{
"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"
}
}
}
}
Multiple Voice Mode (Advanced)
{
"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"
}
}
}
}
Environment Variables
| Variable | Description | Default | Required |
|---|---|---|---|
FISH_API_KEY |
Your Fish Audio API key | - | Yes |
FISH_MODEL_ID |
TTS model to use (s1, speech-1.5, speech-1.6) | s1 |
Optional |
FISH_REFERENCE_ID |
Default voice reference ID (single reference mode) | - | Optional |
FISH_REFERENCES |
Multiple voice references (see below) | - | Optional |
FISH_DEFAULT_REFERENCE |
Default reference ID when using multiple references | - | Optional |
FISH_OUTPUT_FORMAT |
Default audio format (mp3, wav, pcm, opus) | mp3 |
Optional |
FISH_STREAMING |
Enable streaming mode (HTTP/WebSocket) | false |
Optional |
FISH_LATENCY |
Latency mode (normal, balanced) | balanced |
Optional |
FISH_MP3_BITRATE |
MP3 bitrate (64, 128, 192) | 128 |
Optional |
FISH_AUTO_PLAY |
Auto-play audio and enable real-time playback | false |
Optional |
AUDIO_OUTPUT_DIR |
Directory for audio file output | ~/.fish-audio-mcp/audio_output |
Optional |
Configuring Multiple Voice References
You can configure multiple voice references in two ways:
JSON Array Format (Recommended)
Use the FISH_REFERENCES environment variable with a JSON array:
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"
Individual Format (Backward Compatibility)
Use numbered environment variables:
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
Usage
Once configured, the Fish Audio MCP server provides two tools to LLMs.
Tool 1: fish_audio_tts
Generates speech from text using Fish Audio's TTS API.
Parameters
text(required): Text to convert to speech (max 10,000 characters)reference_id(optional): Voice model reference IDreference_name(optional): Select voice by namereference_tag(optional): Select voice by tagstreaming(optional): Enable streaming modeformat(optional): Output format (mp3, wav, pcm, opus)mp3_bitrate(optional): MP3 bitrate (64, 128, 192)normalize(optional): Enable text normalization (default: true)latency(optional): Latency mode (normal, balanced)output_path(optional): Custom output file pathauto_play(optional): Automatically play the generated audiowebsocket_streaming(optional): Use WebSocket streaming instead of HTTPrealtime_play(optional): Play audio in real-time during WebSocket streaming
Voice Selection Priority: reference_id > reference_name > reference_tag > default
Tool 2: fish_audio_list_references
Lists all configured voice references.
Parameters
No parameters required.
Returns
- List of configured voice references with their IDs, names, and tags
- Default reference ID
Examples
Basic Text-to-Speech
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
Using Custom Voice by ID
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
Using Voice by Name
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
Using Voice by Tag
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
List Available Voices
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
HTTP Streaming Mode
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
WebSocket Real-time Streaming
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
Development
Local Development
- Clone the repository:
git clone https://github.com/da-okazaki/mcp-fish-audio-server.git
cd mcp-fish-audio-server
- Install dependencies:
npm install
- Create
.envfile:
cp .env.example .env
# Edit .env with your API key
- Build the project:
npm run build
- Run in development mode:
npm run dev
Testing
Run the test suite:
npm test
Project Structure
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
API Documentation
Fish Audio Service
The service provides two main methods:
generateSpeech: Standard TTS generation
- Returns audio buffer
- Suitable for short texts
- Lower memory usage
generateSpeechStream: Streaming TTS generation
- Returns audio stream
- Suitable for long texts
- Real-time processing
Error Handling
The server handles various error scenarios:
- INVALID_API_KEY: Invalid or missing API key
- NETWORK_ERROR: Connection issues with Fish Audio API
- INVALID_PARAMS: Invalid request parameters
- QUOTA_EXCEEDED: API rate limit exceeded
- SERVER_ERROR: Fish Audio server errors
Troubleshooting
Common Issues
"FISH_API_KEY environment variable is required"
- Ensure you've set the
FISH_API_KEYenvironment variable - Check that the API key is valid
- Ensure you've set the
"Network error: Unable to reach Fish Audio API"
- Check your internet connection
- Verify Fish Audio API is accessible
- Check for proxy/firewall issues
"Text length exceeds maximum limit"
- Split long texts into smaller chunks
- Maximum supported length is 10,000 characters
Audio files not appearing
- Check the
AUDIO_OUTPUT_DIRpath exists - Ensure write permissions for the directory
- Check the
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.