歌词时间轴
- 生成逐句对齐的歌词时间轴,用于卡拉 OK 类应用,异步任务
- 结果含对齐数据与波形数据
- 只返回数据,不产出音频
认证
All endpoints authenticate with a Bearer token.
Get an API key: open the console and create one.
Add it to the request header:
Authorization: Bearer YOUR_OAIRoute_KEY请求参数
音频模型,默认 suno。
生成源音轨那次任务的 task_id。缺失或无法解析源音轨时,提交阶段直接返回 400。
引用源任务结果 data.result.music[] 中的第几首,默认 1,从 1 开始。一次生成通常 2 首。
本端点没有 version 参数,传入会被忽略,不影响计费。
The audio model; defaults to suno.
The task_id of the task that produced the source track. When it's missing or the source can't be resolved, submission returns a 400.
Which track in the source task's data.result.music[], default 1, starting at 1. A single generation usually has 2.
This endpoint has no version parameter; passing one is ignored and doesn't affect billing.
响应
响应状态码。
任务状态,取值 submitted。
任务唯一标识,用于后续轮询。
The response status code.
The task status: submitted.
The unique task identifier, for later polling.
轮询结果
逐句对齐结果,优先读取这个字段。
波形数据,优先读取。
历史任务可能返回该字段。
历史任务可能返回该字段。
历史任务可能返回该字段。
返回结构有新旧两套。新任务读 result.alignment 与 result.waveform_data;老任务的数据在 music[] 下的三个字段里。接的时候按这两个位置分别兜底,否则老数据会读出空值。
The line-by-line alignment results; read this field first.
Waveform data; read first.
Older tasks may return this field.
Older tasks may return this field.
Older tasks may return this field.
There are two response structures, old and new. New tasks read result.alignment and result.waveform_data; old tasks keep their data in the three fields under music[]. Handle both locations as fallbacks when integrating, or old data reads back empty.
怎么用这份数据
卡拉 OK 类应用需要三样东西:每句歌词、该句的起止时间、当前播放位置。
// 播放时按时间轴滚动高亮
function highlight(audio, alignment) {
audio.addEventListener("timeupdate", () => {
const t = audio.currentTime;
const idx = alignment.findIndex(
(line) => t >= line.start && t < line.end
);
document.querySelectorAll(".lyric-line").forEach((el, i) => {
el.classList.toggle("active", i === idx);
});
});
}字段名(start、end)以实际返回为准,第一次接的时候先打印一条看结构。
waveform_data 可以用来画波形进度条,比单纯的时间条更有节奏感。
A karaoke-style app needs three things: each lyric line, that line's start and end times, and the current playback position.
// Scroll-and-highlight along the timeline during playback
function highlight(audio, alignment) {
audio.addEventListener("timeupdate", () => {
const t = audio.currentTime;
const idx = alignment.findIndex(
(line) => t >= line.start && t < line.end
);
document.querySelectorAll(".lyric-line").forEach((el, i) => {
el.classList.toggle("active", i === idx);
});
});
}The field names (start, end) follow what's actually returned; print one entry to check the structure the first time you integrate.
waveform_data can drive a waveform progress bar, which feels more rhythmic than a plain time bar.
错误码
| HTTP | type | 说明 |
|---|---|---|
| 400 | invalid_request_error | 请求参数无效 |
| 401 | authentication_error | 身份验证失败,请检查API密钥 |
| 402 | payment_required | 账户余额不足 |
| 429 | rate_limit_error | 请求过于频繁 |
| HTTP | type | Notes |
|---|---|---|
| 400 | invalid_request_error | Invalid request parameters |
| 401 | authentication_error | Authentication failed; check the API key |
| 402 | payment_required | Insufficient account balance |
| 429 | rate_limit_error | Too many requests |
For more status codes and retry guidance see Error codes and rate limits; for troubleshooting steps on common errors see the FAQ.
使用示例
提交一个任务并拿到 task_id:
提交成功只表示任务已受理。真正的产物要拿返回的 task_id 去任务查询接口轮询,status 变成 completed 之后才有结果。
Submit a task and get a task_id:
A successful submission only means the task was accepted. To get the actual output, poll the task query endpoint with the returned task_id; results appear only after status becomes completed.