Create text-to-speech audio
Table of contents
December 23, 2024
Please configure at least one www.hailuo.ai account for this endpoint, see Setup MiniMax for details.
This endpoint creates an mp3 audio from the provided text in under 20 seconds.
- Up to 20 parallel jobs per account are supported.
- Currently, this service is offered free of charge.
https://api.useapi.net/v1/minimax/audio/create-mp3
Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Alternatively you can use multipart/form-data
# Content-Type: multipart/form-data
API token
is required, see Setup useapi.net for details.
Request Body
{
"account": "Optional MiniMax www.hailuo.ai API account",
"text": "Required text",
"voice_id": "Required voice id"
}
-
account
is optional when only onewww.hailuo.ai
account configured. However, if you have multiple accounts configured, this parameter becomes required. -
text
is required. Insert<#0.5#>
to add a 0.5s pause between sentences. Adjust the duration as needed.
Maximum length: 1000 characters. -
voice_id
is required. Use GET audio/voices to get list of all available voices. -
language_boost
is optional. Use tag_name from arrayvoice_tag_language
of GET audio/config.
Default valueAuto
. -
emotion
is optional. Use value from arrayt2a_emotion
of GET audio/config.
Default valueAuto
. -
vol
is optional.
Default 1. -
speed
is optional.
Valid range: 0.5…2, default 1. -
pitch
is optional.
Valid range: -12…12, default 0. -
deepen_lighten
is optional.
Valid range: -100…100, default 0. -
stronger_softer
is optional.
Valid range: -100…100, default 0. -
nasal_crisp
is optional.
Valid range: -100…100, default 0. -
spacious_echo
is optional.
Supported values:true
,false
(default). -
lofi_telephone
is optional.
Supported values:true
,false
(default). -
robotic
is optional.
Supported values:true
,false
(default). -
auditorium_echo
is optional.
Supported values:true
,false
(default).
Responses
-
Use returned
audio_url
to download generated mp3 audio file.
Use returnedaudio_id
to retrieve full details using GET audio/audio_id
.{ "audio_id": "user:user_id-minimax:account_id-audio:audio_id", "audio_length": 0, "audio_sample_rate": 32000, "audio_size": 1234567, "bitrate": 128000, "word_count": 0, "invisible_character_ratio": 0, "usage_characters": 1000, "audio_format": "mp3", "audio_channel": 1, "input_sensitive": false, "trace_id": "<trace id>", "chunks": 5123, "audio_review": 0, "user_id": 11223344556677, "audio_title": "<autogenerated title>", "audio_url": "https://cdn.hailuoai.video/...mp3", "update_time": 123456789 }
-
{ "error": "<Error message>" }
-
{ "error": "Unauthorized" }
-
Wait in a loop for at least 5..10 seconds and retry again. If you receive this message frequently, you may want to consider adding more accounts to spread the load.
Model
{ // TypeScript, all fields are optional
audio_id: string
audio_length: number
audio_sample_rate: number
audio_size: number
bitrate: number
word_count: number
invisible_character_ratio: number
usage_characters: number
audio_format: string
audio_channel: number
input_sensitive: boolean
trace_id: string
chunks: number
audio_review: number
user_id: number
audio_title: string
audio_url: string
update_time: number
error: string
}
Examples
-
curl -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer …" \ -X POST "https://api.useapi.net/v1/minimax/audio/create-mp3" \ -d '{"text": "…", "voice_id": "…"}'
-
const text = "text"; const voice_id = "voice_id"; const apiUrl = `https://api.useapi.net/v1/minimax/audio/create-mp3`; const token = "API token"; const data = { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' } }; data.body = JSON.stringify({ text, voice_id }); const response = await fetch(apiUrl, data); const result = await response.json(); console.log("response", {response, result});
-
import requests text = "text" voice_id = "voice_id" apiUrl = f"https://api.useapi.net/v1/minimax/audio/create-mp3" token = "API token" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } body = { "text": f"{text}", "voice_id": f"{voice_id}" } response = requests.post(apiUrl, headers=headers, json=body) print(response, response.json())