Skip to main content
Glama

text_to_speech

Convert text to speech and play it through system audio using customizable voice options for accessibility, content consumption, or audio output needs.

Instructions

Convert text to speech and play it through system audio

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to convert to speech
voiceNoThe voice to use for speech synthesis (e.g. 'af_bella'). Use list_voices to see available options.

Implementation Reference

  • MCP CallToolRequest handler for 'text_to_speech' tool: validates args, calls TTSClient.generateAndPlayAudio, returns success message.
    case "text_to_speech": {
      const args = request.params.arguments as unknown as TextToSpeechArgs;
      if (!args.text) {
        throw new Error("Missing required argument: text");
      }
    
      await ttsClient.generateAndPlayAudio(args.text, args.voice);
      return {
        content: [{ 
          type: "text", 
          text: `Successfully generated and played audio${args.voice ? ` using voice: ${args.voice}` : ''}` 
        }],
      };
    }
  • Tool definition including inputSchema (JSON schema) for validating 'text_to_speech' arguments.
    const textToSpeechTool: Tool = {
      name: "text_to_speech",
      description: "Convert text to speech and play it through system audio",
      inputSchema: {
        type: "object",
        properties: {
          text: {
            type: "string",
            description: "The text to convert to speech",
            minLength: 1,
            maxLength: 1000,
          },
          voice: {
            type: "string",
            description: "The voice to use for speech synthesis (e.g. 'af_bella'). Use list_voices to see available options.",
          },
        },
        required: ["text"],
      },
    };
  • Core TTS helper method in TTSClient: generates speech audio using KokoroTTS, saves to temp WAV, and plays it synchronously.
    async generateAndPlayAudio(text: string, voice?: KokoroVoice, speed?: number): Promise<void> {
      await this.waitForInit();
      if (!this.ttsInstance) {
        throw new Error("TTS model not initialized");
      }
    
      const audio = await this.ttsInstance.generate(text, {
        voice: voice || DEFAULT_VOICE,
        // @ts-ignore-line
        speed: speed || DEFAULT_SPEECH_SPEED,
      });
    
      const tempFile = join(tmpdir(), `${Date.now()}.wav`);
      await audio.save(tempFile);
      
      await player.play({
        path: tempFile,
        sync: true
      });
    }
  • TypeScript interface defining expected arguments for text_to_speech tool.
    interface TextToSpeechArgs {
      text: string;
      voice?: KokoroVoice;
    }
  • src/index.ts:355-360 (registration)
    Registration of text_to_speech tool (as textToSpeechTool) in the ListToolsRequest handler response.
    tools: [
      textToSpeechTool,
      textToSpeechWithOptionsTool,
      listVoicesTool,
      getModelStatusTool,
    ],
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the action and output ('play it through system audio'), but fails to address key traits like permissions needed, rate limits, whether it's a read-only or destructive operation, or error handling. This leaves significant gaps for an AI agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. Every word earns its place, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a text-to-speech tool with no annotations and no output schema, the description is incomplete. It lacks information on behavioral aspects (e.g., audio format, playback behavior, errors) and does not explain return values or side effects, leaving the agent with insufficient context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters (text and voice) thoroughly. The description does not add any additional meaning or context beyond what the schema provides, such as examples or usage notes for parameters. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('convert text to speech') and the resource ('system audio'), distinguishing it from siblings like list_voices (which lists options) and text_to_speech_with_options (which offers more customization). It uses precise verbs and specifies the output mechanism.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for converting text to audio playback, but does not explicitly state when to use this tool versus text_to_speech_with_options or other alternatives. It provides basic context but lacks explicit guidance on exclusions or comparisons with siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/hammeiam/koroko-speech-mcp'

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