Merge audio

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Merger MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-merger -- dnx GroupDocs.Merger.Mcp --yes
Folders, licensing and more →

GroupDocs.Merger for Python via .NET combines audio files in the order you join them and saves them as one audio file, with no desktop audio software involved. Audio files are joined with files of the same format: MP3 with MP3, or WAV with WAV.

How to merge MP3 files in Python

  1. Create an instance of the Merger class and pass the path to the first audio file.
  2. Call merger.join() with the path to each audio file to append. Each one must be of the same format as the first.
  3. Call merger.save() with the path of the merged audio file.
from groupdocs.merger import Merger

def merge_mp3_files():
    # Load the first MP3 file
    with Merger("./input.mp3") as merger:
        # Append the second MP3 file
        merger.join("./input2.mp3")
        # Save the merged audio
        merger.save("./output.mp3")

if __name__ == "__main__":
    merge_mp3_files()

input.mp3 is a sample file used in this example. Click here to download it.

input2.mp3 is a sample file used in this example. Click here to download it.

Binary file (MP3, 88 KB)

Download full output

Explanation

  • Load the first file: Merger("./input.mp3") opens the first MP3 file inside a context manager. Its audio comes first in the result.
  • Append another file: merger.join("./input2.mp3") appends the second file’s audio after the first. Call join again for each additional file.
  • Save the result: merger.save("./output.mp3") writes the merged audio to disk.
Warning
Joining an audio file into a format it cannot be joined into (for example, a WAV file into an MP3 file) raises FileTypeNotSupportedException (from groupdocs.merger.exceptions): “Joining ‘Wav’ into ‘Mp3’ is not supported”.

Merge audio Live Demo

GroupDocs.Merger provides free online MP3 Merger App and WAV Merger App, which allow you to try it and check its quality.

API reference

See also