示例#1
0
def estimate(valid, v_W, c_W, valid_v, valid_c, r, score_inf=None):
    fn  = 'est/0' + r
    W = np.append(v_W, c_W, axis=1)
    H = NMF.extractActivation(valid, W)
    t_num = v_W.shape[1]
    
    if score_inf is not None :
        print('apply score inf')
        H = NMF.cons_Activation(score_inf, H) 

    v_H = H[0:t_num]
    c_H = H[t_num:H.shape[0]]
   
    o_v, o_c = reconstruct(valid, v_W, v_H, c_W, c_H)
    
    librosa.output.write_wav(fn + '_vio_est.wav', o_v, 44100)
    librosa.output.write_wav(fn + '_cla_est.wav', o_c, 44100)
    
    valid_v = valid_v[0:220160]
    valid_c = valid_c[0:220160]
    
    sdr, sir, sar, perm = basic.evalBSS(np.array([valid_v, valid_c]), np.array([o_v, o_c]))
   
    print(sdr)
    print(sir)
    print(sar)