import requests
url = "https://api.musicgpt.com/api/public/v1/inpaint"
headers = {"Authorization": "<API_KEY>"}
data = {
"prompt": "Add a soft guitar solo here",
"replace_start_at": 12.5,
"replace_end_at": 20.0,
"lyrics": "This is where my story begins",
"gender": "male",
"webhook_url": "https://example.com/webhook"
}
# Option 1: audio_url
data["audio_url"] = "https://mybucket.s3.amazonaws.com/song.mp3"
response = requests.post(url, headers=headers, data=data)
# Option 2: File Upload
# with open("song.mp3", "rb") as f:
# files = {"audio_file": f}
# response = requests.post(url, headers=headers, data=data, files=files)
# print(response.json())
{
"success": true,
"message": "Inpaint request submitted successfully",
"task_id": "task-xyz-123",
"conversion_id_1": "inpaint-abc",
"conversion_id_2": "inpaint-def",
"eta": 40,
"credit_estimate": 45
}
This endpoint allows users to replace a specific time segment of an audio clip using a textual prompt and optional lyrics. The inpainting operation blends new audio content into the selected range, guided by user-defined style and voice preferences.
import requests
url = "https://api.musicgpt.com/api/public/v1/inpaint"
headers = {"Authorization": "<API_KEY>"}
data = {
"prompt": "Add a soft guitar solo here",
"replace_start_at": 12.5,
"replace_end_at": 20.0,
"lyrics": "This is where my story begins",
"gender": "male",
"webhook_url": "https://example.com/webhook"
}
# Option 1: audio_url
data["audio_url"] = "https://mybucket.s3.amazonaws.com/song.mp3"
response = requests.post(url, headers=headers, data=data)
# Option 2: File Upload
# with open("song.mp3", "rb") as f:
# files = {"audio_file": f}
# response = requests.post(url, headers=headers, data=data, files=files)
# print(response.json())
{
"success": true,
"message": "Inpaint request submitted successfully",
"task_id": "task-xyz-123",
"conversion_id_1": "inpaint-abc",
"conversion_id_2": "inpaint-def",
"eta": 40,
"credit_estimate": 45
}
Successfully initiated inpaint task
The response is of type object
.