跳转到主要内容

接口

GET /api/v1/music/timeline?clip_id={clip_id}
同步接口。 立即返回逐词时间戳数据。 返回片段中每个歌词词语的起止时间戳,用于构建同步歌词显示(卡拉 OK 效果)、字幕文件或动态文字特效。

查询参数

参数类型是否必填说明
clip_idstring必填要获取时间轴的音频片段 ID。通过 音频上传 获取(data.clipId),或使用生成任务完成后的 results[].id

响应

{
  "code": 0,
  "message": "ok",
  "request_id": "req-1710000000000",
  "data": {
    "aligned": [
      { "word": "你好", "start": 2.14, "end": 2.56 },
      { "word": "世界", "start": 2.58, "end": 2.99 },
      { "word": "这就是", "start": 3.1, "end": 3.3 },
      { "word": "音乐", "start": 3.5, "end": 3.95 }
    ]
  }
}
字段类型说明
alignedarray逐词时间戳对象数组
aligned[].wordstring歌词词语
aligned[].startfloat起始时间(秒)
aligned[].endfloat结束时间(秒)

示例

curl "https://api.example.com/api/v1/music/timeline?clip_id=abc123def456" \
  -H "Authorization: Bearer sk-mm-your-key"

应用场景:卡拉 OK 歌词显示

遍历 aligned 数组,根据当前播放时间高亮当前词语:
function getCurrentWord(aligned, currentTime) {
  return aligned.find(w => currentTime >= w.start && currentTime <= w.end);
}