Skip to main content
POST
/
v1
/
audio
/
speech
Text to Speech
curl --request POST \
  --url https://api.neospeech.io/v1/audio/speech \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "input": "<string>",
  "voice": "<string>",
  "model": "<string>",
  "pitch": "<string>",
  "style": "<string>",
  "styleDegree": "<string>",
  "lang": "<string>"
}
'
Generate high-quality audio from text using our neural TTS models. This endpoint returns a complete MP3 file after processing your text.

Request

Here’s the simplest way to generate speech:
curl -X POST "https://api.neospeech.io/v1/audio/speech" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Hello, welcome to NeoSpeech",
    "voice": "lyra",
    "model": "aurora-4"
  }' \
  --output speech.mp3

Parameters

Authorization
string
required
Bearer token: Bearer sk-your-api-key
input
string
required
The text to convert to speech (max 5,000 characters)
voice
string
required
Voice identifier like lyra, kai, or zara. See all voices
model
string
required
Audio model: aurora-4 (premium), aurora-3.5 (high quality), turbo-3 (fast), or mini-2 (lightweight)
pitch
string
Adjust voice pitch from -50% to +50%. Default: +0%
style
string
Speech emotion: calm, excited, cheerful, or sad. Default: calm
styleDegree
string
Style intensity from 0.5 to 2.0. Default: 1.5
lang
string
Language code like en-US, en-GB, fr-FR. Default: en-US

Response

Returns binary MP3 audio data with these headers:
Content-Type: audio/mpeg
X-Character-Count: 28
X-Model-Used: aurora-4
X-Voice-Used: Lyra

Common patterns

Save to file

const response = await fetch('https://api.neospeech.io/v1/audio/speech', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.NEOSPEECH_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    input: 'Your text here',
    voice: 'lyra',
    model: 'aurora-4'
  })
});

const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('output.mp3', buffer);

Add emotion

const response = await fetch('https://api.neospeech.io/v1/audio/speech', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    input: 'This is exciting news!',
    voice: 'kai',
    model: 'aurora-4',
    style: 'excited',
    styleDegree: '1.8'
  })
});

Handle errors

try {
  const response = await fetch('https://api.neospeech.io/v1/audio/speech', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${apiKey}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ input, voice, model })
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.message);
  }

  return await response.blob();
} catch (error) {
  console.error('Speech generation failed:', error.message);
  throw error;
}