import requests
url = "https://api.musicgpt.com/api/public/v1/audio_to_midi"
headers = {"Authorization": "<<<api key>>>"}
# Option 1: Use audio URL
payload = {
"audio_url": "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, data=payload)
print(response.json())
# Option 2: Upload local audio file
payload = {
"sonify_midi": True,
"save_note_events": True,
"webhook_url": "https://your-webhook-url.com/callback"
}
with open("audio.wav", "rb") as f:
files = {"audio_file": f}
response = requests.post(url, headers=headers, data=payload, files=files)
print(response.json())
{
"success": true,
"task_id": "task789",
"message": "MIDI conversion task queued successfully"
}
Processes an audio file and converts it into a MIDI file. Optionally generates a sonified .wav and/or a CSV of note events. This request is handled asynchronously.
import requests
url = "https://api.musicgpt.com/api/public/v1/audio_to_midi"
headers = {"Authorization": "<<<api key>>>"}
# Option 1: Use audio URL
payload = {
"audio_url": "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, data=payload)
print(response.json())
# Option 2: Upload local audio file
payload = {
"sonify_midi": True,
"save_note_events": True,
"webhook_url": "https://your-webhook-url.com/callback"
}
with open("audio.wav", "rb") as f:
files = {"audio_file": f}
response = requests.post(url, headers=headers, data=payload, files=files)
print(response.json())
{
"success": true,
"task_id": "task789",
"message": "MIDI conversion task queued successfully"
}
MIDI conversion task initiated successfully
The response is of type object
.