Skip to main content
Glama

text_to_speech_with_options

Convert text to speech with customizable voice selection and adjustable speech speed using the Kokoro TTS model.

Instructions

Convert text to speech with customizable speed

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.
speedNoSpeech rate multiplier (0.5 to 2.0)

Implementation Reference

  • Handler logic for executing the text_to_speech_with_options tool. Extracts arguments and delegates to TTSClient.generateAndPlayAudio method.
    case "text_to_speech_with_options": {
      const args = request.params.arguments as unknown as TextToSpeechWithOptionsArgs;
      if (!args.text) {
        throw new Error("Missing required argument: text");
      }
    
      await ttsClient.generateAndPlayAudio(args.text, args.voice, args.speed);
      return {
        content: [{ 
          type: "text", 
          text: `Successfully generated and played audio${args.voice ? ` using voice: ${args.voice}` : ''} (speed: ${args.speed || 1.0})` 
        }],
      };
    }
  • Tool definition including name, description, and input schema for validation.
    const textToSpeechWithOptionsTool: Tool = {
      name: "text_to_speech_with_options",
      description: "Convert text to speech with customizable speed",
      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.",
          },
          speed: {
            type: "number",
            description: "Speech rate multiplier (0.5 to 2.0)",
            minimum: 0.5,
            maximum: 2.0,
          },
        },
        required: ["text"],
      },
    };
  • TypeScript interface defining the expected arguments for the tool.
    interface TextToSpeechWithOptionsArgs extends TextToSpeechArgs {
      speed?: number;
      voice?: KokoroVoice;
    }
  • src/index.ts:356-360 (registration)
    Registers the textToSpeechWithOptionsTool in the list returned by ListToolsRequest handler.
      textToSpeechTool,
      textToSpeechWithOptionsTool,
      listVoicesTool,
      getModelStatusTool,
    ],
  • Core helper method in TTSClient that performs the actual text-to-speech generation and playback using KokoroTTS.
      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
        });
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'customizable speed' but doesn't disclose other behavioral traits: it doesn't specify output format (e.g., audio file, stream), permissions required, rate limits, or whether it's a read-only or mutating operation. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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 directly states the tool's purpose without any fluff. It's appropriately sized and front-loaded, with every word earning its place. No structural issues or unnecessary elaboration.

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 tool's complexity (3 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain the output (e.g., what's returned, format), lacks behavioral context like error handling or performance, and doesn't guide usage relative to siblings. For a tool with no structured support, more descriptive detail is needed.

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 all parameters (text, voice, speed) thoroughly. The description adds minimal value beyond the schema—it implies speed customization but doesn't provide additional context like default values or examples. 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.

Purpose4/5

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

The description clearly states the tool's purpose: converting text to speech with customizable speed. It specifies the verb ('convert') and resource ('text to speech'), distinguishing it from siblings like list_voices (which lists options) or get_model_status (which checks status). However, it doesn't explicitly differentiate from text_to_speech (likely a simpler version), so it's not a perfect 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose text_to_speech_with_options over text_to_speech (the likely sibling), nor does it specify prerequisites like needing to list_voices first for voice selection. Usage is implied but not explicitly stated.

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