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
| Model | Pricing | Best for |
|---|---|---|
moss-tts-nano | 0.005 credits / 1K chars | Multilingual speech with voice cloning |
Quick Start
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.wavThe 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:
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")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:
| Voice | Maps to |
|---|---|
alloy | English, neutral |
echo | English, news anchor |
fable | English, gentle |
onyx | English, academic |
nova | Chinese, neutral |
shimmer | Chinese, soft |
Language-specific voices
Voices are named by language and style, e.g. zh-gentle, en-news, ja-news.
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.wavcurl -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.wavSee 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.
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.wavTips 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
| Format | Use case |
|---|---|
wav (default) | Ready-to-play audio file |
pcm | Raw audio for further processing (48kHz, 16-bit, stereo) |
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.pcmBilling is based on character count. See the API Reference for pricing details.
Audio Transcription Guide
Learn how to transcribe audio with LEAPERone by uploading files or passing file URLs, language hints, and response formats.
Video Extract Guide
Learn how to extract video metadata from social media share links, authenticate requests, handle responses, and track fixed-price usage.