Quick Start

Get up and running with TTS in under 5 minutes.

Prerequisites

  • A YourVoic account with API access
  • Your API key from the dashboard
  • Python, Node.js, or cURL installed

Step 1: Authentication

Include your API key in the X-API-Key header with every request:

X-API-Key: your_api_key_here

Step 2: Generate Speech

Python

import requests

response = requests.post(
    "https://yourvoic.com/api/v1/tts/generate",
    headers={"X-API-Key": "your_api_key"},
    json={
        "text": "Hello! This is a test of the text-to-speech API.",
        "voice": "Peter",
        "language": "en-US"
    }
)

if response.status_code == 200:
    with open("output.mp3", "wb") as f:
        f.write(response.content)
    print("Audio saved to output.mp3")
else:
    print(f"Error: {response.json()}")

JavaScript (Node.js)

const fs = require('fs');

async function generateSpeech() {
    const response = await fetch('https://yourvoic.com/api/v1/tts/generate', {
        method: 'POST',
        headers: {
            'X-API-Key': 'your_api_key',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            text: 'Hello! This is a test of the text-to-speech API.',
            voice: 'Peter',
            language: 'en-US'
        })
    });

    if (response.ok) {
        const buffer = await response.arrayBuffer();
        fs.writeFileSync('output.mp3', Buffer.from(buffer));
        console.log('Audio saved to output.mp3');
    } else {
        console.error('Error:', await response.json());
    }
}

generateSpeech();

cURL

curl -X POST "https://yourvoic.com/api/v1/tts/generate" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello! This is a test of the text-to-speech API.",
    "voice": "Peter",
    "language": "en-US"
  }' \
  --output output.mp3

Step 3: Customize Your Audio

Change the Model

# Use premium quality model
response = requests.post(
    "https://yourvoic.com/api/v1/tts/generate",
    headers={"X-API-Key": "your_api_key"},
    json={
        "text": "Premium quality audio for professional content.",
        "voice": "Peter",
        "language": "en-US",
        "model": "aura-max"  # Premium quality
    }
)

Adjust Speed and Pitch

# Faster speech with higher pitch
response = requests.post(
    "https://yourvoic.com/api/v1/tts/generate",
    headers={"X-API-Key": "your_api_key"},
    json={
        "text": "This will be spoken faster with higher pitch.",
        "voice": "Peter",
        "language": "en-US",
        "speed": 1.25,  # 25% faster
        "pitch": 1.1    # 10% higher pitch
    }
)

Different Output Format

# Get WAV format instead of MP3
response = requests.post(
    "https://yourvoic.com/api/v1/tts/generate",
    headers={"X-API-Key": "your_api_key"},
    json={
        "text": "This will be saved as a WAV file.",
        "voice": "Peter",
        "language": "en-US",
        "output_format": "wav"
    }
)

with open("output.wav", "wb") as f:
    f.write(response.content)

Common Use Cases

Use CaseRecommended ModelSettings
Chatbot/Assistantaura-liteDefault speed, MP3
Audiobooksaura-maxSpeed 0.9, MP3 320kbps
IVR Systemrapid-flashDefault, WAV
E-learningaura-primeSpeed 0.95, clear voice
Video Narrationaura-maxWAV for editing