synthesize_speech
Convert text to natural-sounding speech audio with customizable voice options and speaking speed, returning MP3 format audio.
Instructions
Convert text to natural-sounding speech audio.
Returns base64-encoded audio in MP3 format. Use list_voices to see available voice options.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The text to convert to speech | |
| voice | No | Voice ID to use (see list_voices for available options) | alloy |
| speed | No | Speaking speed multiplier (0.5 to 2.0) |
Implementation Reference
- server.py:94-115 (handler)Main handler function for the synthesize_speech tool. It converts text to speech by making an async HTTP POST request to the Brainiall API endpoint '/v1/tts/synthesize' with text, voice (default: 'alloy'), and speed (default: 1.0) parameters. Returns base64-encoded MP3 audio.
@mcp.tool() async def synthesize_speech( text: Annotated[str, "The text to convert to speech"], voice: Annotated[str, "Voice ID to use (see list_voices for available options)"] = "alloy", speed: Annotated[float, "Speaking speed multiplier (0.5 to 2.0)"] = 1.0, ) -> dict: """Convert text to natural-sounding speech audio. Returns base64-encoded audio in MP3 format. Use list_voices to see available voice options. """ async with _client() as client: response = await client.post( "/v1/tts/synthesize", json={ "text": text, "voice": voice, "speed": speed, }, ) response.raise_for_status() return response.json() - server.py:94-99 (schema)Input schema definition for synthesize_speech using Annotated type hints. Parameters: text (str, required), voice (str, default 'alloy'), and speed (float, range 0.5-2.0, default 1.0). Each parameter includes descriptive metadata for tool documentation.
@mcp.tool() async def synthesize_speech( text: Annotated[str, "The text to convert to speech"], voice: Annotated[str, "Voice ID to use (see list_voices for available options)"] = "alloy", speed: Annotated[float, "Speaking speed multiplier (0.5 to 2.0)"] = 1.0, ) -> dict: - server.py:94-94 (registration)Tool registration decorator @mcp.tool() that registers the synthesize_speech function as an MCP tool with the FastMCP server instance.
@mcp.tool()