添加人声
curl --request POST \
--url https://apibox.erweima.ai/api/v1/generate/add-vocals \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "带有舒缓人声的平静放松钢琴曲",
"title": "带人声的轻松钢琴",
"negativeTags": "重金属, 激进人声",
"style": "爵士",
"uploadUrl": "https://example.com/instrumental.mp3",
"callBackUrl": "https://api.example.com/callback",
"vocalGender": "m",
"styleWeight": 0.61,
"weirdnessConstraint": 0.72,
"audioWeight": 0.65,
"model": "V4_5PLUS"
}
'import requests
url = "https://apibox.erweima.ai/api/v1/generate/add-vocals"
payload = {
"prompt": "带有舒缓人声的平静放松钢琴曲",
"title": "带人声的轻松钢琴",
"negativeTags": "重金属, 激进人声",
"style": "爵士",
"uploadUrl": "https://example.com/instrumental.mp3",
"callBackUrl": "https://api.example.com/callback",
"vocalGender": "m",
"styleWeight": 0.61,
"weirdnessConstraint": 0.72,
"audioWeight": 0.65,
"model": "V4_5PLUS"
}
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({
prompt: '带有舒缓人声的平静放松钢琴曲',
title: '带人声的轻松钢琴',
negativeTags: '重金属, 激进人声',
style: '爵士',
uploadUrl: 'https://example.com/instrumental.mp3',
callBackUrl: 'https://api.example.com/callback',
vocalGender: 'm',
styleWeight: 0.61,
weirdnessConstraint: 0.72,
audioWeight: 0.65,
model: 'V4_5PLUS'
})
};
fetch('https://apibox.erweima.ai/api/v1/generate/add-vocals', 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://apibox.erweima.ai/api/v1/generate/add-vocals",
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([
'prompt' => '带有舒缓人声的平静放松钢琴曲',
'title' => '带人声的轻松钢琴',
'negativeTags' => '重金属, 激进人声',
'style' => '爵士',
'uploadUrl' => 'https://example.com/instrumental.mp3',
'callBackUrl' => 'https://api.example.com/callback',
'vocalGender' => 'm',
'styleWeight' => 0.61,
'weirdnessConstraint' => 0.72,
'audioWeight' => 0.65,
'model' => 'V4_5PLUS'
]),
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://apibox.erweima.ai/api/v1/generate/add-vocals"
payload := strings.NewReader("{\n \"prompt\": \"带有舒缓人声的平静放松钢琴曲\",\n \"title\": \"带人声的轻松钢琴\",\n \"negativeTags\": \"重金属, 激进人声\",\n \"style\": \"爵士\",\n \"uploadUrl\": \"https://example.com/instrumental.mp3\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"model\": \"V4_5PLUS\"\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://apibox.erweima.ai/api/v1/generate/add-vocals")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"带有舒缓人声的平静放松钢琴曲\",\n \"title\": \"带人声的轻松钢琴\",\n \"negativeTags\": \"重金属, 激进人声\",\n \"style\": \"爵士\",\n \"uploadUrl\": \"https://example.com/instrumental.mp3\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"model\": \"V4_5PLUS\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apibox.erweima.ai/api/v1/generate/add-vocals")
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 \"prompt\": \"带有舒缓人声的平静放松钢琴曲\",\n \"title\": \"带人声的轻松钢琴\",\n \"negativeTags\": \"重金属, 激进人声\",\n \"style\": \"爵士\",\n \"uploadUrl\": \"https://example.com/instrumental.mp3\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"model\": \"V4_5PLUS\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "success",
"data": {
"taskId": "5c79****be8e"
}
}Generate Music
添加人声
通过为上传的音频文件添加人声元素,为现有的器乐音乐生成人声轨道
POST
/
api
/
v1
/
generate
/
add-vocals
添加人声
curl --request POST \
--url https://apibox.erweima.ai/api/v1/generate/add-vocals \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "带有舒缓人声的平静放松钢琴曲",
"title": "带人声的轻松钢琴",
"negativeTags": "重金属, 激进人声",
"style": "爵士",
"uploadUrl": "https://example.com/instrumental.mp3",
"callBackUrl": "https://api.example.com/callback",
"vocalGender": "m",
"styleWeight": 0.61,
"weirdnessConstraint": 0.72,
"audioWeight": 0.65,
"model": "V4_5PLUS"
}
'import requests
url = "https://apibox.erweima.ai/api/v1/generate/add-vocals"
payload = {
"prompt": "带有舒缓人声的平静放松钢琴曲",
"title": "带人声的轻松钢琴",
"negativeTags": "重金属, 激进人声",
"style": "爵士",
"uploadUrl": "https://example.com/instrumental.mp3",
"callBackUrl": "https://api.example.com/callback",
"vocalGender": "m",
"styleWeight": 0.61,
"weirdnessConstraint": 0.72,
"audioWeight": 0.65,
"model": "V4_5PLUS"
}
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({
prompt: '带有舒缓人声的平静放松钢琴曲',
title: '带人声的轻松钢琴',
negativeTags: '重金属, 激进人声',
style: '爵士',
uploadUrl: 'https://example.com/instrumental.mp3',
callBackUrl: 'https://api.example.com/callback',
vocalGender: 'm',
styleWeight: 0.61,
weirdnessConstraint: 0.72,
audioWeight: 0.65,
model: 'V4_5PLUS'
})
};
fetch('https://apibox.erweima.ai/api/v1/generate/add-vocals', 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://apibox.erweima.ai/api/v1/generate/add-vocals",
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([
'prompt' => '带有舒缓人声的平静放松钢琴曲',
'title' => '带人声的轻松钢琴',
'negativeTags' => '重金属, 激进人声',
'style' => '爵士',
'uploadUrl' => 'https://example.com/instrumental.mp3',
'callBackUrl' => 'https://api.example.com/callback',
'vocalGender' => 'm',
'styleWeight' => 0.61,
'weirdnessConstraint' => 0.72,
'audioWeight' => 0.65,
'model' => 'V4_5PLUS'
]),
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://apibox.erweima.ai/api/v1/generate/add-vocals"
payload := strings.NewReader("{\n \"prompt\": \"带有舒缓人声的平静放松钢琴曲\",\n \"title\": \"带人声的轻松钢琴\",\n \"negativeTags\": \"重金属, 激进人声\",\n \"style\": \"爵士\",\n \"uploadUrl\": \"https://example.com/instrumental.mp3\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"model\": \"V4_5PLUS\"\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://apibox.erweima.ai/api/v1/generate/add-vocals")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"带有舒缓人声的平静放松钢琴曲\",\n \"title\": \"带人声的轻松钢琴\",\n \"negativeTags\": \"重金属, 激进人声\",\n \"style\": \"爵士\",\n \"uploadUrl\": \"https://example.com/instrumental.mp3\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"model\": \"V4_5PLUS\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apibox.erweima.ai/api/v1/generate/add-vocals")
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 \"prompt\": \"带有舒缓人声的平静放松钢琴曲\",\n \"title\": \"带人声的轻松钢琴\",\n \"negativeTags\": \"重金属, 激进人声\",\n \"style\": \"爵士\",\n \"uploadUrl\": \"https://example.com/instrumental.mp3\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"model\": \"V4_5PLUS\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "success",
"data": {
"taskId": "5c79****be8e"
}
}使用指南
- 此接口通过添加人声元素来增强器乐曲目
- 接受上传的音频文件,并根据您的规格生成人声
- 上传的音频必须可公开访问且采用支持的格式(MP3、WAV等)
参数详情
- 必需字段:
uploadUrl、callBackUrl、prompt、title、negativeTags、style - callBackUrl:必须是有效的、可公开访问的音频文件URL
- style:描述整体流派和人声方法(爵士、古典、电子、流行)
- negativeTags:要从生成中排除的音乐风格或人声特征
- title:用作生成的人声曲目的标题
可选参数
以下字段是此接口可用的可选控制:
- vocalGender (string):首选人声性别。允许的值:
m(男性)、f(女性) - styleWeight (number):范围0-1的风格权重(建议两位小数)
- weirdnessConstraint (number):范围0-1的创意/新颖性约束(建议两位小数)
- audioWeight (number):范围0-1的音频一致性相对权重(建议两位小数)
- model (string):用于生成的模型版本。可选值:
V4_5PLUS(默认)、V5、V5_5
开发者注意事项
- 回调过程有三个阶段:
text(文本生成)、first(第一轨道完成)、complete(所有轨道完成) - 在某些情况下,
text和first阶段可能被跳过,直接返回complete - 详细回调格式请参见添加人声回调
- 使用获取音乐生成详情监控任务进度
授权
🔑 API 认证说明
所有接口都需要通过 Bearer Token 方式进行认证。
获取 API Key
- 访问 API Key 管理页面 获取您的 API Key
使用方式
在请求头中添加:
Authorization: Bearer YOUR_API_KEY
⚠️ 注意:
- 请妥善保管您的 API Key,不要泄露给他人
- 如果怀疑 API Key 泄露,请立即在管理页面重置
请求体
application/json
为其生成人声的音频内容描述。必填。提供所需人声风格和内容的上下文。
示例:
"带有舒缓人声的平静放松钢琴曲"
音乐曲目的标题。必填。这将作为生成的人声曲目的标题。
示例:
"带人声的轻松钢琴"
要从生成的曲目中排除的音乐风格或人声特征。必填。用于避免特定的人声风格或特征。
示例:
"重金属, 激进人声"
音乐和人声风格。必填。例如:爵士、古典、电子、流行。描述整体流派和人声方法。
示例:
"爵士"
要添加人声的上传音频文件的URL。必须是系统可以访问的有效音频文件URL。上传的音频应该采用支持的格式(MP3、WAV等)。
示例:
"https://example.com/instrumental.mp3"
当人声生成完成时接收任务完成通知的URL。回调过程分为三个阶段:text、first、complete。在某些情况下,text和first阶段可能被跳过,直接返回complete。
示例:
"https://api.example.com/callback"
首选人声性别。可选。允许的值:m(男性)、f(女性)。
可用选项:
m, f 示例:
"m"
风格权重。可选。范围:0-1。建议保留两位小数。
必填范围:
0 <= x <= 1必须是以下数值的倍数 0.01示例:
0.61
创意/新颖性约束。可选。范围:0-1。建议保留两位小数。
必填范围:
0 <= x <= 1必须是以下数值的倍数 0.01示例:
0.72
音频一致性与其他控制的相对权重。可选。范围:0-1。建议保留两位小数。
必填范围:
0 <= x <= 1必须是以下数值的倍数 0.01示例:
0.65
用于生成的模型版本。可选。默认值:V4_5PLUS。
可用选项:
V4_5PLUS, V5, V5_5 示例:
"V4_5PLUS"
响应
请求成功
状态码说明
- ✅ 200 - 请求成功
- ⚠️ 400 - 参数错误
- ⚠️ 401 - 没有访问权限
- ⚠️ 404 - 请求方式或者路径错误
- ⚠️ 405 - 调用超过限制
- ⚠️ 413 - 主题或者prompt过长
- ⚠️ 429 - 积分不足
- ⚠️ 430 - 您的调用频率过高。请稍后再试。
- ⚠️ 455 - 网站维护
- ❌ 500 - 服务器异常
可用选项:
200, 400, 401, 404, 405, 413, 429, 430, 455, 500 示例:
200
当 code != 200 时,展示错误信息
示例:
"success"
Show child attributes
Show child attributes
