从音频生成 MIDI
curl --request POST \
--url https://apibox.erweima.ai/api/v1/midi/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"taskId": "5c79****be8e",
"callBackUrl": "https://example.callback",
"audioId": "8ca376e7-******-08aaf2c6dd27"
}
'import requests
url = "https://apibox.erweima.ai/api/v1/midi/generate"
payload = {
"taskId": "5c79****be8e",
"callBackUrl": "https://example.callback",
"audioId": "8ca376e7-******-08aaf2c6dd27"
}
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({
taskId: '5c79****be8e',
callBackUrl: 'https://example.callback',
audioId: '8ca376e7-******-08aaf2c6dd27'
})
};
fetch('https://apibox.erweima.ai/api/v1/midi/generate', 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/midi/generate",
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([
'taskId' => '5c79****be8e',
'callBackUrl' => 'https://example.callback',
'audioId' => '8ca376e7-******-08aaf2c6dd27'
]),
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/midi/generate"
payload := strings.NewReader("{\n \"taskId\": \"5c79****be8e\",\n \"callBackUrl\": \"https://example.callback\",\n \"audioId\": \"8ca376e7-******-08aaf2c6dd27\"\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/midi/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"taskId\": \"5c79****be8e\",\n \"callBackUrl\": \"https://example.callback\",\n \"audioId\": \"8ca376e7-******-08aaf2c6dd27\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apibox.erweima.ai/api/v1/midi/generate")
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 \"taskId\": \"5c79****be8e\",\n \"callBackUrl\": \"https://example.callback\",\n \"audioId\": \"8ca376e7-******-08aaf2c6dd27\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "success",
"data": {
"taskId": "5c79****be8e"
}
}Vocal Removal
从音频生成 MIDI
将分离后的音轨转换为 MIDI 格式,为每个乐器提供详细的音符信息。
POST
/
api
/
v1
/
midi
/
generate
从音频生成 MIDI
curl --request POST \
--url https://apibox.erweima.ai/api/v1/midi/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"taskId": "5c79****be8e",
"callBackUrl": "https://example.callback",
"audioId": "8ca376e7-******-08aaf2c6dd27"
}
'import requests
url = "https://apibox.erweima.ai/api/v1/midi/generate"
payload = {
"taskId": "5c79****be8e",
"callBackUrl": "https://example.callback",
"audioId": "8ca376e7-******-08aaf2c6dd27"
}
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({
taskId: '5c79****be8e',
callBackUrl: 'https://example.callback',
audioId: '8ca376e7-******-08aaf2c6dd27'
})
};
fetch('https://apibox.erweima.ai/api/v1/midi/generate', 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/midi/generate",
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([
'taskId' => '5c79****be8e',
'callBackUrl' => 'https://example.callback',
'audioId' => '8ca376e7-******-08aaf2c6dd27'
]),
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/midi/generate"
payload := strings.NewReader("{\n \"taskId\": \"5c79****be8e\",\n \"callBackUrl\": \"https://example.callback\",\n \"audioId\": \"8ca376e7-******-08aaf2c6dd27\"\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/midi/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"taskId\": \"5c79****be8e\",\n \"callBackUrl\": \"https://example.callback\",\n \"audioId\": \"8ca376e7-******-08aaf2c6dd27\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apibox.erweima.ai/api/v1/midi/generate")
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 \"taskId\": \"5c79****be8e\",\n \"callBackUrl\": \"https://example.callback\",\n \"audioId\": \"8ca376e7-******-08aaf2c6dd27\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "success",
"data": {
"taskId": "5c79****be8e"
}
}使用指南
- 将分离后的音轨转换为包含音高、时间和力度信息的结构化 MIDI 数据
- 需要已完成的人声分离任务 ID(来自人声分离 API)
- 为检测到的多个乐器生成 MIDI 音符数据,包括鼓、贝斯、吉他、键盘等
- 适用于音乐转谱、记谱、混音或教育分析
- 在清晰、分离良好且乐器部分明确的音轨上效果最佳
前置条件
您必须首先使用 人声与乐器分离 API,然后才能生成 MIDI。
参数说明
| 参数名称 | 类型 | 说明 |
|---|---|---|
taskId | string | 必填。 已完成的人声分离任务 ID |
callBackUrl | string | 必填。 接收 MIDI 生成完成通知的回调 URL |
audioId | string | 可选。 指定要生成 MIDI 的分离音频轨道。此 audioId 可从获取人声分离详情接口的 originData 数组中获取。originData 数组中的每个项目都包含一个 id 字段,可在此处使用。如果不提供,将从所有分离的轨道生成 MIDI。 |
开发者注意事项
- 回调将包含每个检测到的乐器的详细音符数据
- 每个音符包含:
pitch(MIDI 音符编号)、start(秒)、end(秒)、velocity(0-1) - 不是所有乐器都会被检测到 - 取决于音频内容
- 计费说明: 请在 https://api.box/billing 查看当前每次调用的积分消耗
授权
🔑 API 认证说明
所有接口都需要通过 Bearer Token 方式进行认证。
获取 API Key
- 访问 API Key 管理页面 获取您的 API Key
使用方式
在请求头中添加:
Authorization: Bearer YOUR_API_KEY
⚠️ 注意:
- 请妥善保管您的 API Key,不要泄露给他人
- 如果怀疑 API Key 泄露,请立即在管理页面重置
请求体
application/json
已完成的人声分离任务 ID。这应该是从人声与乐器分离端点返回的 taskId。
示例:
"5c79****be8e"
可选。指定要生成 MIDI 的分离音频轨道。此 audioId 可从获取人声分离详情接口的 originData 数组中获取。originData 数组中的每个项目都包含一个 id 字段,可在此处使用。如果不提供,将从所有分离的轨道生成 MIDI。
示例:
"8ca376e7-******-08aaf2c6dd27"
