API v1.0 is now available! Check out the new voice cloning features.
SpeechgenSpeechgen

Quick Start

Get up and running with the Speechgen API in under 5 minutes

Quick Start Guide

Get started with the Speechgen API in just a few steps.

Get your API key

Sign up for a Speechgen account and navigate to your Dashboard to generate your API key.

Make your first request

Use the code examples below to convert text to speech.

Handle the response

Receive audio data in your preferred format (MP3, WAV, OGG).

Your First API Call

Here's a simple example to convert text to speech:

cURL

curl -X POST https://api.speechgen.com/v1/text-to-speech \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, welcome to Speechgen!",
    "voice": "en-US-Neural2-A",
    "format": "mp3"
  }'

JavaScript

const response = await fetch("https://api.speechgen.com/v1/text-to-speech", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    text: "Hello, welcome to Speechgen!",
    voice: "en-US-Neural2-A",
    format: "mp3",
  }),
});

const audioBlob = await response.blob();

Python

import requests

response = requests.post(
    'https://api.speechgen.com/v1/text-to-speech',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        'text': 'Hello, welcome to Speechgen!',
        'voice': 'en-US-Neural2-A',
        'format': 'mp3',
    }
)

audio_content = response.content

Remember to replace YOUR_API_KEY with your actual API key from the dashboard.

Here's a recommended structure for integrating Speechgen into your project:

speechgen.ts
.env.local
package.json
  • lib/speechgen.ts - Your Speechgen API client wrapper
  • app/api/tts/route.ts - Server-side API route to proxy requests
  • .env.local - Store your SPEECHGEN_API_KEY here

Next Steps