Suno MIDI Generation API 연동 안내

SUNO를 사용하면 생성된 음악을 2차 창작하고 음악의 MIDI를 가져올 수 있으며, 이 문서에서는 관련 API의 연동 방법을 설명합니다.

이 API의 핵심 입력 매개변수는 audio_id이며, 전체 트랙 분리(action: "all_stems")가 완료된 후 선택한 오디오 트랙의 data[].id를 입력합니다. async: true 또는 callback_url을 선택적으로 사용할 수 있습니다. 곡 생성

공식 웹사이트에서 Edit → Get stems를 통해 Extract Stems and MIDI를 엽니다. 아래 그림은 트랙 분리 단계를 보여줍니다. 분리가 완료되면 필요한 오디오 트랙을 선택하고 Get MIDI를 클릭합니다. Suno Studio 내보내기 안내

Suno 공식 웹사이트의 MIDI 추출 전 트랙 분리 팝업

여기에 입력한 audio_id는 57e07045-43bb-40b3-9989-d57e0083339e이며, 이번 트랙 분리로 얻은 드럼 트랙 ID입니다.

import os

import requests

url = "https://api.acedata.cloud/suno/midi"
headers = {
    "accept": "application/json",
    "authorization": f"Bearer {os.environ['API_KEY']}",
    "content-type": "application/json",
}
payload = {
    "audio_id": "57e07045-43bb-40b3-9989-d57e0083339e",
    "async": True,
}

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

비동기로 반환된 task_id는 작업을 조회하는 데 사용합니다. 완료 후 response.data에서 아래 결과를 가져오며, 콜백에서는 data를 직접 사용합니다. 다음은 해당 오디오 트랙의 실제 테스트 응답입니다. 작업 조회

  "success": true,
  "task_id": "8341d069-c6ec-4f93-b441-42aa1f038e76",
  "trace_id": "32c6f889-fe35-402d-b801-9854791a7e54",
  "data": [
    {
      "state": "complete",
      "instruments": [
        {
          "name": "drums",
          "program": 0,
          "notes": [
            {
              "pitch": 37,
              "start": 7.5625,
              "end": 7.5640624999999995,
              "velocity": 0.48031496062992124
            }, {
              "pitch": 37,
              "start": 8.1875,
              "end": 8.188541666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 8.8125,
              "end": 8.813541666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 9.4375,
              "end": 9.438541666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 10.0625,
              "end": 10.0640625,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 10.6875,
              "end": 10.6890625,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 11.3125,
              "end": 11.3140625,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 11.9375,
              "end": 11.9390625,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 12.5625,
              "end": 12.5640625,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 13.182291666666666,
              "end": 13.183854166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 13.802083333333334,
              "end": 13.803645833333333,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 14.421875,
              "end": 14.422916666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 15.046875,
              "end": 15.047916666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 15.671875,
              "end": 15.672916666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 16.296875,
              "end": 16.297916666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 16.921875,
              "end": 16.922916666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 17.546875,
              "end": 17.547916666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 18.171875,
              "end": 18.172916666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 18.791666666666668,
              "end": 18.793229166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 19.416666666666668,
              "end": 19.418229166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 20.041666666666668,
              "end": 20.043229166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 20.666666666666668,
              "end": 20.668229166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 21.286458333333332,
              "end": 21.2875,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 21.911458333333332,
              "end": 21.9125,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 22.536458333333332,
              "end": 22.538020833333334,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 23.15625,
              "end": 23.1578125,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 23.78125,
              "end": 23.7828125,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 24.40625,
              "end": 24.4078125,
              "velocity": 0.4645669291338583
            },
{
              "pitch": 37,
              "start": 25.03125,
              "end": 25.0328125,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 25.65625,
              "end": 25.6578125,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 26.28125,
              "end": 26.2828125,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 26.901041666666668,
              "end": 26.902604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 27.526041666666668,
              "end": 27.527604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 28.151041666666668,
              "end": 28.152604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 28.776041666666668,
              "end": 28.777604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 29.401041666666668,
              "end": 29.402604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 30.026041666666668,
              "end": 30.027604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 30.651041666666668,
              "end": 30.652604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 31.276041666666668,
              "end": 31.277604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 31.901041666666668,
              "end": 31.902604166666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 32.526041666666664,
              "end": 32.52760416666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 35.067708333333336,
              "end": 35.06875,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 35.692708333333336,
              "end": 35.69375,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 36.317708333333336,
              "end": 36.319270833333334,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 36.942708333333336,
              "end": 36.944270833333334,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 37.572916666666664,
              "end": 37.57447916666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 38.197916666666664,
              "end": 38.19947916666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 38.822916666666664,
              "end": 38.82447916666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 39.447916666666664,
              "end": 39.44947916666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 40.072916666666664,
              "end": 40.07447916666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 40.697916666666664,
              "end": 40.69947916666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 41.328125,
              "end": 41.329166666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 41.953125,
              "end": 41.954166666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 42.578125,
              "end": 42.579166666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 43.203125,
              "end": 43.204166666666666,
              "velocity": 0.4645669291338583
            }, {
              "pitch": 37,
              "start": 43.833333333333336,
              "end": 43.834375,
              "velocity": 0.4645669291338583
            },
            {
              "pitch": 37,
              "start": 44.458333333333336,
              "end": 44.459375,
              "velocity": 0.4645669291338583
            }
          ],
          "is_drum": true
        }
      ]
    }
  ]
}

보시다시피 data에는 전체 트랙을 분리한 후 선택한 트랙의 MIDI 정보가 포함되어 있습니다. state: "complete"는 결과를 읽을 수 있음을 나타냅니다.

  • instruments[]는 악기별로 그룹화되며, name은 악기 이름이고 program은 MIDI 음색 번호입니다.
  • notes[]는 각 음표를 기록합니다. pitch는 MIDI 음높이이고, start와 end는 시작 및 종료 시간(초)이며, velocity는 세기입니다.