0

Is there any way to concatenate or merge two audio files into one?

Requirements : Must use built-in modules only [may use PyGame]

Audio File format : .wma OR .wav OR .mp3

I have looked at many questions now and found solutions that involved downloading modules (which I do not prefer).

Any help would be welcome.

qwerty
  • 13
  • 1
  • 7

2 Answers2

2

I make some research and found this.

#import libraries
from glob import iglob
import shutil
import os
#create path variable
PATH = r'C:\music'
#create everything.mp3
destination = open('everything.mp3', 'wb')
for filename in iglob(os.path.join(PATH, '*.mp3')):
    shutil.copyfileobj(open(filename, 'rb'), destination)
#make them all together with for
destination.close()
#close file

from here.

Community
  • 1
  • 1
0

I actually managed to join two Flac files by just concatenation as long as the two files were produced by the same encoder:

audio1 = open("audio1.flac", "rb").read()
audio2 = open("audio2.flac", "rb").read()
audioJoin = audio1 + audio2
audioFinal = open("audioFinal.flac", "wb").write(audioJoin)
rearThing
  • 632
  • 3
  • 9
  • 26