1

我想在某个时间生成带有背景音乐和指令的锻炼 mp3 文件(例如“用力推”、“再做一次重复!”)

我用 pico2wave 生成​​指令并用 pydub 组装它们。

我这样做:

for timing,phrase in phrases.items():
        fileToAdd = pydub.AudioSegment.from_file(rep+"/"+str(timing)+".wav")
        finalFile = finalFile.fade(to_gain=-35, start=(timing*1000)-500, duration=500) # on diminue la chanson, une demi seconde avant
        finalFile = finalFile.fade(to_gain=+35, start=(timing*1000)+len(fileToAdd), duration=500) 
        fichierFinal = fichierFinal.overlay(fileToAdd,position=timing*1000) 

结果文件的质量很差。我尝试消除“褪色效果”并且质量很好(但我听不太清楚“说明”)

我怎样才能改变这个?我可以轻松地进行淡出和淡入效果吗?

谢谢,

问候,

阿克塞尔

4

1 回答 1

2

我认为问题在于您将音频淡化然后再次增强它(因此每次衰减然后增强时您都会损失 35dB 的动态范围)。

我认为更好的解决方案是拆分音频并仅减少您需要的部分(不进行任何增强操作)。

您在此处执行的操作有时称为“闪避”,因此我将在下面使用该名称:

def duck(sound, position, duration, gain=-15.0, fade_duration=500):
    """
    sound - an AudioSegment object
    position - how many milliseconds into the sound the duck should 
        begin (this is where overlaid audio could begin, the fade down
        will happen before this point)
    duration - how long should the sound stay quiet (milliseconds)
    gain - how much quieter should the sound get (in dB)
    fade_duration - how long sound the fades last (in milliseconds)
    """

    # this part is from the beginning until the end of the ducked section
    first_part = sound[:position+duration]
    first_part = first_part.fade(to_gain=gain, end=position, duration=fade_duration)

    # this part begins where the fade_up happens (will just fade in)
    second_part = sound[position+duration:]
    second_part = second_part.fade(from_gain=gain, start=0, duration=fade_duration)

    return first_part + second_part


for timing, phrase in phrases.items():
    fileToAdd = pydub.AudioSegment.from_file(rep+"/"+str(timing)+".wav")

    finalFile = duck(finalFile, position=timing*1000, duration=len(fileToAdd))

    finalFile = finalFile.overlay(fileToAdd, position=timing*1000) 

经过一些测试,35dB 可能比你想要的要多。15dB 对我来说听起来不错:)

于 2015-11-23T22:15:58.060 回答