augmentations.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:audio_data_augmentation 作者: sid0710 项目源码 文件源码
def convolve(infile, ir_name, level = 0.5):
    """ Apply convolution to infile using impulse response given

    Args:
        infile (str): Filename
        ir_name can be  'smartphone_mic' or 'classroom'
        level (float) : can be between 0 and 1, default value = 0.5
    """
    fs1, x = monoWavRead(filename=infile)

    x = np.copy(x)
    #Change the path below for the sounds folder
    ir_path = './sounds/ir_{0}.wav'.format(ir_name)

    fs2, ir = monoWavRead(filename=ir_path)

    y = np.convolve(x, ir, 'full')[0:x.shape[0]] * level + x * (1 - level)

    #Change the output file name to suit your requirements here
    outfile_name = os.path.basename(infile).split(".")[0] + ("{0}_convolved{1}.wav".format(ir_name, level))
    outfile = os.path.join(outfile_path, outfile_name)
    write(filename = outfile, rate = fs1, data = y)
    if (FILE_DELETION):
        extractFeaturesAndDelete(outfile)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号