Suno Timing API 对接说明

SUNO 允许我们对生成的音乐进行二次创作,获取音乐的歌词、音频时间线,本文档讲解相关 API 的对接方法。

data.aligned_words 返回逐词的对齐时间。以本页实测响应中的前三个词为例。

词 开始(秒) 结束(秒)
Window 13.097 13.727
lights 13.91583 14.86
across 14.99667 15.7

该 API 只有一个输入参数,就是 audio_id,它是官方生成的歌曲ID。

这里输入的 audio_id 是 3f8c1800-7a96-4a2b-811f-5fee716a9e32。

import os

import requests

url = "https://api.orchats.repoingest.com/suno/timing"
headers = {
    "accept": "application/json",
    "authorization": f"Bearer {os.environ['API_KEY']}",
    "content-type": "application/json",
}
payload = {
    "audio_id": "3f8c1800-7a96-4a2b-811f-5fee716a9e32",
}

response = requests.post(url, json=payload, headers=headers, timeout=180)
print(response.text)

结果节选如下:

{
  "success": true,
  "task_id": "192b701b-8050-40f4-960c-29b54fd4822a",
  "trace_id": "b177ad51-617a-452a-a4ff-1115e8d2b347",
  "data": {
    "aligned_words": [
      {
        "word": "[Verse]\nWindow ",
        "success": true,
        "start_s": 13.097,
        "end_s": 13.727,
        "p_align": 0.99
      },
      {
        "word": "lights ",
        "success": true,
        "start_s": 13.91583,
        "end_s": 14.86,
        "p_align": 0.99
      },
      {
        "word": "across ",
        "success": true,
        "start_s": 14.99667,
        "end_s": 15.7,
        "p_align": 0.99
      },
      {
        "word": "the ",
        "success": true,
        "start_s": 15.78,
        "end_s": 15.948,
        "p_align": 0.99
      }
    ],
    "waveform_data": [
      0.14492,
      0.20651,
      0.1787
    ],
    "hoot_cer": 0.15671641791044777,
    "is_streamed": false,
    "aligned_lyrics": [
      {
        "text": "Window lights across the bay",
        "start_s": 13.097,
        "end_s": 16.188,
        "section": "Verse",
        "words": [
          {
            "text": "Window",
            "start_s": 13.097,
            "end_s": 13.727
          },
          {
            "text": " lights",
            "start_s": 13.727,
            "end_s": 14.86
          },
          {
            "text": " across",
            "start_s": 14.86,
            "end_s": 15.68
          },
          {
            "text": " the",
            "start_s": 15.7,
            "end_s": 15.94
          },
          {
            "text": " bay",
            "start_s": 15.948,
            "end_s": 16.188
          }
        ]
      },
      {
        "text": "Guide the boats that drift away",
        "start_s": 19.397,
        "end_s": 22.631,
        "section": "Verse",
        "words": [
          {
            "text": "Guide",
            "start_s": 19.397,
            "end_s": 19.789
          },
          {
            "text": " the",
            "start_s": 19.789,
            "end_s": 19.98
          },
          {
            "text": " bo",
            "start_s": 19.98,
            "end_s": 20.092
          },
          {
            "text": "ats",
            "start_s": 20.092,
            "end_s": 20.653
          },
          {
            "text": " that",
            "start_s": 20.689,
            "end_s": 21.063
          },
          {
            "text": " drift",
            "start_s": 21.22,
            "end_s": 22.07
          },
          {
            "text": " away",
            "start_s": 22.07,
            "end_s": 22.631
          }
        ]
      }
    ]
  }
}

aligned_words 字段说明

可以看到,data.aligned_words 是对象数组,每个对象代表一个带有时间信息的词或短语。

  • word: 歌词中的实际词或短语
  • success: 布尔值,表示此词的对齐是否成功
  • start_s: 词的开始时间
  • end_s: 词的结束时间
  • p_align: 对齐的概率或置信度分数,范围为 0 到 1

data.aligned_lyrics 给出行与词的时间,可用于滚动歌词。waveform_data 为波形采样。选取替换片段时,可以读取对齐时间并试听原曲核对。