def calibrate_param(data_path): # load data X, y, mapping = load_data(data_path) full_band_energy = 0 unvoiced_buffer = [] for i in range(N): f = Frame(X[i], y[i]) temp = f.calculate_full_band_energy(X[i]) # add noise frame to noise buffer unvoiced_buffer.append(temp) full_band_energy += temp full_band_avarage = full_band_energy / N return full_band_avarage, unvoiced_buffer
mapping = np.array(data["mapping"]) return X, y # main if __name__ == '__main__': X_voice, y_voice = load_data(DATA_PATH_VOICE) X_noise, y_noise = load_data(DATA_PATH_NOISE) energy_voice = 0 counter = 0 temp = 0 for (samples, c) in zip(X_voice, y_voice): f = Frame(samples, c) temp = f.calculate_full_band_energy(f.samples) energy_voice += temp counter += 1 energy_voice = energy_voice / counter energy_noise = 0 counter = 0 temp = 0 for (samples, c) in zip(X_noise, y_noise): f = Frame(samples, c) temp = f.calculate_full_band_energy(f.samples) energy_noise += temp counter += 1