Skip to main content
Glama

venice_text_to_speech

Convert text to speech audio using Venice AI's TTS models and customizable voices for accessible audio content creation.

Instructions

Convert text to speech audio using Venice AI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to convert to speech
modelNoTTS modeltts-kokoro
voiceNoVoice ID (e.g., af_sky, af_bella, am_adam)af_sky

Implementation Reference

  • The main handler function that executes the text-to-speech logic by calling the Venice AI API, processing the audio response into base64, and formatting the output.
    async ({ text, model, voice }) => { const response = await veniceAPI("/audio/speech", { method: "POST", body: JSON.stringify({ model, input: text, voice }) }); if (!response.ok) { const data = await response.json() as { error?: { message?: string } }; return { content: [{ type: "text" as const, text: `Error: ${data.error?.message || response.statusText}` }] }; } const arrayBuffer = await response.arrayBuffer(); const base64 = Buffer.from(arrayBuffer).toString("base64"); return { content: [{ type: "text" as const, text: `Audio generated (${Math.round(base64.length / 1024)}KB MP3): data:audio/mp3;base64,${base64.substring(0, 50)}...` }] }; }
  • Zod schema defining the input parameters for the tool: text, optional model, and optional voice.
    { text: z.string().describe("Text to convert to speech"), model: z.string().optional().default("tts-kokoro").describe("TTS model"), voice: z.string().optional().default("af_sky").describe("Voice ID (e.g., af_sky, af_bella, am_adam)"), },
  • The server.tool() call that registers the venice_text_to_speech tool with its schema and handler.
    server.tool( "venice_text_to_speech", "Convert text to speech audio using Venice AI", { text: z.string().describe("Text to convert to speech"), model: z.string().optional().default("tts-kokoro").describe("TTS model"), voice: z.string().optional().default("af_sky").describe("Voice ID (e.g., af_sky, af_bella, am_adam)"), }, async ({ text, model, voice }) => { const response = await veniceAPI("/audio/speech", { method: "POST", body: JSON.stringify({ model, input: text, voice }) }); if (!response.ok) { const data = await response.json() as { error?: { message?: string } }; return { content: [{ type: "text" as const, text: `Error: ${data.error?.message || response.statusText}` }] }; } const arrayBuffer = await response.arrayBuffer(); const base64 = Buffer.from(arrayBuffer).toString("base64"); return { content: [{ type: "text" as const, text: `Audio generated (${Math.round(base64.length / 1024)}KB MP3): data:audio/mp3;base64,${base64.substring(0, 50)}...` }] }; } );

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/georgeglarson/venice-mcp'

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