我正在尝试创建两个音轨(声乐和器乐)的混合,这是相同的持续时间(3:30)。但是,当我尝试使用叠加功能时,我的声音开始得太快了。
from pydub import AudioSegment
sound1 = AudioSegment.from_file("vocals.mp3")
sound2 = AudioSegment.from_file("instrumental.mp3")
combined = sound1.overlay(sound2)
combined.export("mix.mp3", format='mp3')发布于 2021-02-22 06:27:24
我相信你可以使用overlay的位置,其中def overlay(self, seg, position=0, loop=False, times=None, gain_during_overlay=None)参数表示你希望在原始声音上从哪里开始。
# This takes the duration of sound2 and overlays
# sound1 after 10% of the song2's duration.
combined = sound2.overlay(sound1, position=0.1*len(sound2))请注意,这将使您的歌曲总长度与sound1一样长,为了解决这个问题,您可以添加歌曲的其余部分:
if len(sound2) < len(sound1):
# Play the last 10% of the song1
combined += sound2[-1.1*len(sound1)+len(sound2):]https://stackoverflow.com/questions/60918209
复制相似问题