我正在尝试将一系列 wav 文件合并到一个音频文件中。到目前为止,这就是我所拥有的。我不知道如何将这些对象加在一起,因为它们都是一个对象。
import glob, os
from pydub import AudioSegment
wavfiles = []
for file in glob.glob('*.WAV'):
wavfiles.append(file)
outfile = "sounds.wav"
pydubobjects = []
for file in wavfiles:
pydubobjects.append(AudioSegment.from_wav(file))
combined_sounds = sum(pydubobjects) #this is what doesn't work of course
# it should be like so
# combined_sounds = sound1 + sound2 + sound 3
# with each soundX being a pydub object
combined_sounds.export(outfile, format='wav')