Skip to main content
POST
/
tts
/
add-music
Add Background Music
curl --request POST \
  --url https://api.example.com/tts/add-music \
  --header 'Content-Type: application/json' \
  --data '
{
  "music_volume": 123,
  "fade_duration": 123,
  "api_key": "<string>"
}
'
Add background music to an existing audio file. The music will be looped to match the audio length and faded in/out for smooth transitions.

Request

audio
file
required
Audio file to add music to (MP3, WAV, etc.)
music
file
required
Background music file (MP3, WAV, etc.)
music_volume
number
default:"-20"
Music volume in decibels (dB). Range: -40 to 0
  • Lower values = quieter music
  • Higher values = louder music
  • Default: -20 dB (background level)
fade_duration
integer
default:"2000"
Fade in/out duration in milliseconds. Default: 2000ms (2 seconds)
api_key
string
required
Your GistMag API key

Response

Returns the combined audio file (voice + music) as MP3.

Credit Cost

1 credit per request (in addition to any credits used to generate the original audio).

Example Request

curl -X POST https://api.gistmag.co.uk/tts/add-music \
  -F "audio=@speech.mp3" \
  -F "music=@background.mp3" \
  -F "music_volume=-20" \
  -F "fade_duration=2000" \
  -F "api_key=your_api_key_here" \
  --output speech_with_music.mp3

How It Works

  1. The music file is adjusted to the specified volume
  2. If the music is shorter than the audio, it’s looped to match the length
  3. Music is trimmed to exactly match the audio duration
  4. Fade in/out effects are applied for smooth transitions
  5. The voice and music are combined into a single audio file

Tips

  • Use instrumental music to avoid conflicts with voice
  • Adjust music_volume to ensure the voice remains clear
  • Longer fade_duration creates smoother transitions
  • The music will automatically loop if shorter than the audio