venice_text_to_speech
Convert text to speech audio using Venice AI's TTS models and voice options for accessible audio content creation.
Instructions
Convert text to speech audio using Venice AI
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to convert to speech | |
| model | No | TTS model | tts-kokoro |
| voice | No | Voice ID (e.g., af_sky, af_bella, am_adam) | af_sky |
Implementation Reference
- src/tools/inference/index.ts:109-118 (handler)The handler function for venice_text_to_speech tool. It sends a POST request to Venice AI's /audio/speech endpoint with the provided text, model, and voice parameters, handles errors, and returns the generated audio as base64-encoded data in the response.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)}...` }] }; }
- src/tools/inference/index.ts:104-108 (schema)Zod schema defining the input parameters for the venice_text_to_speech tool: text (required), model (optional, default 'tts-kokoro'), voice (optional, default 'af_sky').{ 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)"), },
- src/tools/inference/index.ts:101-119 (registration)Direct registration of the venice_text_to_speech tool using server.tool(), including name, description, input schema, and handler function.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)}...` }] }; } );
- src/index.ts:16-16 (registration)Invocation of registerInferenceTools which registers the venice_text_to_speech among other inference tools to the MCP server.registerInferenceTools(server);