LEAPERone Docs

Text to Speech Guide

Learn how to convert text to speech audio with LEAPERone, choose TTS models and voices, and handle binary audio responses.

The Text to Speech endpoint generates spoken audio from text input. Choose from preset voices across multiple languages, or clone any voice from a short audio sample.

Models

ModelPricingBest for
moss-tts-nano0.005 credits / 1K charsMultilingual speech with voice cloning

Quick Start

POST /v1/audio/speech
curl -X POST https://api.leaper.one/v1/audio/speech \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"input": "Hello world!", "voice": "alloy"}' \
  --output hello.wav

The response is a WAV audio file you can play directly.

Using the OpenAI SDK

The endpoint is OpenAI-compatible, so you can use the official SDK:

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.leaper.one/v1",
    api_key="sk-your-api-key"
)

response = client.audio.speech.create(
    model="moss-tts-nano",
    input="Welcome to LEAPERone. This is a text to speech demo.",
    voice="alloy"
)
response.stream_to_file("welcome.wav")
Node.js
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.leaper.one/v1",
  apiKey: "sk-your-api-key",
});

const response = await client.audio.speech.create({
  model: "moss-tts-nano",
  input: "Welcome to LEAPERone.",
  voice: "alloy",
});

const buffer = Buffer.from(await response.arrayBuffer());
await fs.promises.writeFile("welcome.wav", buffer);

Choosing a Voice

OpenAI-compatible voices

Use familiar voice names if you're migrating from OpenAI:

VoiceMaps to
alloyEnglish, neutral
echoEnglish, news anchor
fableEnglish, gentle
onyxEnglish, academic
novaChinese, neutral
shimmerChinese, soft

Language-specific voices

Voices are named by language and style, e.g. zh-gentle, en-news, ja-news.

Chinese gentle voice
curl -X POST https://api.leaper.one/v1/audio/speech \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"input": "晚安,祝你做个好梦。", "voice": "zh-gentle"}' \
  --output goodnight.wav
Japanese news voice
curl -X POST https://api.leaper.one/v1/audio/speech \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"input": "本日のニュースをお伝えします。", "voice": "ja-news"}' \
  --output news_ja.wav

See the API Reference for the full list of available voices.

Voice Cloning

Upload a short audio sample to clone any voice. This requires multipart/form-data instead of JSON.

Clone a voice
curl -X POST https://api.leaper.one/v1/audio/speech \
  -H "Authorization: Bearer sk-your-api-key" \
  -F input="This sentence will be spoken in the cloned voice." \
  -F prompt_audio=@my-voice-sample.mp3 \
  --output cloned.wav

Tips for good voice cloning:

  • Use a clear speech recording, 5-15 seconds long
  • Minimize background noise
  • Audio file must be under 1MB (mp3, wav, flac, m4a, ogg)
  • Voice cloning runs on CPU and takes 20-60 seconds

Voice cloning is not supported via the OpenAI SDK because it requires file upload alongside text parameters. Use curl or a direct HTTP request.

Output Formats

FormatUse case
wav (default)Ready-to-play audio file
pcmRaw audio for further processing (48kHz, 16-bit, stereo)
Get PCM output
curl -X POST https://api.leaper.one/v1/audio/speech \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"input": "Raw PCM output.", "voice": "alloy", "response_format": "pcm"}' \
  --output raw.pcm

Billing is based on character count. See the API Reference for pricing details.