Eleven v4 Speech / Custom Voice
curl --request POST \
--url https://api.aihubmax.com/e/v1/audios/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "eleven-v4-text-to-speech",
"text": "欢迎收听。",
"voice_id": "existing-voice-id"
}
'import requests
url = "https://api.aihubmax.com/e/v1/audios/generations"
payload = {
"model": "eleven-v4-text-to-speech",
"text": "欢迎收听。",
"voice_id": "existing-voice-id"
}
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({
model: 'eleven-v4-text-to-speech',
text: '欢迎收听。',
voice_id: 'existing-voice-id'
})
};
fetch('https://api.aihubmax.com/e/v1/audios/generations', 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://api.aihubmax.com/e/v1/audios/generations",
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([
'model' => 'eleven-v4-text-to-speech',
'text' => '欢迎收听。',
'voice_id' => 'existing-voice-id'
]),
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://api.aihubmax.com/e/v1/audios/generations"
payload := strings.NewReader("{\n \"model\": \"eleven-v4-text-to-speech\",\n \"text\": \"欢迎收听。\",\n \"voice_id\": \"existing-voice-id\"\n}")
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://api.aihubmax.com/e/v1/audios/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"eleven-v4-text-to-speech\",\n \"text\": \"欢迎收听。\",\n \"voice_id\": \"existing-voice-id\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aihubmax.com/e/v1/audios/generations")
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 = "{\n \"model\": \"eleven-v4-text-to-speech\",\n \"text\": \"欢迎收听。\",\n \"voice_id\": \"existing-voice-id\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1757165031,
"id": "task-unified-1757165031-uyujaw3d",
"model": "<string>",
"object": "audio.generation.task",
"progress": 0,
"status": "pending",
"task_info": {
"can_cancel": true,
"estimated_time": 45
},
"type": "audio"
}{
"error": {
"message": "请求格式错误",
"type": "invalid_request_error"
}
}{
"error": {
"message": "API密钥无效",
"type": "authentication_error"
}
}{
"error": {
"message": "账户余额不足",
"type": "insufficient_quota"
}
}{
"error": {
"message": "参数校验失败",
"type": "validation_error"
}
}{
"error": {
"message": "请求频率超限",
"type": "rate_limit_error"
}
}{
"error": {
"message": "服务器内部错误",
"type": "server_error"
}
}{
"error": {
"message": "服务暂不可用,请稍后重试",
"type": "service_unavailable"
}
}语音合成
Eleven v4 单段语音合成
- 单段文本与指定已有音色合成语音
- text 与 voice_id 必填,文本最多10000字符
- 可选嵌套音色设置、前后文与音效
- 异步处理模式,使用返回的任务ID 进行查询
- 完成后从
results[0].url下载音频;timestamps 请求仅在完整功能可用时受理,结果保留实际返回的对齐和说话人区间,不补造缺失字段。请及时下载,链接保留时间取决于文件存储服务。
POST
/
v1
/
audios
/
generations
Eleven v4 Speech / Custom Voice
curl --request POST \
--url https://api.aihubmax.com/e/v1/audios/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "eleven-v4-text-to-speech",
"text": "欢迎收听。",
"voice_id": "existing-voice-id"
}
'import requests
url = "https://api.aihubmax.com/e/v1/audios/generations"
payload = {
"model": "eleven-v4-text-to-speech",
"text": "欢迎收听。",
"voice_id": "existing-voice-id"
}
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({
model: 'eleven-v4-text-to-speech',
text: '欢迎收听。',
voice_id: 'existing-voice-id'
})
};
fetch('https://api.aihubmax.com/e/v1/audios/generations', 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://api.aihubmax.com/e/v1/audios/generations",
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([
'model' => 'eleven-v4-text-to-speech',
'text' => '欢迎收听。',
'voice_id' => 'existing-voice-id'
]),
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://api.aihubmax.com/e/v1/audios/generations"
payload := strings.NewReader("{\n \"model\": \"eleven-v4-text-to-speech\",\n \"text\": \"欢迎收听。\",\n \"voice_id\": \"existing-voice-id\"\n}")
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://api.aihubmax.com/e/v1/audios/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"eleven-v4-text-to-speech\",\n \"text\": \"欢迎收听。\",\n \"voice_id\": \"existing-voice-id\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aihubmax.com/e/v1/audios/generations")
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 = "{\n \"model\": \"eleven-v4-text-to-speech\",\n \"text\": \"欢迎收听。\",\n \"voice_id\": \"existing-voice-id\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1757165031,
"id": "task-unified-1757165031-uyujaw3d",
"model": "<string>",
"object": "audio.generation.task",
"progress": 0,
"status": "pending",
"task_info": {
"can_cancel": true,
"estimated_time": 45
},
"type": "audio"
}{
"error": {
"message": "请求格式错误",
"type": "invalid_request_error"
}
}{
"error": {
"message": "API密钥无效",
"type": "authentication_error"
}
}{
"error": {
"message": "账户余额不足",
"type": "insufficient_quota"
}
}{
"error": {
"message": "参数校验失败",
"type": "validation_error"
}
}{
"error": {
"message": "请求频率超限",
"type": "rate_limit_error"
}
}{
"error": {
"message": "服务器内部错误",
"type": "server_error"
}
}{
"error": {
"message": "服务暂不可用,请稍后重试",
"type": "service_unavailable"
}
}eleven-v4-text-to-speech 与 eleven-v4-text-to-speech-custom-voice 均要求 text 和 voice_id,无默认音色。文本支持 1–10000 个 Unicode 字符,包含空格、标点、emoji 和音频标签。Speech 不接受 inputs;分段多音色使用 Dialogue。
直接传已有音色的原始 ID。custom 支持私有音色,也允许公共音色;普通入口也可使用可访问的私有音色。音色必须仍有效并允许访问,ID 不代表永久可用或本系统用户独享;其他取得有效 ID 且有模型权限的调用者也可能使用。不可用时任务失败,按实际退款结果提示。音色目录仅用于发现和试听。
可选 voice_settings 内的 stability 默认 0.5、similarity_boost 默认 0.75,clone_strength 可选,均为 0–1。整个对象省略/null 时不强制覆盖已保存的音色设置;传对象时使用其字段默认值。clone_strength 仅适用于对应 v4 专业克隆音色,不创建声音。v4 不承诺 style、speed 或 SSML。
previous_text / next_text 提供前后文,不朗读、不计费。seed 为 0–4294967295,language_code 可选,apply_text_normalization 为 auto/on/off,默认 auto。audio_effects 可包含滤镜、混响、背景音目录 ID;distance 为 0–1(默认0)、send_level 为 0–1(默认1)、pan 为 -1–1(默认0)。混响或非零声像不能与裸 PCM、μ-law、A-law 组合,无音效附加费。
输出格式默认 mp3_44100_128,共28种 MP3、PCM、WAV、μ-law、A-law、Opus 值,完整列表见参数。裸 PCM 为16位小端;按结果的采样率、声道和 Content-Type 解码。时间戳、固定版本发音词典及安全控制是显式功能要求;无法执行完整请求时明确报错,不删除选项。
两模型基准价均为 **$0.00008/Unicode字符**($0.08/1000字符),按实际字符收费,不补齐千字符。仅累计 text,不计音色ID、设置和前后文;采用提交时价格与分组倍率,完成后多退少补,失败按任务规则退款。
提交后查询任务,完成后下载 results[0].url。文件元数据与实际返回的对齐字段保留;普通音频结果可能没有 alignment、voice_segments,不能据缺失字段推导时间戳。请及时保存音频。
迁移旧请求:voice → voice_id,平铺设置 → voice_settings,Speech future_text → next_text。旧字段与未知嵌套字段明确拒绝;已受理任务及历史账单保持原合同。旧 Turbo 名称无兼容别名。授权
请求体
application/json
1–10000 个 Unicode 字符,含空格、标点和音频标签。
Required string length:
1 - 10000示例:
"欢迎收听。"
音频编码、采样率及码率;共 28 种格式。
可用选项:
mp3_22050_32, mp3_24000_48, mp3_44100_32, mp3_44100_64, mp3_44100_96, mp3_44100_128, mp3_44100_192, pcm_8000, pcm_16000, pcm_22050, pcm_24000, pcm_32000, pcm_44100, pcm_48000, wav_8000, wav_16000, wav_22050, wav_24000, wav_32000, wav_44100, wav_48000, ulaw_8000, alaw_8000, opus_48000_32, opus_48000_64, opus_48000_96, opus_48000_128, opus_48000_192 示例:
"mp3_44100_128"
响应
任务创建成功