replace section
Replace a section of lyrics in an existing song to generate new music. The new lyrics should overlap with the original lyrics, and the timing should correspond appropriately.
Credits cost: 15
How to Use
Original lyrics:
[Verse 1]
Walking down the street
Feeling the beat
[Chorus]
This is my song
Singing all day long
[Verse 2]
Under the moonlight
Everything feels right
[Outro]
The night goes on
If you want to replace Verse 2 with new lyrics:
- infill_lyrics: [Verse 2]\nDancing in the rain\nForgetting all the pain (the new lyrics to replace)
- prompt: This is my song\nSinging all day long\n\n[Verse 2]\nDancing in the rain\nForgetting all the pain\n\n[Outro]\nThe night goes on (context with original lyrics before and after the new lyrics)
- infill_start_s: 45 (start time of Verse 2)
- infill_end_s: 60 (end time of Verse 2)
This way, the system can generate the best result based on the context and new lyrics fragment.
Auto Concat Feature
When auto_concat is set to true, the system will automatically concatenate the replaced sections into complete songs:
- Replace Section: Generates 2 replaced music fragments
- Auto Concat: Automatically concatenates each fragment into a full song
- Result: Returns 2 sets of paired data, each containing:
- replaced: The replaced section fragment
- full: The complete concatenated song
Response format with auto_concat:
{
"code": 200,
"data": [
{
"replaced": { /* Fragment 1 data */ },
"full": { /* Complete song 1 data */ }
},
{
"replaced": { /* Fragment 2 data */ },
"full": { /* Complete song 2 data */ }
}
],
"message": "success"
}
Without auto_concat (default): Returns only the 2 replaced fragments, you need to manually call the concat API to get complete songs.
Important Notes
- infill_start_s must be less than infill_end_s
- Both time values must be non-negative
- The new lyrics should have some overlap with the original lyrics
- Timing should correspond appropriately for best results
- When using auto_concat=true, polling may take longer as it waits for both replace and concat operations to complete
Polling Result
Use the task query endpoint with the returned task_id to poll for results. Recommended polling interval: 15-25 seconds.
Status codes during auto_concat:
- 202: Task in progress (replace section or concat in progress)
- 200: Task completed successfully
Request
- Base URLhttps://api.musicapi.ai
- URLhttps://api.musicapi.ai/api/v1/sonic/replace-section
- AuthHTTP bearer
Request body
Response
success
Changes
No recorded changes to this operation across all 1 revision of this API.