GPU-accelerated text-to-speech · OpenAI-compatible API
POST /v1/audio/speech# curl
curl http://HOST:8880/v1/audio/speech \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kokoro",
"voice": "af_heart",
"input": "Hello world!",
"speed": 1.0
}' --output speech.mp3
# Python (openai library)
from openai import OpenAI
client = OpenAI(
base_url="http://HOST:8880/v1",
api_key="YOUR_API_KEY"
)
response = client.audio.speech.create(
model="kokoro",
voice="af_heart",
input="Hello world!"
)
response.stream_to_file("speech.mp3")
POST /v1/audio/speech// npm install openai
const { OpenAI } = require('openai');
const fs = require('fs');
const client = new OpenAI({
baseURL: 'http://HOST:3011/v1',
apiKey: 'YOUR_API_KEY'
});
async function generateSpeech() {
const mp3 = await client.audio.speech.create({
model: 'kokoro',
voice: 'bm_fable',
input: 'Hello world! This is a test of Kokoro TTS in Node JS.',
speed: 0.8 // <-- Set speed here
});
const buffer = Buffer.from(await mp3.arrayBuffer());
fs.writeFileSync('speech.mp3', buffer);
}
generateSpeech();
GET /v1/audio/voicescurl http://HOST:8880/v1/audio/voices \
-H "Authorization: Bearer YOUR_API_KEY"
GET /statscurl http://HOST:8880/stats