Text-to-Speech API
Generate high-quality audio from text using Audian's text-to-speech service. Support for multiple languages and voice options.
Endpoint​
POST https://api.audian.com:8443/v2/media/text-to-speech
Request​
Headers​
Content-Type: application/json
X-Auth-Token: YOUR_API_KEY
Parameters​
| Parameter | Type | Required | Description |
|---|---|---|---|
text | String | Yes | Text to convert to speech (max 5000 characters) |
voice | String | No | Voice ID (default: en-US-neural-1) |
language | String | No | Language code (default: en-US) |
speed | Number | No | Speech speed (0.5 - 2.0, default: 1.0) |
pitch | Number | No | Voice pitch (-20 to 20, default: 0) |
name | String | No | Name for the generated media file |
Available Voices​
English (US)​
en-US-neural-1- Standard male voiceen-US-neural-2- Standard female voiceen-US-neural-3- Professional male voiceen-US-neural-4- Friendly female voice
English (UK)​
en-GB-neural-1- Standard male voiceen-GB-neural-2- Standard female voice
Spanish​
es-ES-neural-1- Standard male voicees-ES-neural-2- Standard female voice
French​
fr-FR-neural-1- Standard male voicefr-FR-neural-2- Standard female voice
German​
de-DE-neural-1- Standard male voicede-DE-neural-2- Standard female voice
Examples​
Basic Text-to-Speech​
curl -X POST https://api.audian.com:8443/v2/media/text-to-speech \
-H "X-Auth-Token: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Thank you for calling. Your call is important to us.",
"voice": "en-US-neural-2",
"language": "en-US",
"name": "ivr-greeting"
}'
JavaScript/Node.js​
const axios = require('axios');
const generateSpeech = async () => {
try {
const response = await axios.post(
'https://api.audian.com:8443/v2/media/text-to-speech',
{
text: 'Thank you for calling. Your call is important to us.',
voice: 'en-US-neural-2',
language: 'en-US',
speed: 1.0,
pitch: 0,
name: 'ivr-greeting'
},
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
}
);
console.log('Speech generated:', response.data);
} catch (error) {
console.error('Generation failed:', error);
}
};
generateSpeech();
Python​
import requests
import json
def generate_speech(api_key, text, voice='en-US-neural-2',
language='en-US', speed=1.0, pitch=0, name=None):
url = 'https://api.audian.com:8443/v2/media/text-to-speech'
headers = {
'X-Auth-Token': api_key,
'Content-Type': 'application/json'
}
payload = {
'text': text,
'voice': voice,
'language': language,
'speed': speed,
'pitch': pitch
}
if name:
payload['name'] = name
response = requests.post(url, headers=headers, json=payload)
return response.json()
# Usage
result = generate_speech(
api_key='YOUR_API_KEY',
text='Thank you for calling. Your call is important to us.',
voice='en-US-neural-2',
name='ivr-greeting'
)
print(result)
Advanced with Speed and Pitch​
curl -X POST https://api.audian.com:8443/v2/media/text-to-speech \
-H "X-Auth-Token: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Press 1 for sales, 2 for support, or 3 for billing",
"voice": "en-US-neural-1",
"language": "en-US",
"speed": 1.1,
"pitch": 2,
"name": "ivr-menu-options"
}'
Response​
Success (200)​
{
"id": "media_tts_abc123",
"name": "ivr-greeting",
"text": "Thank you for calling. Your call is important to us.",
"voice": "en-US-neural-2",
"language": "en-US",
"speed": 1.0,
"pitch": 0,
"url": "https://api.audian.com:8443/v2/media/media_tts_abc123",
"duration": 3.2,
"format": "wav",
"size": 51200,
"created_at": "2024-02-04T10:35:00Z"
}
Error (400)​
{
"error": "invalid_voice",
"message": "The specified voice does not exist"
}
Parameters Guide​
Speed​
- Range: 0.5 to 2.0
- Default: 1.0
- 0.5: Half speed (slower speech)
- 1.0: Normal speed
- 2.0: Double speed (faster speech)
Pitch​
- Range: -20 to 20
- Default: 0
- Negative values: Lower pitch (deeper voice)
- Positive values: Higher pitch (lighter voice)
Use Cases​
Interactive Voice Response (IVR)​
Generate dynamic menu prompts and information messages.
const menuText = `Press 1 for sales, 2 for support, or 3 for billing`;
// Generate and use in IVR system
Voicemail Greetings​
Create professional voicemail prompts in multiple languages.
const greetingText = `You have reached our office. We are currently closed.`;
// Generate and assign to voicemail box
Notifications​
Generate alert and notification messages.
const notificationText = `Your appointment reminder: You have a meeting today at 2 PM`;
// Generate and play to caller
Caching and Performance​
Generated speech files are cached and reused when identical requests are made. This improves performance and reduces processing time for commonly used prompts.
Limits and Quotas​
- Text limit: 5000 characters per request
- API calls: See your plan for TTS generation limits
- File retention: Generated files retained for 90 days
- Concurrent requests: Up to 10 concurrent TTS generations per API key