POST
/
audio_to_midi
import requests

url = "https://api.example.com/api/public/v1/audio_to_midi"
headers = {"Authorization": "<API_KEY>", "accept": "application/json"}

payload = {
    "audio_path": "https://example.com/audio_file.wav",
    "sonify_midi": True,
    "save_note_events": True,
    "webhook_url": "https://your-webhook-url.com/callback"
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
{
  "success": true,
  "task_id": "task789",
  "message": "MIDI conversion task queued successfully"
}

Convert an audio file into a MIDI file using AI-driven audio analysis and transcription.

The Audio to MIDI endpoint processes audio files to generate MIDI sequences. It can optionally create a sonified .wav file of the MIDI output and export note events into a .csv file for further analysis or editing. Ideal for music production, remixing, and advanced audio content creation.


๐Ÿ“ก Endpoint

POST /audio_to_midi

This is the primary endpoint for initiating audio-to-MIDI conversion tasks.


โ–ถ๏ธ Sample Output

Generated MIDI and optional outputs from a sample audio file:

Download MIDI(.mid) Download Sonified MIDI(.wav)

๐Ÿงช Try it Yourself

Visit the Audio to MIDI Endpoint Explorer to test it live. Upload an audio file, and get back the MIDI version!


๐Ÿ› ๏ธ Request Parameters

ParameterTypeRequiredDefaultDescription
audio_pathStringโœ… Yes-The S3 path of the input audio file to convert.
sonify_midiBooleanOptionaltrueIf true, generates a .wav file that plays the MIDI output.
save_note_eventsBooleanOptionaltrueIf true, saves predicted note events as a .csv file.
webhook_urlStringOptional""Callback URL for asynchronous result delivery.

๐Ÿ’ก Note: audio_path must be a valid and accessible S3 URL.


๐Ÿ“ค Sample Request

๐Ÿš cURL

curl -X POST "https://api.example.com/api/public/v1/audio_to_midi" \
-H "accept: application/json" \
-H "Authorization: <api_key>" \
-d '{
  "audio_path": "s3://your-bucket/input_audio.wav",
  "sonify_midi": true,
  "save_note_events": true,
  "webhook_url": "https://yourdomain.com/webhook"
}'

๐Ÿ Python

import requests

url = "https://api.example.com/api/public/v1/audio_to_midi"
headers = {
    "accept": "application/json",
    "Authorization": "<api_key>"
}

payload = {
    "audio_path": "s3://your-bucket/input_audio.wav",
    "sonify_midi": True,
    "save_note_events": True,
    "webhook_url": "https://yourdomain.com/webhook"
}

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

๐Ÿ” Replace api_key, audio_path, and webhook_url with your own values before sending.


๐Ÿ“ฅ Sample Response

โœ… Success (200 OK)

{
  "success": true,
  "task_id": "abcdef1234567890",
  "status": "processing"
}

โŒ Common Errors

  • 400 Bad Request: Invalid audio_path or missing required parameters.
  • 404 Not Found: Provided audio file not found in S3.
  • 422 Unprocessable Entity: Unsupported audio format.
  • 500 Internal Server Error: An unexpected error occurred while processing.

๐Ÿ“ž Webhook Response

When the conversion process completes, if a webhook_url was provided, the system sends a POST request:

{
  "success": true, 
  "conversion_type": "Audio to MIDI", 
  "task_id": "f5b563e5-e414-47ec-989b-255c74d90119", 
  "conversion_id": "c7127f6b-e9a4-4d22-8804-d94a8521155a", 
  "midi_file_path": "https://lalals.s3.amazonaws.com/AudioToMidi/f5b563e5-e414-47ec-989b-255c74d90119.mid", 
  "sonify_file_path": "https://lalals.s3.amazonaws.com/AudioToMidi/f5b563e5-e414-47ec-989b-255c74d90119.wav", 
  "notes_file_path": "", 
  "message": "Audio to Midi Completed"
}

You can download your generated files using the provided URLs.


Payload and Request Formation

Make sure the JSON payload is well-formed and all mandatory fields are included when sending the request.

Authorizations

Authorization
string
header
required

Body

multipart/form-data

Response

200
application/json

MIDI conversion task initiated successfully

The response is of type object.