LangVoice API Documentation
Welcome to the LangVoice API documentation. Learn how to integrate our powerful text-to-speech capabilities into your applications.
Quick Start
- 1
Create an account
Sign up for a free account to get started.
- 2
Generate an API key
Create an API key from your dashboard.
- 3
Make your first request
Use the API to generate speech from text.
Using X-API-Key Header (Recommended)
Include your API key in the X-API-Key header with every request.
curl -X POST "https://api.langvoice.com/api/v1/tts/generate" \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"text": "Hello world", "voice": "heart", "language": "american_english"}'Generate Speech
Convert text to natural-sounding speech with a single API call.
/tts/generateGenerate speech from text
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The text to convert to speech (max 5000 chars) |
voice | string | Yes | Voice ID (e.g., "heart", "michael") |
language | string | Yes | Language code (e.g., "american_english") |
speed | float | No | Speech speed (0.5-2.0, default: 1.0) |
Example Request
{
"text": "Hello, welcome to LangVoice! This is a demonstration of our text-to-speech API.",
"voice": "heart",
"language": "american_english",
"speed": 1.0
}Response
Returns an audio file (MP3) with the following headers:
X-Audio-Duration- Duration of the audio in secondsX-Generation-Time- Time taken to generate in secondsX-Characters-Processed- Number of characters processed
Language Examples
Copy-paste payloads for the most popular languages. Use with either X-API-Key or Bearer tokens.
{
"text": "Hello from LangVoice. Let's build something amazing today.",
"voice": "heart",
"language": "american_english",
"speed": 1
}{
"text": "Good afternoon from LangVoice. Natural UK English in seconds.",
"voice": "emma",
"language": "british_english",
"speed": 0.95
}{
"text": "Hola, bienvenido a LangVoice. Generemos audio natural en segundos.",
"voice": "bella",
"language": "spanish",
"speed": 1
}{
"text": "Bonjour, ceci est LangVoice. La synthese vocale est simple et rapide.",
"voice": "george",
"language": "french",
"speed": 1
}{
"text": "Namaste, yeh LangVoice hai. Hum prakritik awaaz bana rahe hain.",
"voice": "michael",
"language": "hindi",
"speed": 0.9
}{
"text": "Konnichiwa, LangVoice desu. Kirei na onsei o tsukurimasu.",
"voice": "alice",
"language": "japanese",
"speed": 1
}{
"text": "Ciao, benvenuto su LangVoice. Generiamo audio naturale in pochi secondi.",
"voice": "nicole",
"language": "italian",
"speed": 1
}{
"text": "Ola, bem-vindo ao LangVoice. Vamos criar audio natural em segundos.",
"voice": "river",
"language": "brazilian_portuguese",
"speed": 1
}{
"text": "Ni hao, zheli shi LangVoice. Women keyi kuaisu shengcheng qingchu de shengyin.",
"voice": "nova",
"language": "mandarin_chinese",
"speed": 1
}Voices & Languages
Get available voices and supported languages.
/tts/voicesList all available voices
/tts/languagesList all supported languages
Available Voices
American English
British English
Supported Languages
American English
american_english
British English
british_english
Spanish
spanish
French
french
Hindi (romanized)
hindi
Italian
italian
Japanese (romanized)
japanese
Brazilian Portuguese
brazilian_portuguese
Mandarin Chinese (pinyin)
mandarin_chinese
Multi-Voice Script
Write one script and swap speakers inline with bracketed voice markers. The API keeps ordering and merges everything into a single audio file.
/tts/multi-voice-textGenerate speech with multiple voices using bracketed markers
Dialogue Example
{
"language": "american_english",
"text": "[heart] Welcome to LangVoice. [michael] Hi! I can help you get set up. [heart] Pick any voice and start building."
}IVR Menu Example
{
"language": "american_english",
"text": "[bella] Thanks for calling LangVoice support. [liam] Press 1 for product help, press 2 for billing. [bella] Stay on the line to talk with an agent."
}Rate Limits
Rate limits vary based on your account tier.
Free Tier
- - 20 requests per minute
- - 100 requests per hour
- - 500 requests per day
- - 50,000 characters per day
- - Max 5,000 characters per request
Enterprise Tier
- - 1,000 requests per minute
- - 10,000 requests per hour
- - 100,000 requests per day
- - 5,000,000 characters per day
- - Max 10,000 characters per request
- - Priority processing
Rate Limit Headers
Every API response includes rate limit information in the headers:
X-RateLimit-Limit- Maximum requests allowedX-RateLimit-Remaining- Requests remaining in current windowX-RateLimit-Reset- Unix timestamp when the limit resets
Code Examples
Get started quickly with these code examples in popular programming languages.
Python Example
import requests
API_KEY = "your_api_key_here"
BASE_URL = "https://api.langvoice.com/api/v1"
def generate_speech(text: str, voice: str = "heart", language: str = "american_english", speed: float = 1.0):
"""Generate speech from text using the LangVoice API."""
response = requests.post(
f"{BASE_URL}/tts/generate",
headers={
"X-API-Key": API_KEY,
"Content-Type": "application/json"
},
json={
"text": text,
"voice": voice,
"language": language,
"speed": speed
}
)
if response.status_code == 200:
# Save the audio file
with open("output.mp3", "wb") as f:
f.write(response.content)
# Get generation info from headers
duration = response.headers.get("X-Audio-Duration")
gen_time = response.headers.get("X-Generation-Time")
print(f"Audio duration: {duration}s, Generated in: {gen_time}s")
return True
else:
print(f"Error: {response.json()}")
return False
# Usage
generate_speech(
text="Hello, welcome to LangVoice! This is a test of the text-to-speech API.",
voice="heart",
language="american_english",
speed=1.0
)Error Handling
The API returns standard HTTP status codes and JSON error responses:
| Status Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid or missing API key |
| 403 | Forbidden - Insufficient permissions |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error |
Error Response Format:
{
"detail": "Error message describing what went wrong",
"error_code": "RATE_LIMIT_EXCEEDED",
"timestamp": "2024-01-15T10:30:00Z"
}Official SDKs
We provide official SDKs for popular programming languages:
Need Help?
Our support team is here to help you integrate LangVoice into your application.