MiniMaxi text-to-speech
curl --request POST \
--url https://xuwuai.com/minimaxi/v1/t2a_v2 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://xuwuai.com/minimaxi/v1/t2a_v2"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://xuwuai.com/minimaxi/v1/t2a_v2', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://xuwuai.com/minimaxi/v1/t2a_v2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xuwuai.com/minimaxi/v1/t2a_v2"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://xuwuai.com/minimaxi/v1/t2a_v2")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://xuwuai.com/minimaxi/v1/t2a_v2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{}语音合成
语音合成(TTS)
同步 t2a_v2、异步 t2a_async_v2 与查询
POST
/
minimaxi
/
v1
/
t2a_v2
MiniMaxi text-to-speech
curl --request POST \
--url https://xuwuai.com/minimaxi/v1/t2a_v2 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://xuwuai.com/minimaxi/v1/t2a_v2"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://xuwuai.com/minimaxi/v1/t2a_v2', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://xuwuai.com/minimaxi/v1/t2a_v2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xuwuai.com/minimaxi/v1/t2a_v2"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://xuwuai.com/minimaxi/v1/t2a_v2")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://xuwuai.com/minimaxi/v1/t2a_v2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{}概述
- 同步:
POST /minimaxi/v1/t2a_v2 - 异步:
POST /minimaxi/v1/t2a_async_v2+GET /minimaxi/v1/query/t2a_async_query_v2
- 同步合成
- 异步合成与查询
curl -X POST "https://xuwuai.com/minimaxi/v1/t2a_v2" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"model":"speech-2.8-hd","text":"欢迎使用 Xuwu","output_format":"hex"}' \
--output minimaxi-tts.mp3
curl -X POST "https://xuwuai.com/minimaxi/v1/t2a_async_v2" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"model":"speech-2.8-hd","text":"hello"}'
curl "https://xuwuai.com/minimaxi/v1/query/t2a_async_query_v2?task_id=$TASK_ID" \
-H "Authorization: Bearer $TOKEN"
音色别名与情感(voice alias)
-
为了与 OpenAI 风格保持一致,Xuwu 为常见音色提供别名到 MiniMax 实际音色的映射:
alloy→female-chengshu(女声-成熟)echo→male-qn-qingse(男声-青年-清色)fable→male-qn-jingying(男声-青年-精英)onyx→presenter_malenova→presenter_femaleshimmer→audiobook_female_1
-
如果你在请求体中填写
voice_id为上述别名,Xuwu 会自动转换为 MiniMax 要求的voice_id;当该音色存在默认情感时,会在未显式指定emotion时自动补全。
{
"voice": {
"alloy": "female-chengshu|sad",
"echo": "male-qn-qingse"
}
}
返回格式(audio_mode)
- 通过渠道自定义参数可设置音频返回模式:
audio_mode = json(默认):响应体以 JSON 返回,data.audio为 hex 或 URL(由output_format决定)。audio_mode = hex:当output_format=hex时返回裸音频流;当output_format=url时仍返回 JSON。
{
"audio_mode": "hex"
}
异步合成任务(t2a_async_v2)在返回 JSON 载荷中会原样保留你的
voice_id 与参数;若你使用了别名,Xuwu 会在上游请求前进行一次转换与情感补全。关键参数对齐(官方)
output_format: 仅非流式生效,取值hex(默认)或url。url有效期以官方返回为准。emotion:happy/sad/angry/fearful/disgusted/surprised/calm/fluent/whisper。该能力受模型与音色组合限制,并非所有voice_id都支持;例如speech-2.6-hd+male-qn-qingse不建议配置默认happy。sound_effects:spacious_echo/auditorium_echo/lofi_telephone/robotic
Authorizations
Authorization: Bearer
Body
application/json
The body is of type object.
Response
200 - application/json
OK
The response is of type object.