首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pydub多次褪色后质量差

pydub多次褪色后质量差
EN

Stack Overflow用户
提问于 2015-11-23 20:39:14
回答 1查看 961关注 0票数 1

我想生成锻炼mp3文件与音乐在背景和指示在一定的时间(前)。“用力推”,“再重复一遍!")

我用pico2wave生成指令,然后用pydub组装它们。

我这样做:

代码语言:javascript
复制
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) 

结果文件质量很差。我试着消除“褪色效应”,质量很好(但我听不清楚“指示”)

我怎么才能改变这个?我能很容易地使一个淡出和褪色的效果?

谢谢,

致以敬意,

Axel

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-23 22:15:58

我认为问题是,您正在减弱音频,然后再增强它(因此,您正在失去35分贝的动态范围,每次你衰减,然后提高)。

我认为一个更好的解决方案是分割音频,只减少你需要的部分(没有任何提升操作)。

您在这里所做的操作有时被称为“躲避”,所以我将在下面使用这个名称:

代码语言:javascript
复制
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) 

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33880261

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档