Skip to main content
Glama

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
NameRequiredDescriptionDefault
textYesThe text to convert to speech
voiceNoVoice ID to use (see list_voices for available options)alloy
speedNoSpeaking speed multiplier (0.5 to 2.0)

Implementation Reference

  • 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()
  • 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()

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/fasuizu-br/brainiall-mcp-server'

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