utils.py 文件源码

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

项目:sourceseparation_misc 作者: ycemsubakan 项目源码 文件源码
def mag2spec_and_audio_wiener(xhat, recons, MS, MSphase, arguments):

    #xhat = xhat.cpu().numpy()
    #recons = recons.cpu().numpy()
    try:   # pytorch case
        MS = MS.cpu().numpy()
        MSphase = MSphase.cpu().numpy()
        Nmix = MSphase.shape[0]

        maghats = np.split(xhat, Nmix, axis=0) 
        reconss = np.split(recons, Nmix, axis=0) 
        mixmags = np.split(MS, Nmix, axis=0) 
        phases = np.split(MSphase, Nmix, axis=0)

    except:
        maghats = [xhat]
        reconss = [recons]
        mixmags = [MS]
        phases = [MSphase]


    all_audio = []
    eps = 1e-20
    for maghat, recons, mixmag, phase in zip(maghats, reconss, mixmags, phases):
        mask = (maghat / (recons + eps))
        all_audio.append(lr.istft((mask*mixmag*np.exp(1j*phase)).transpose(), 
                                  win_length=arguments.win_length))

    return all_audio, maghats
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号