Skip to main content
Glama

text_to_speech_with_options

Convert text into speech with adjustable speed and selectable voices using a customizable TTS tool. Ideal for generating audio content with personalized settings.

Instructions

Convert text to speech with customizable speed

Input Schema

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

  • Handler logic for the text_to_speech_with_options tool. Parses arguments, validates text input, generates and plays audio using TTSClient with speed option, and returns success message.
    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})` }], }; }
  • JSON Schema defining the input parameters for the text_to_speech_with_options tool, including text (required), optional voice, and speed with constraints.
    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"], },
  • src/index.ts:356-360 (registration)
    The textToSpeechWithOptionsTool is registered here in the array returned by the ListToolsRequest handler.
    textToSpeechTool, textToSpeechWithOptionsTool, listVoicesTool, getModelStatusTool, ],
  • TypeScript interface for tool arguments, defining structure with optional speed and voice.
    interface TextToSpeechWithOptionsArgs extends TextToSpeechArgs { speed?: number; voice?: KokoroVoice; }
  • Supporting method in TTSClient class that performs the actual text-to-speech generation using KokoroTTS, saves to temp WAV file, 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 }); } }

Other Tools

Related 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