Skip to main content
Glama

speak

Convert text into speech using the VOICEVOX engine, enabling audio generation and playback for applications requiring voice synthesis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes

Implementation Reference

  • Handler function that takes text input, uses VOICEVOX API via helpers to generate speech audio, saves it to /tmp/voicevox.wav, plays it using afplay, and returns success response.
    async ({ text }) => {
      const resolvedSpeakerId = Number(process.env.SPEAKER_ID);
      if (!resolvedSpeakerId || isNaN(resolvedSpeakerId)) {
        throw new Error("speaker_idが指定されてないか、環境変数SPEAKER_IDが不正です");
      }
      const query = await createAudioQuery(text, resolvedSpeakerId);
      const buffer = await synthesizeVoice(query, resolvedSpeakerId);
      const filePath = "/tmp/voicevox.wav";
      saveAudioFile(buffer, filePath);
      playAudio(filePath);
      return {
        content: [
          {
            type: "text",
            text: "OK",
          }
        ]
      };
    }
  • Zod schema defining the input parameter 'text' as a required string.
    { text: z.string() },
  • src/index.ts:49-70 (registration)
    MCP server.tool call registering the 'speak' tool with its schema and handler function.
    server.tool("speak",
      { text: z.string() },
      async ({ text }) => {
        const resolvedSpeakerId = Number(process.env.SPEAKER_ID);
        if (!resolvedSpeakerId || isNaN(resolvedSpeakerId)) {
          throw new Error("speaker_idが指定されてないか、環境変数SPEAKER_IDが不正です");
        }
        const query = await createAudioQuery(text, resolvedSpeakerId);
        const buffer = await synthesizeVoice(query, resolvedSpeakerId);
        const filePath = "/tmp/voicevox.wav";
        saveAudioFile(buffer, filePath);
        playAudio(filePath);
        return {
          content: [
            {
              type: "text",
              text: "OK",
            }
          ]
        };
      }
    )
  • Helper function to create an audio synthesis query using VOICEVOX API.
    export async function createAudioQuery(text: string, speakerId: number) {
      const res = await fetch(`${VOICEVOX_API_URL}/audio_query?speaker=${speakerId}&text=${encodeURIComponent(text)}`, {
        method: "POST",
      });
      return await res.json();
    }
  • Helper function to synthesize audio from query using VOICEVOX API, applying custom speed scale from env.
    export async function synthesizeVoice(query: any, speakerId: number) {
      const speedScale = process.env.SPEED_SCALE ? Number(process.env.SPEED_SCALE) : 1.2;
      query.speedScale = speedScale;
      const res = await fetch(`${VOICEVOX_API_URL}/synthesis?speaker=${speakerId}`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify(query),
      });
      const audioBlob = await res.blob();
      return Buffer.from(await audioBlob.arrayBuffer());
    } 
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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

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/Yuki10Kobayashi/voicevox-mcp'

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