Speech Synthesis (Text to Audio)
High-quality speech synthesis interface supporting multiple voice tones, speed adjustment, and emotional expression. Suitable for audiobooks, voice assistants, and more.
API Endpoints
POST
/t2a_v2Text to speech
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Required | Model name: speech-2.6-hd or speech-2.6-turbo |
text | string | Required | Text content to synthesize |
voice_id | string | Optional | Voice ID, use preset or cloned voice |
speed | number | Optional | Speech rate, range 0.5-2.0, default 1.0 |
pitch | number | Optional | Pitch, range -12 to 12 |
audio_format | string | Optional | Output format: mp3, wav, pcm |
Request Example
Request Example
{
"model": "speech-2.6-hd",
"text": "你好,欢迎使用 MiniMax 语音合成服务。",
"voice_id": "female-tianmei",
"speed": 1.0,
"audio_format": "mp3"
}Response Example
Response Example
{
"audio": "base64_encoded_audio_data...",
"status": "success",
"usage": {
"characters": 18
}
}Code Examples
import requests
import base64
url = "https://your-proxy-domain.com/v1/t2a_v2"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "speech-2.6-hd",
"text": "你好,欢迎使用 MiniMax 语音合成服务。",
"voice_id": "female-tianmei",
"speed": 1.0,
"audio_format": "mp3"
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
# 保存音频文件
audio_data = base64.b64decode(result["audio"])
with open("output.mp3", "wb") as f:
f.write(audio_data)