Skip to main content
Glama

voicevox

Synthesize and playback speech using a text-to-speech engine compatible with VOICEVOX, enabling AI agents to generate natural voice output for applications.

Instructions

VOICEVOXを使用して音声を合成し、ホストコンピュータで再生します

Input Schema

NameRequiredDescriptionDefault
textNo合成する文章

Input Schema (JSON Schema)

{ "properties": { "text": { "description": "合成する文章", "type": "string" } }, "type": "object" }

Implementation Reference

  • The execute method that implements the core voicevox tool logic: creates audio query via VOICEVOX API, synthesizes speech, saves to temporary WAV file, and plays it on the host using platform-specific playback.
    async execute({ text }: VoicevoxInput): Promise<string> { try { // 音声合成用のクエリを作成 const queryResponse = await axios.post( `${this.VOICEVOX_API_URL}/audio_query`, null, { params: { text, speaker: this.VOICEVOX_API_SPEAKER_ID } } ); // 音声を合成 const synthesisResponse = await axios.post( `${this.VOICEVOX_API_URL}/synthesis`, queryResponse.data, { params: { speaker: this.VOICEVOX_API_SPEAKER_ID }, responseType: "arraybuffer", } ); // 音声データを一時ファイルに保存 fs.writeFileSync( this.TEMP_AUDIO_FILE, Buffer.from(synthesisResponse.data) ); // 音声を再生 await this.playAudio(this.TEMP_AUDIO_FILE); return `「${text}」の音声をホストコンピュータで再生しました。話者ID: ${this.VOICEVOX_API_SPEAKER_ID}`; } catch (error) { console.log(error); if (error instanceof Error) { throw new Error(`音声合成または再生に失敗しました: ${error.message}`); } throw new Error("音声合成または再生に失敗しました"); } }
  • Input schema definition using Zod for validation and TypeScript interface for typing the 'text' parameter expected by the voicevox tool.
    interface VoicevoxInput { text: string; } class VoicevoxTool extends MCPTool<VoicevoxInput> { name = "voicevox"; description = "VOICEVOXを使用して音声を合成し、ホストコンピュータで再生します"; schema = { text: { type: z.string(), description: "合成する文章", }, };
  • Supporting helper method to play the generated audio file using OS-specific commands: VLC on Windows, aplay on Linux.
    private async playAudio(filePath: string): Promise<void> { try { switch (process.platform) { // Windows case "win32": await execAsync( `vlc.exe -I dummy --dummy-quiet ${filePath} vlc://quit` ); break; // Linux or Docker case "linux": await execAsync(`aplay ${filePath}`); break; // Mac case "darwin": default: throw new Error("サポートされていないOSです"); } } catch (error) { throw new Error(`音声の再生に失敗しました: ${error}`); } } }

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

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