TTS

Generate speech audio from text using the z-ai-web-dev-sdk TTS API.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/tmtgroupbot/lptracker-deploy --skill tts-tmtgroupbot
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: TTS
Source: https://github.com/tmtgroupbot/lptracker-deploy/tree/main/skills/TTS
Command: npx skills add https://github.com/tmtgroupbot/lptracker-deploy --skill tts-tmtgroupbot

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires z-ai-web-dev-sdk, and includes scripts (resource) components.

What problem does it solve? Converting written text into spoken audio for applications requires handling API constraints, audio formats, and backend integration, which this Skill implements using the z-ai-web-dev-sdk. ## Core Features & Use Cases - Text-to-Speech Generation: Convert text up to 1024 characters into WAV, MP3, or PCM audio with seven voices, adjustable speed (0.5-2.0), and volume control. - CLI and SDK Modes: Use the z-ai CLI for quick one-off conversions or the SDK for backend integration in Express.js and Next.js API routes. - Use Case: Build an e-learning app that converts lesson text into narrated audio files, splitting long content into chunks and batch-generating WAV files served through an API endpoint. ## Quick Start Ask the AI to convert the text "Hello, world" into a WAV audio file using the TTS skill.

Frequently Asked Questions about TTS

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert text to speech in JavaScript?

Import z-ai-web-dev-sdk, create an instance with ZAI.create(), then call zai.audio.tts.create() with your input text, voice, speed, and response_format. Convert the returned Response via response.arrayBuffer() and write it to a file with fs.writeFileSync.

What audio formats does the z-ai TTS API support?

The API supports WAV, MP3, and PCM output formats for non-streaming requests. When streaming is enabled with stream: true, only the PCM format is supported, and audio is generated at a 24000 Hz sample rate.

Can I use z-ai-web-dev-sdk in client-side browser code?

No, z-ai-web-dev-sdk must be used in backend code only, never in client-side code. For web apps, expose it through a server endpoint such as a Next.js API route or Express.js handler that returns the audio buffer.

Why does my TTS request fail with long text input?

The API limits input to 1024 characters per request, so longer text causes errors. Split the text into sentence-based chunks under the limit, generate audio for each chunk, and combine the resulting files.

Why is response.audio undefined when calling the TTS API?

The SDK returns a standard Response object without an audio property. Call await response.arrayBuffer() on the response, then convert it with Buffer.from(new Uint8Array(arrayBuffer)) before saving.