print(" stft_sp_arr.shape = ", stft_sp_arr.shape) ################################################################# print('Calc steering vector!') print(' (angle_h, angle_v) = ', angle_h, angle_v) sensor_positions = get_sensor_positions(hor_mic_count, vert_mic_count, dHor=dHor, dVert=dVert) source_position = get_source_position(angle_h, angle_v) d_arr = propagation_vector_free_field(sensor_positions, source_position, N_fft=n_fft, F_s=sr) psd = get_power_spectral_density_matrix(stft_mix) w = get_mvdr_vector(d_arr.T, psd) result_mvdr_spec = apply_beamforming_vector(w, stft_mix) align_stft_arr = ds_align(stft_mix, d_arr.T) ################################################################# result_spec, H = zelin_filter(stft_arr=align_stft_arr, alfa=0.7, alg_type=0) print('Calc zelin filter output done!') ################################################################# result_spec = result_mvdr_spec * H
# 3 - Calc steering vector print('Calc steering vector!') print(' (angle_h, angle_v) = ', angle_h, angle_v) sensor_positions = get_sensor_positions(hor_mic_count, vert_mic_count, dHor=dHor, dVert=dVert) source_position = get_source_position(angle_h, angle_v) d_arr = propagation_vector_free_field(sensor_positions, source_position, N_fft=n_fft, F_s=sr) ################################################################# # 4 - Calc psd matrix psd_noise_matrix = get_power_spectral_density_matrix(stft_noise_arr) print('Calc psd matrix done!') print(' psd_noise_matrix.shape = ', psd_noise_matrix.shape) ################################################################# # 6 - Apply MVDR type_reg = 1 reg_p = 0.001 w = get_mvdr_vector_svd(d_arr.T, psd_noise_matrix, type_reg=type_reg, r=reg_p) result_spec = apply_beamforming_vector(w, stft_mix_arr) #################################################################
frame_segm = ilrma_sad(stft_mix_arr, sr, n_fft, n_overlap) elif type_sad == 'all': frame_segm = np.ones((n_frames)) else: assert False, 'type_sad = {} unsupported'.format(type_sad) noise_time = (np.sum((frame_segm)) * fft_hop_size) / sr print('MVDR_SAD_FILTER type = {} , detect noise only period = {} sec.'.format(type_sad, noise_time)) ################################################################# # 5 - Create mask by SAD segm mask = np.ones((n_bins, n_frames)) * (frame_segm) ################################################################# # 6 - Filter output psd = get_power_spectral_density_matrix(stft_mix_arr, mask=mask) if use_cmt: T_matrix = get_taper(hor_mic_count=hor_mic_count, vert_mic_count=vert_mic_count, dHor=dHor, dVert=dVert, angle_h=angle_h, angle_v=angle_v, sr=sr, fft_size=n_fft, bandwidth=0.5) for i in range(n_bins): psd[i, :, :] = np.multiply(psd[i, :, :], T_matrix[i]) # Regularisation psd = psd + 0.001 * np.identity(psd.shape[-1])