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
Create an instance of the Merger class and pass the path to the first audio file.
Call merger.join() with the path to each audio file to append. Each one must be of the same format as the first.
Call merger.save() with the path of the merged audio file.
fromgroupdocs.mergerimportMergerdefmerge_mp3_files():# Load the first MP3 filewithMerger("./input.mp3")asmerger:# Append the second MP3 filemerger.join("./input2.mp3")# Save the merged audiomerger.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.
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.