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. 1

    Create an account

    Sign up for a free account to get started.

  2. 2

    Generate an API key

    Create an API key from your dashboard.

  3. 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.

POST
/tts/generate

Generate speech from text

Request Body

ParameterTypeRequiredDescription
textstringYesThe text to convert to speech (max 5000 chars)
voicestringYesVoice ID (e.g., "heart", "michael")
languagestringYesLanguage code (e.g., "american_english")
speedfloatNoSpeech 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 seconds
  • X-Generation-Time - Time taken to generate in seconds
  • X-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.

American Englishvoice: heartlang: american_english
{
  "text": "Hello from LangVoice. Let's build something amazing today.",
  "voice": "heart",
  "language": "american_english",
  "speed": 1
}
British Englishvoice: emmalang: british_english
{
  "text": "Good afternoon from LangVoice. Natural UK English in seconds.",
  "voice": "emma",
  "language": "british_english",
  "speed": 0.95
}
Spanishvoice: bellalang: spanish
{
  "text": "Hola, bienvenido a LangVoice. Generemos audio natural en segundos.",
  "voice": "bella",
  "language": "spanish",
  "speed": 1
}
Frenchvoice: georgelang: french
{
  "text": "Bonjour, ceci est LangVoice. La synthese vocale est simple et rapide.",
  "voice": "george",
  "language": "french",
  "speed": 1
}
Hindi (romanized)voice: michaellang: hindi
{
  "text": "Namaste, yeh LangVoice hai. Hum prakritik awaaz bana rahe hain.",
  "voice": "michael",
  "language": "hindi",
  "speed": 0.9
}
Japanese (romanized)voice: alicelang: japanese
{
  "text": "Konnichiwa, LangVoice desu. Kirei na onsei o tsukurimasu.",
  "voice": "alice",
  "language": "japanese",
  "speed": 1
}
Italianvoice: nicolelang: italian
{
  "text": "Ciao, benvenuto su LangVoice. Generiamo audio naturale in pochi secondi.",
  "voice": "nicole",
  "language": "italian",
  "speed": 1
}
Brazilian Portuguesevoice: riverlang: brazilian_portuguese
{
  "text": "Ola, bem-vindo ao LangVoice. Vamos criar audio natural em segundos.",
  "voice": "river",
  "language": "brazilian_portuguese",
  "speed": 1
}
Mandarin Chinese (pinyin)voice: novalang: mandarin_chinese
{
  "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.

GET
/tts/voices

List all available voices

GET
/tts/languages

List all supported languages

Available Voices

American English
heartbellanicoleaoedekoresarahnovaskyalloyjessicarivermichaelfenrirpuckechoericliamonyxadam
British English
emmaisabellaalicelilygeorgefablelewisdaniel

Supported Languages

American English

american_english

EN-USvoice: heart

British English

british_english

EN-UKvoice: emma

Spanish

spanish

ESvoice: bella

French

french

FRvoice: george

Hindi (romanized)

hindi

HIvoice: michael

Italian

italian

ITvoice: nicole

Japanese (romanized)

japanese

JAvoice: alice

Brazilian Portuguese

brazilian_portuguese

PT-BRvoice: river

Mandarin Chinese (pinyin)

mandarin_chinese

ZHvoice: nova

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.

POST
/tts/multi-voice-text

Generate 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 allowed
  • X-RateLimit-Remaining - Requests remaining in current window
  • X-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 CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
429Too Many Requests - Rate limit exceeded
500Internal 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.