Suno Timing API 연동 설명

SUNO는 생성된 음악을 2차 창작하고 음악의 가사와 오디오 타임라인을 가져올 수 있도록 지원하며, 이 문서에서는 관련 API의 연동 방법을 설명합니다.

data.aligned_words는 단어별 정렬 시간을 반환합니다. 이 페이지의 실제 테스트 응답에 있는 첫 세 단어를 예로 듭니다.

단어 시작(초) 종료(초)
창문 13.097 13.727
불빛 13.91583 14.86
가로질러 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는 파형 샘플입니다. 교체할 구간을 선택할 때 정렬 시간을 읽고 원곡을 들어 확인할 수 있습니다.