2016-03-06 86 views
0

有什么办法将两个音频文件连接或合并为一个?连接音频文件[Python 2.7]

要求:必须使用内置模块只[可以使用pygame的]

音频文件格式:.wma格式或.wav或.MP3

我已经在许多问题现在看起来和发现涉及下载模块的解决方案(我不喜欢)。

任何帮助将受到欢迎。

+0

你尝试寻找它? pydub:http://pydub.com/? – MaxU

+0

我做了,我发现安装过程非常繁琐 – qwerty

+0

然后定义“适当的解决方案”,请 – MaxU

回答

0

我做了一些研究,发现这一点。

#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 

here

0

其实我设法只是连接,只要两个文件由同一编码器产生连接两个FLAC文件:

audio1 = open("audio1.flac", "rb").read() 
audio2 = open("audio2.flac", "rb").read() 
audioJoin = audio1 + audio2 
audioFinal = open("audioFinal.flac", "wb").write(audioJoin)