def main(): n_mfcc = 40 model_dir = '../models' model = Model(model_dir) signal, rate = au.read_wav('../../audio/trapphus.wav') signal_segment_list = au.split_signal(signal, rate=rate, segment_length=60000, min_energy=100, max_energy=4, debug=False) signal_segment_list = [ au.pad_to(segment, 2**16) for segment in signal_segment_list ] mfccs = [ au.waveform_to_mfcc(segment, rate, n_mfcc)[1][:, :-1] for segment in signal_segment_list ] nw_input = preprocess(mfccs) nw_output = model.forward(nw_input) rir_list = postprocess(nw_output, 0, True) rir_list_2 = postprocess(nw_output, 20, True) plt.show()
def preprocess_peaks(signal, fs): mfcc = au.waveform_to_mfcc(signal, fs, 40)[1][:,:-1] delta_1, delta_2 = au.calculate_delta_features(mfcc) mean = np.load('/home/felix/rirnet/database/mean.npy').T std = np.load('/home/felix/rirnet/database/std.npy').T normalized = np.nan_to_num((np.array([mfcc, delta_1, delta_2]).T - mean)/std).T return torch.tensor(normalized).unsqueeze(0).float()
def waveforms_to_mfccs(waveforms, db_setup): fs = db_setup['fs'] n_mfcc = db_setup['n_mfcc'] mfccs = [ au.waveform_to_mfcc(waveform, fs, n_mfcc)[1][:, :-1] for waveform in waveforms ] return mfccs